A simple Apex client library for using the Alpha Vantage API. Alpha Vantage provides free and paid access to financial market data. This project has no direct affiliation with Alpha Vantage. For the full list of functions and parameters used by the AlphaVantage API visit their API documentation.
ApexDocs for this project can be found here.
Alpha Vantage API Documentation can be found here.
This project is provided as an unmanaged SalesForce package. To install:
- Clone this repository.
git clone https://github.com/KThompso/avs.git
- Change the value of the
API_KEY
variable inAV.cls
to your Alpha Vantage API key. Don't have one? Request one for free here. - Build the package:
$ (cd avs && make salesforce-package)
- Deploy the
package
directory to your SalesForce org. E.g. using the ForceCLI tool to deploy to your test org:
$ force login -i test && force import -d avs/package/
HttpResponse resp = AVStock.intraday('MSFT', '5min', null);
if (resp.getStatusCode() == 200) {
Map<String, Object> m = (Map<String, Object>) JSON.deserializeUntyped(resp.getBody());
Map<String, Object> timeseries = (Map<String, Object>) m.get('Time Series (5min)');
for (String k : timeseries.keyset()) {
Map<String, Object> point = (Map<String, Object>) timeseries.get(k);
System.debug(k + ' : ' + point.get('1. open'));
}
} else {
System.debug(LoggingLevel.ERROR, resp.getBody());
}