BoxLang 🚀 A New JVM Dynamic Language Learn More...
Wraps the AlphaVantage API for easy CFML usage using the Hyper ColdBox module.
box install AlphaVantage
.env
moduleSettings
AlphaVantage can mainly be configured using environment variables:
ALPHAVANTAGE_API_KEY
- Required API key for authenticating with the AlphaVantage APIFINNUHB_API_URL
- base URL of the AlphaVantage API.You'll need to either use commandbox-dotenv
to automatically populate environment variables from the .env
file on server start, or manually read this file to populate environment variables inside your application.
# .env file
# AlphaVantage API Credentials
ALPHAVANTAGE_API_KEY=
ALPHAVANTAGE_API_URL=https://alphavantage.io/api/v1
As an aside, PLEASE ensure you ignore this file in your .gitignore
!
Set this in config/ColdBox.cfc
in the configure()
method:
moduleSettings.alphavantage = {
apiKey : "blablasecret",
apiURL : "my.url"
};
Each api method returns a HyperResponse
object with the following methods (not exhaustive):
response.isSuccess()
- booleanresponse.isError()
- booleanresponse.json()
- JSON deserialized to a struct or arrayresponse.getData()
- unchanged data payloadSee the Hyper docs for more info on using a HyperResponse
.
var response = getInstance( "Fundamentals@AlphaVantage" ).getCompanyOverview( "MSFT" );
Parameter | Type | Description |
---|---|---|
symbol | string | Required. Stock symbol to fetch |
var response = getInstance( "Fundamentals@AlphaVantage" ).getCompanyEarnings( "MSFT" );
Parameter | Type | Description |
---|---|---|
symbol | string | Required. Stock symbol to fetch |
$
box install alphavantage