https://github.com/basilzuberi/alpha_vantage_package
A package to use AlphaVantage stock API.
https://github.com/basilzuberi/alpha_vantage_package
flutter flutter-package flutter-packages pub
Last synced: 4 months ago
JSON representation
A package to use AlphaVantage stock API.
- Host: GitHub
- URL: https://github.com/basilzuberi/alpha_vantage_package
- Owner: basilzuberi
- License: mit
- Created: 2020-02-25T00:44:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-21T16:35:26.000Z (over 4 years ago)
- Last Synced: 2025-10-23T00:48:04.708Z (8 months ago)
- Topics: flutter, flutter-package, flutter-packages, pub
- Language: Dart
- Homepage:
- Size: 10.7 KB
- Stars: 3
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# alpha_vantage_package
A new Flutter package for using alpha vantage api.
You will need your own API key from https://www.alphavantage.co/ (it's free) to use stocks other than MSFT
This was refactored and updated from the original source: https://github.com/jcmelend/flutter_alpha_vantage_api so credits to the maker.
For more information about how the JSON is layed out, visit https://www.alphavantage.co/documentation/
## Getting Started
For help getting started with Flutter, view our online [documentation](https://flutter.io/).
For help on editing package code, view the [documentation](https://flutter.io/developing-packages/).
## Usage
Add the following import statement where you need to use this package libraries:
import 'package:alpha_vantage_package/alpha_vantage_package.dart';
There are four libraries to use to call Alpha Vantage rest api:
TimeSeries.dart, SectorPerformances.dart, ForeignExchange.dart, CryptoCurrencies.dart,
and TechnicalIndicators.dart.
Example:
```Dart
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_alpha_vantage_package/alpha_vantage_package.dart';
void main() async {
test('Intraday', () async {
final timeSeries = new TimeSeries("YourAlphaVantageAPIKey");
//get the hourly time series for Microsoft with to-the-minute updates. You can change this.
JSONObject json = await timeSeries.getIntraday("MSFT");
var data = json.getJSONMap()["Time Series (1min)"];
//convert to map to get specific data like the amount during lcose
var data2 = Map.from(data);
data2.forEach((k,v) => print(v["4. close"]));
//Use get method to search entire json for key for stock
expect(json.get("2. Symbol"), "MSFT");
// Use map to find stock symbol
expect(json.getJSONMap()["Meta Data"]["2. Symbol"], "MSFT");
print(json.getJSONMap());
});
test('Intraday', () async {
final technicalIndicator = new TechnicalIndicators("YourAlphaVantageAPIKey");
//get SMA for microsoft
JSONObject json = await technicalIndicator.getSMA("MSFT");
// Use get method to search entire json for key for stock
expect(json.get("1: Symbol"), "MSFT");
// Use map to find stock symbol
expect(json.getJSONMap()["Meta Data"]["1: Symbol"], "MSFT");
print(json.getJSONMap());
});
}
```