Skip to content

Endpoints and Usage

Shravan Jambukesan edited this page Mar 3, 2021 · 4 revisions

Background

TwelveDataSharp is currently aimed at supporting Twelve Data's high demand time series and technical indicator endpoints, with new endpoints being added over time. In addition to fetching data from supported endpoints, TwelveDataSharp also features mapping logic to convert response data into more applicable data formats (i.e converting a stock price that was originally a string into a double).

Response Codes and Status Messages

All TwelveDataSharp methods return response codes and status messages to indicate if data was fetched successfully.

ResponseStatus

Field: Enums.TwelveDataClientResponseStatus ResponseStatus

Enums.TwelveDataClientResponseStatus.Ok - Response from Twelve Data API was successful

Enums.TwelveDataClientResponseStatus.TwelveDataApiError - An API error from Twelve Data, relating to an invalid symbol, bad API key, or reaching your rate limit

Enums.TwelveDataClientResponseStatus.TwelveDataSharpError - An internal error within the TwelveDataSharp library, with the exact exception captured in the ResponseMessage field.

ResponseMessage

Field: string ResponseMessage

"RESPONSE_OK" - Response from Twelve Data API was successful

"Invalid symbol or API key" - An API error occurred, likely related to an invalid symbol or API key

Exception stack trace - An exception stack trace associated with a TwelveDataSharp internal error

Real-time Price

Task<TwelveDataPrice> GetRealTimePriceAsync(string symbol) 

API reference: https://twelvedata.com/docs#real-time-price

Input

symbol - A valid symbol for an NYSE or NASDAQ listed equity (ex: AAPL, TSLA, FB, GME)

Output

TwelveDataPrice

Fields:

double Price - Current price of the specified security

Usage

var response = await twelveDataClient.GetRealTimePriceAsync("AAPL");

Quotes

Task<TwelveDataQuote> GetQuoteAsync(string symbol, string interval = "1min")

API reference: https://twelvedata.com/docs#quote

Input

symbol - A valid symbol for an NYSE or NASDAQ listed equity (ex: AAPL, TSLA, FB)

interval - Default interval of 1min, can be set to 1min, 5min, 15min, 30min, 45min, 1h, 2h, 4h, 1day, 1week, 1month

Output

TwelveDataQuote

Fields:

string Symbol - The symbol of the security

string Name - The name of the company or fund

string Exchange - The name of the listing exchange

string Currency - Currency of the quoted prices

DateTime Datetime - Timestamp of the quote

double Open - Opening price for the specified interval

double Close - Closing price for the specified interval

double High - High price for the specified interval

double Low - Low price for the specified interval

long Volume - Trading volume for the specified interval

double PreviousClose - Closing price from previous specified interval

double Change - Amount change in monetary value of the price from the previous interval

double PercentChange - Percentage change in the monetary value of the price from the previous interval

double FiftyTwoWeekHigh - Highest quoted price from the last 52 weeks of trading

double FiftyTwoWeekLow - Lowest quoted price from the last 52 weeks of trading

double FiftyTwoWeekHighChange - Change in highest price from the last 52 weeks of trading

double FiftyTwoWeekLowChange - Change in the lowest price from the last 52 weeks of trading

double FiftyTwoWeekHighChangePercent - Percent change in the highest price from the last 52 weeks of trading

double FiftyTwoWeekLowChangePercent - Percent change in the lowest price from the last 52 weeks of trading

string FiftyTwoWeekRange - Range of consisting of the lowest price and highest price from the last 52 weeks of trading

Usage

var response = await twelveDataClient.GetQuoteAsync("TSLA");

Time Series

Task<TwelveDataTimeSeries> GetTimeSeriesAsync(string symbol, string interval = "1min")

API reference: https://twelvedata.com/docs#stocks

Input

symbol - A valid symbol for an NYSE or NASDAQ listed equity (ex: AAPL, TSLA, FB)

interval - Default interval of 1min, can be set to 1min, 5min, 15min, 30min, 45min, 1h, 2h, 4h, 1day, 1week, 1month

Output

TwelveDataTimeSeries

Fields:

string Symbol - The symbol of the security

string Name - The name of the company or fund

string Exchange - The name of the listing exchange

string Currency - Currency of the quoted prices

string ExchangeTimezone - Time zone of the listing exchange

string Type - Type of the equity (stock, ETF)

List<TimeSeriesValues> - Time series data for the specified interval

TimeSeriesValues

Fields:

double Open - Opening price for the interval

double Close - Closing price for the interval

double High - High price of the interval

double Low - Low price of the interval

long Volume - Trading volume during the interval

Usage

var response = await twelveDataClient.GetTimeSeriesAsync("GME");
Clone this wiki locally