The most popular .Net client library for Alpha Vantage API.
This repository is forked from https://github.com/kirlut/AlphaVantage.Net
- AlphaVantage.Net.Core - low-level client for Alpha Vantage API based on
HttpClient
- AlphaVantage.Net.Stocks - stock time series.
- AlphaVantage.Net.Forex - Forex data
- AlphaVantage.Net.Crypto - cryptocurrencies data
- AlphaVantage.Net.TechnicalIndicators - technical indicators time series.
This package allow you to request any available data from API, but you have to manually set all query parameters and retrieve information you need from the result
- Package Manager:
Install-Package AlphaVantage.Net.Core -Version 2.0.1
- .NET CLI:
dotnet add package AlphaVantage.Net.Core --version 2.0.1
using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using AlphaVantage.Net.Common;
using AlphaVantage.Net.Core.Client;
.....
public static async Task CoreDemo()
{
// use your AlphaVantage API key
string apiKey = "1";
// there's 5 more constructors available
using var client = new AlphaVantageClient(apiKey);
// query for intraday time series for Apple Inc:
var query = new Dictionary<string, string>()
{
{"symbol", "AAPL"},
{"interval", "15min"}
};
// retrieve response as pure JSON string
string stringResult = await client.RequestPureJsonAsync(ApiFunction.TIME_SERIES_INTRADAY, query);
// retrieve response as parsed JsonDocument from System.Text.Json
JsonDocument parsedResult = await client.RequestParsedJsonAsync(ApiFunction.TIME_SERIES_INTRADAY, query);
}
- Package Manager:
Install-Package AlphaVantage.Net.Stocks -Version 2.0.1
- .NET CLI:
dotnet add package AlphaVantage.Net.Stocks --version 2.0.1
using System.Collections.Generic;
using System.Threading.Tasks;
using AlphaVantage.Net.Common.Intervals;
using AlphaVantage.Net.Common.Size;
using AlphaVantage.Net.Core.Client;
using AlphaVantage.Net.Stocks;
using AlphaVantage.Net.Stocks.Client;
.....
public static async Task StocksDemo()
{
// use your AlphaVantage API key
string apiKey = "1";
// there are 5 more constructors available
using var client = new AlphaVantageClient(apiKey);
using var stocksClient = client.Stocks();
StockTimeSeries stockTs = await stocksClient.GetTimeSeriesAsync("AAPL", Interval.Daily, OutputSize.Compact, isAdjusted: true);
GlobalQuote globalQuote = await stocksClient.GetGlobalQuoteAsync("AAPL");
ICollection<SymbolSearchMatch> searchMatches = await stocksClient.SearchSymbolAsync("BA");
}
- Package Manager:
Install-Package AlphaVantage.Net.Forex -Version 2.0.1
- .NET CLI:
dotnet add package AlphaVantage.Net.Forex --version 2.0.1
using System.Threading.Tasks;
using AlphaVantage.Net.Common.Currencies;
using AlphaVantage.Net.Common.Intervals;
using AlphaVantage.Net.Common.Size;
using AlphaVantage.Net.Core.Client;
using AlphaVantage.Net.Forex;
using AlphaVantage.Net.Forex.Client;
.....
public static async Task ForexDemo()
{
// use your AlphaVantage API key
string apiKey = "1";
// there are 5 more constructors available
using var client = new AlphaVantageClient(apiKey);
using var forexClient = client.Forex();
ForexTimeSeries forexTimeSeries = await forexClient.GetTimeSeriesAsync(
PhysicalCurrency.USD,
PhysicalCurrency.ILS,
Interval.Daily,
OutputSize.Compact);
ForexExchangeRate forexExchangeRate = await forexClient.GetExchangeRateAsync(PhysicalCurrency.USD, PhysicalCurrency.ILS);
}
- Package Manager:
Install-Package AlphaVantage.Net.Crypto -Version 2.0.1
- .NET CLI:
dotnet add package AlphaVantage.Net.Crypto --version 2.0.1
using System.Threading.Tasks;
using AlphaVantage.Net.Common.Currencies;
using AlphaVantage.Net.Common.Intervals;
using AlphaVantage.Net.Core.Client;
using AlphaVantage.Net.Crypto;
using AlphaVantage.Net.Crypto.Client;
.....
public static async Task CryptoDemo()
{
// use your AlphaVantage API key
string apiKey = "1";
// there are 5 more constructors available
using var client = new AlphaVantageClient(apiKey);
using var cryptoClient = client.Crypto();
CryptoTimeSeries cryptoTimeSeries =
await cryptoClient.GetTimeSeriesAsync(DigitalCurrency.BTC, PhysicalCurrency.ILS, Interval.Weekly);
CryptoRating cryptoRating = await cryptoClient.GetCryptoRatingAsync(DigitalCurrency.BTC);
CryptoExchangeRate exchangeRate =
await cryptoClient.GetExchangeRateAsync(DigitalCurrency.BTC, PhysicalCurrency.ILS);
}
Since API endpoints from this section have many different additional parameters, you still need to check Alpha Vantage documentation in order to use it.
- Package Manager:
Install-Package AlphaVantage.Net.TechnicalIndicators -Version 2.0.1
- .NET CLI:
dotnet add package AlphaVantage.Net.TechnicalIndicators --version 2.0.1
using System.Collections.Generic;
using System.Threading.Tasks;
using AlphaVantage.Net.Common.Intervals;
using AlphaVantage.Net.Core.Client;
using AlphaVantage.Net.TechnicalIndicators;
using AlphaVantage.Net.TechnicalIndicators.Client;
.....
public static async Task TechIndicatorsDemo()
{
// use your AlphaVantage API key
string apiKey = "1";
// there are 5 more constructors available
using var client = new AlphaVantageClient(apiKey);
var symbol = "IBM";
var indicatorType = TechIndicatorType.SMA;
var query = new Dictionary<string, string>()
{
{"time_period", "20"},
{"series_type", "close"}
};
TechIndicatorTimeSeries result = await client.GetTechIndicatorTimeSeriesAsync(symbol, indicatorType, Interval.Min15, query);
}