https://github.com/michaelborn/alphavantage
CFML wrapper for the AlphaVantage API. Built with ColdBox and Hyper.
https://github.com/michaelborn/alphavantage
Last synced: 4 months ago
JSON representation
CFML wrapper for the AlphaVantage API. Built with ColdBox and Hyper.
- Host: GitHub
- URL: https://github.com/michaelborn/alphavantage
- Owner: michaelborn
- Created: 2021-07-21T16:43:42.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-21T17:55:05.000Z (almost 5 years ago)
- Last Synced: 2025-11-30T22:51:04.480Z (7 months ago)
- Language: ColdFusion
- Size: 60.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AlphaVantage CFML API wrapper
Wraps the [AlphaVantage](https://alphavantage.io) API for easy CFML usage using the [Hyper](https://github.com/elpete/hyper) ColdBox module.

## Getting Started
1. Install this module - `box install AlphaVantage`
2. Configure AlphaVantage API secrets using `.env`
3. OR configure AlphaVantage API via ColdBox `moduleSettings`
## Environment Variable Configuration
AlphaVantage can mainly be configured using environment variables:
* `ALPHAVANTAGE_API_KEY` - Required API key for authenticating with the AlphaVantage API
* `FINNUHB_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.
```bash
# .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`!
## ColdBox Module Configuration via ModuleSettings
Set this in `config/ColdBox.cfc` in the `configure()` method:
```js
moduleSettings.alphavantage = {
apiKey : "blablasecret",
apiURL : "my.url"
};
```
## API Reference
Each api method returns a [`HyperResponse` object](https://github.com/coldbox-modules/hyper#hyperresponse) with the following methods (not exhaustive):
* `response.isSuccess()` - boolean
* `response.isError()` - boolean
* `response.json()` - JSON deserialized to a struct or array
* `response.getData()` - unchanged data payload
See the [Hyper docs](https://github.com/coldbox-modules/hyper#hyperresponse) for more info on using a `HyperResponse`.
### Fundamentals
#### getCompanyOverview
```js
var response = getInstance( "Fundamentals@AlphaVantage" ).getCompanyOverview( "MSFT" );
```
| Parameter | Type | Description
| --------- | -------- | --------------------------------------- |
| `symbol` | `string` | **Required**. Stock symbol to fetch |
#### GetCompanyEarnings
```js
var response = getInstance( "Fundamentals@AlphaVantage" ).getCompanyEarnings( "MSFT" );
```
| Parameter | Type | Description
| --------- | -------- | --------------------------------------- |
| `symbol` | `string` | **Required**. Stock symbol to fetch |