Indices-API API

Powered by 10+ exchange rate data sources for indices prices, the Indices-API API is capable of delivering real-time precious indices data. The API comes with multiple endpoints, each serving a different use case. Endpoint functionalities include getting the latest indices rates data for all or a specific set of indices, converting amounts from one currency to another, retrieving Time-Series data for one or multiple currencies and querying the API for daily fluctuation data.

Throughout this documentation you will learn about API structure, methods, potential errors and code examples. In case any question was left unanswered, please make sure to contact us and our team will be happy to help out.

Quickstart Tool

No time for long documentation articles? We've got you covered - in the Dashboard section of your control panel you will be able to access our Quickstart tool and test all API endpoints at the click of a button.

Go to Quickstart Tool

Getting Started

Definitions

Definition Description
API Key A unique key assigned to each API account used to authenticate with the API.
Symbol Refers to the three-letter currency code or index code of a given currency.
Base Currency The currency to which exchange rates are relative to. (If 1 USD = X EUR, USD is the base currency)
Target Currency The currency an amount is converted to. (If 1 USD = X EUR, EUR is the target currency)
Base URL Refers to URL which all API request endpoints and URLs are based on.

API Key

Your API Key is the unique key that is passed into the API base URL's access_key parameter in order to authenticate with the Indices-API API.

Base URL:

https://indices-api.com/api/

Append your API Key: Here is how to authenticate with the Indices-API API:

https://indices-api.com/api/latest
? access_key = API_KEY
? symbols = NYA,EGX-30,GSPC

API Response

Exchange rates delivered by the Indices-API API are by default relative to USD. All data is returned in standard JSON format and can be parsed easily using any programming language.

When fetching indices rates with any currency selected as the base currency (utilizing the 'base' parameter, defaulting to USD if not specified), it is necessary to apply 1/value to the API response.

Example Response: For instance, to ascertain the NYSE Composite rate in USD from the API response value, execute 1/0.000051351995333131, yielding 19473.43 USD. Furthermore, when USD serves as the base, the API response will include the USD Price without requiring additional conversion. This can be identified, for example, as USDNYA. (ONLY APPLIES FOR LATEST ENDPOINT).

{
"success": true,
"timestamp": 1728588840,
"base": "USD",
"date": "2024-10-10",
"rates": {
"EGX-30": 0.0015791959638306,
"EGX-30": 0.0001732354668436,
"GSPC": 0.000051351995333131,
"USDEGX-30": 633.2336346493283,
"USDGSPC": 5772.489999999927,
"USDNYA": 19473.43999999987,
[...]
}
}      

As illustrated above, the API's response - when queried for real-time exchange rates - always contains a timestamp object containing a standard UNIX time stamp indicating the time the given exchange rate data was collected, a base object containing the three-letter currency code or index code of the base currency, and a rates object containing the actual exchange rate data.

Further below, in the Endpoints section, the API response structure will be discussed in detail.

Available Endpoints

The Indices-API API comes with X API endpoints, each providing a different functionality. Please note that depending on your subscription plan, certain API endpoints may or may not be available.

  • Latest rates endpoint: Returns real-time indices rates data for all available or a specific set of indices (The number of symbols per API request depends on the acquired plan).
  • Convert endpoint: Allows for conversion of any amount from one currency to another.
  • Historical rates endpoint: Returns historical indices rates data for a specific set of indices. (The number of symbols per API request depends on the acquired plan).
  • Time-Series data endpoint: Returns daily historical indices rates data between two specified dates for a index. (The date limits per API request depends on the acquired plan).
  • Fluctuation data endpoint: Returns fluctuation data between two specified dates for all available or a specific set of indices. (The date limits per API request depends on the acquired plan).
  • Open/High/Low/Close (OHLC): Allows you to query the API to get the open, high, low, and close price.

SSL Connection

All paid subscription plans available on Indices-API come with 256-bit SSL encryption. To connect to the API via SSL, simply use the https protocol instead of standard http.

JSONP Callbacks

The Indices-API API comes with support for JSONP Callbacks. This feature enables you to specify a function name, pass it into the API's callback GET parameter and cause the API to return your requested API response wrapped inside that function.

Example Call:

https://indices-api.com/api/latest
? access_key = API_KEY
& callback = MY_FUNCTION

In the example call above we are requesting the API to use the callback name MY_FUNCTION.

Example Response: Your API response will be wrapped inside your preferred callback function.

({
"success": true,
"timestamp": 1519296206,
"base": "USD",
"date": "2024-10-10",
"rates": {
"EGX-30": 0.0015791959638306,
"GSPC": 0.0001732354668436,
"NYA": 0.000051351995333131,
"USDEGX-30": 633.2336346493283,
"USDGSPC": 5772.489999999927,
"USDNYA": 19473.43999999987,
[...]
}
})  

Access-Control / CORS

Indices-API also supports Cross-Origin Resource Sharing (CORS) and Access-Control Headers. This will enable you to use the Indices-API API via Cross-Origin HTTP Requests.

Learn more about CORS »

HTTP ETags

HTTP ETags are a way of reducing the load on your back-end by requesting new Indices-API data only if rates have changed since the last API response.

What are ETags?

An ETag is a part of the HTTP protocol and one of the several mechanisms used for cache validation. The ETag is an identifier assigned to a data resource in a server, and if that resource is ever updated at the server, the ETag is changed.

Whenever a resource is requested (via its URL), the data and ETag are retrieved and stored in the Web cache, and the ETag is sent along with subsequent requests. If the ETag at the server has not changed, a "Not Modified" message is returned, and the cached data is used. (Definition by pcmag.com)

ETags - Quickstart Guide

Step 1

Your initial request to the Indices-API API will create an ETag object containing a unique ETag key and a Date object containing the exact date and time at which the data was last modified. This data must be cached along with the entire API response in order for ETags to work.

ETag: "202567a75aef2e66a3ebf2366bff048f"  
Date: Mon, 12 Apr 2018 11:30:01 GMT
Step 2

Once you make another API request, make sure to include the If-None-Match HTTP header and set it to your previously generated ETag value. Moreover, you will need to add the If-Modified-Since HTTP header to your API request containing the date and time data from your last request.

If-None-Match: "1872ade88f3013edeb33decd74a4f947"  
If-Modified-Since: Fri, 10 Apr 2015 12:10:04 GMT
Step 3

Depending on whether or not your result set has updated since your last API request, the API will return either:

  • the results from your initial API request along with a 304 – Not Modified HTTP header indicating that no change has occured. In this case, the size of the API response will be as small as 0.2kb;
  • or new results with an entirely new set of ETag and Date objects indicating that new data has been accessed. In this case, the size of your API response will be normal.

Potential Errors

Whenever a requested resource is not available or an API call fails for another reason, a JSON error is returned. Errors always come with an error code and a description.

Example Error: The following error is returned if your monthly API request volume has been exceeded.

{
"success": false,
"error": {
"code": 104,
"info": "Your monthly API request volume has been reached. Please upgrade your plan."    
}
}

Other Errors:

Error Code Description
404 The requested resource does not exist.
101 No API Key was specified or an invalid API Key was specified.
103 The requested API endpoint does not exist.
104 The maximum allowed amount of monthly API requests has been reached.
105 The current subscription plan does not support this API endpoint.
106 The current request did not return any results.
102 The account this API request is coming from is inactive.
201 An invalid base currency has been entered.
202 One or more invalid symbols have been specified.
301 No date has been specified. [historical]
302 An invalid date has been specified. [historical, convert]
403 No or an invalid amount has been specified. [convert]
431 The maximum allowed amount of symbols has been exceeded.
501 No or an invalid timeframe has been specified. [timeseries]
502 No or an invalid "start_date" has been specified. [timeseries, fluctuation]
503 No or an invalid "end_date" has been specified. [timeseries, fluctuation]
504 An invalid timeframe has been specified. [timeseries, fluctuation]
505 The specified timeframe is too long, exceeding 30 days. [timeseries, fluctuation]

Endpoints

Supported Symbols Endpoint

The Indices-API API comes with a constantly updated endpoint returning all available currencies. To access this list, make a request to the API's symbols endpoint.

API Request:

https://indices-api.com/api/symbols
? access_key = API_KEY

Request Parameters:

Parameter Description
access_key [Required] Your API Key.

API Response:

{
"success": true,
"symbols": {
"000001": "SSE Composite",
"AORD": "ALL ORDINARIES",
"AXJO": "S&P/ASX 200",
"BFX": "BEL 20",
"BSESN": "BSE SENSEX",
"BVSP": "IBOVESPA",
"BUK100P": "Cboe UK 100",
[...] 
}
}     

Response Objects:

Response Object Description
success Returns true or false depending on whether or not your API request has succeeded.
symbols Returns all supported currencies with their respective three-letter currency codes or index codes and names.

Latest Rates Endpoint

Depending on your subscription plan, the API's latest endpoint will return real-time exchange rate data updated every 60 minutes, every 10 minutes or every 60 seconds.

API Request:

https://indices-api.com/api/latest
? access_key = API_KEY
& base = USD
& symbols = NYA,EGX-30,GSPC

Request Parameters:

Parameter Description
access_key [required] Your API Key.
base [optional] Enter the three-letter currency code or index code of your preferred base currency. Default USD.
symbols [required] Enter a list of comma-separated currency codes or indices codes to limit output codes. (The number of symbols per API request depends on the acquired plan).

API Response:

{
        "success": true,
        "timestamp": 1728588840,
        "base": "USD",
        "date": "2024-10-10",
        "rates": {
        "EGX-30": 0.0015791959638306,
        "GSPC":  0.0001732354668436,
        "NYA":  0.000051351995333131,
        "USDEGX-30": 633.2336346493283,
        "USDGSPC":  5772.489999999927,
        "USDNYA":  19473.43999999987,

        },
        }      

Response Objects:

Response Object Description
success Returns true or false depending on whether or not your API request has succeeded.
timestamp Returns the exact date and time (UNIX time stamp) the given rates were collected.
base Returns the three-letter currency code or indices code of the base currency used for this request.
rates Returns indices rates data for the currencies you have requested.

Historical Rates Endpoint

Historical rates are available for most currencies October 2024. You can query the Indices-API API for historical rates by appending a date (format YYYY-MM-DD) to the base URL.

API Request:

https://indices-api.com/api/2024-10-09
? access_key = API_KEY
& base = USD
& symbols = NYA

Request Parameters:

Parameter Description
YYYY-MM-DD [required] A date in the past for which historical rates are requested.
access_key [required] Your API Key.
base [optional] Enter the three-letter currency code or index code of your preferred base currency. Default USD.
symbols [required] Enter a list of comma-separated currency codes or indices codes to limit output codes. (The number of symbols per API request depends on the acquired plan).

API Response:

{
"success": true,
"historical": true,
"date": "2024-10-09",
"base": "USD",
"rates": {
"NYA": 0.00005115851003909,
},
}

Response Objects:

Response Object Description
success Returns true or false depending on whether or not your API request has succeeded.
historical Returns true if a request for historical exchange rates was made.
date Returns the date for which historical rates were requested.
timestamp Returns the exact date and time (UNIX time stamp) the given rates were collected.
base Returns the three-letter currency code or indices code of the base currency used for this request.
rates Returns indices rates data for the currencies you have requested.

Specify Symbols

To reduce bandwidth you can limit the number of output currencies to a specific set of your choice on most API endpoints. To do so, simply append the Indices-API API's symbols parameter to your API request and set it to one or more comma-separated currency codes or index codes.

Example:

https://indices-api.com/api/latest
? access_key = API_KEY
& symbols = NYA,GSPC,EGX-30

Changing base currency

Provided changing base currency is supported on your subscription plan, you can change the currency to which your output index rates are relative to by appending the base parameter to your API request URL and setting it to the three-letter code of your preferred base currency.

Example:

https://indices-api.com/api/latest
? access_key = API_KEY
& base = EUR

Convert Endpoint

The Indices-API API comes with a separate currency conversion endpoint, which can be used to convert any amount from one currency to another. In order to convert currencies, please use the API's convert endpoint, append the from and to parameters and set them to your preferred base and target currency codes or index codes.

It is also possible to convert currencies using historical indices rates data. To do this, please also use the API's date parameter and set it to your preferred date. (format YYYY-MM-DD)

API Request:

https://indices-api.com/api/convert
? access_key = API_KEY
& from = GBP
& to = JPY
& amount = 25

Request Parameters:

Parameter Description
access_key [required] Your API Key.
from [required] The three-letter currency code or index code of the symbol you would like to convert from.
to [required] The three-letter currency code or index code of the currency you would like to convert to.
amount [required] The amount to be converted.
date [optional] Specify a date (format YYYY-MM-DD) to use historical rates for this conversion.

API Response:

{
"success": true,
"query": {
"from": "GBP",
"to": "JPY",
"amount": 25
},
"info": {
"timestamp": 1519328414,
"rate": 148.972231
},
"historical": ""
"date": "2018-02-22"
"result": 3724.305775
}

Response Objects:

Response Object Description
success Returns true or false depending on whether or not your API request has succeeded.
query > from Returns the three-letter currency code or indices code of the symbol converted from.
query > to Returns the three-letter currency code or indices code of the symbol converted to.
query > to Returns the amount that is converted.
info > timestamp Returns the exact date and time (UNIX time stamp) the given exchange rate was collected.
info > rate Returns the exchange rate used for your conversion.
historical Returns true if historical rates are used for this conversion.
date Returns the date (format YYYY-MM-DD) the given exchange rate data was collected.
result Returns your conversion result.

Time-Series Endpoint

Indices-API timeseries endpoint lets you query the API for daily historical rates between two dates of your choice. (The date limits per API request depends on the acquired plan).

You can not use the current date on the parameter "end_date". We recommend using a day prior to the current date in order to get a successful response. To get the last price you will have to use the latest endpoint.

API Request:

https://indices-api.com/api/timeseries
? access_key = API_KEY
& start_date = 2024-10-04
& end_date = 2024-10-09
& symbols = NYA
& order = desc

Request Parameters:

Parameter Description
access_key [required] Your API Key.
start_date [required] The start date of your preferred timeframe. (The date limits per API request depends on the acquired plan).
end_date [required] The end date of your preferred timeframe. (The date limits per API request depends on the acquired plan).
base [optional] Enter the three-letter currency code or index code of your preferred base currency. Default USD.
symbols [required] Enter one currency or indices codes to limit the output.
order [optional] Enter the sort order of the results. Supported values: asc (ascending), desc (descending). Default is desc.

API Response:

{
"success": true,
"timeseries": true,
"start_date": "2024-10-04",
"end_date": "2024-10-09",
"base": "USD",
"rates": {
"2024-10-04":{
"NYA": 0.000051579147169749,
"USD": 1
},
"2024-10-05": {
"NYA": 0.000051180530107459,
"USD": 1
},
"2024-10-06": {
"NYA": 0.000051180530107459,
"USD": 1
},
"2024-10-07": {
"NYA": 0.000051180530107459,
"USD": 1
},
"2024-10-08": {
"NYA": 0.00005146071231918,
"USD": 1
"2024-10-09": {
"NYA":  0.000051453483735297,
},
}

Response Objects:

>
Response Object Description
success Returns true or false depending on whether or not your API request has succeeded.
timeseries Returns true if a request to the timeseries endpoint is made.
start_date The start date of your time frame.
end_date The end date of your time frame.
base Returns the three-letter currency code or indices code of the base currency used for this request.
rates Returns indices rates data for the currencies you have requested.

Fluctuation Endpoint

Using the Indices-API API's fluctuation fluctuation endpoint you will be able to retrieve information about how currencies fluctuate on a day-to-day basis (The date limits per API request depends on the acquired plan). To use this feature, simply append a start_date and end_date and choose the symbol you would like to query the API for.

API Request:

https://indices-api.com/api/fluctuation
? access_key = API_KEY
& start_date = 2024-10-04
& end_date = 2024-10-09
& symbols = NYA

Request Parameters:

Parameter Description
access_key [required] Your API Key.
start_date [required] The start date of your preferred timeframe. (The date limits per API request depends on the acquired plan).
end_date [required] The end date of your preferred timeframe. (The date limits per API request depends on the acquired plan).
base [optional] Enter the three-letter currency code or index code of your preferred base currency. Default USD.
symbols [required] Enter a list of comma-separated currency codes or indices codes to limit output symbols. (1 symbol per API request).

API Response:

{
"success":true,
"fluctuation":true,
"start_date":"2024-10-04",
"end_date":"2024-10-08",
"base":"EUR",
"rates":{
"USD":{
"start_rate":0.000051579147169749,
"end_rate":0.000051453483735297,
"change":1.25663434451997587,
"change_pct":0.24363224548563062
}

Response Objects:

Response Object Description
success Returns true or false depending on whether or not your API request has succeeded.
fluctuation Returns true if a request to the fluctuation endpoint is made.
start_date The start date of your time frame.
end_date The end date of your time frame.
base Returns the three-letter currency code or indices code of the base currency used for this request.
rates Returns indices rates data for the currencies you have requested.
rates > start_rate Returns the exchange collected on your start date.
rates > end_rate Returns the exchange collected on your end date.
rates > change Returns the change (decimal number) of the given currency rate between your start and end date.
rates > change Returns the percentage change of the given currency rate between your start and end date.

Open/High/Low/Close (OHLC) Price Endpoint

Indices-API open-high-low-close/YYYY-MM-DD endpoint allows you to query the API to get the open, high, low, and close price.

Note: The open and close values are based on the start and end of the UTC day, not on traditional trading hours. If you're querying data for the current day, keep in mind that the high and close prices may change as the day progresses.

This endpoint has a limitation of one symbol per request.

API Request:

https://indices-api.com/api/open-high-low-close/YYYY-MM-DD
    ? access_key = API_KEY
    & base = USD
    & symbols = NYA

Request Parameters:

Parameter Description
YYYY-MM-DD [required] A date in the past or the current date.
access_key [required] Your API Key.
base [required] Enter an index symbol or currency.
symbols [required] Enter one index code or currency to limit the output.

API Response:

{
"success": true,
"timestamp": 1653931700,
"date": "2024-10-09",
"base": "NYA",
"symbol": "USD",
"rates": {
"open": 0.000051453483735297,
"high": 0.000051472711484643,
"low": 0.00005115851003909,
"close": 0.00005115851003909,
}

Response Objects:

Response Object Description
success Returns true or false depending on whether or not your API request has succeeded.
date Returns the date for the open, high, low, and close price.
base Returns the symbol as base used for this request.
symbol Returns the symbol used for this request.
rates Returns the open, high, low, and close price for the requested symbol.

Sample Code

PHP (cURL)

Real-time rates: Find below a simple PHP example for getting indices rates data via the Indices-API API's latest endpoint.

// set API Endpoint and API key 
$endpoint = 'latest';
$access_key = 'API_KEY';

// Initialize CURL:
$ch = curl_init('https://indices-api.com/api/'.$endpoint.'?access_key='.$access_key.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Store the data:
$json = curl_exec($ch);
curl_close($ch);

// Decode JSON response:
$exchangeRates = json_decode($json, true);

// Access the exchange rate values, e.g. NYA:
echo $exchangeRates['rates']['NYA'];

Convert currencies: Here is how to convert currencies using PHP cURL.

// set API Endpoint, access key, required parameters
$endpoint = 'convert';
$access_key = 'API_KEY';

$from = 'USD';
$to = 'EUR';
$amount = 10;

// initialize CURL:
$ch = curl_init('https://indices-api.com/api/'.$endpoint.'?access_key='.$access_key.'&from='.$from.'&to='.$to.'&amount='.$amount.'');   
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// get the JSON data:
$json = curl_exec($ch);
curl_close($ch);

// Decode JSON response:
$conversionResult = json_decode($json, true);

// access the conversion result
echo $conversionResult['result'];

Python (using Request module)


    import requests

    base_currency = 'USD'
    symbol = 'NYA' 
    endpoint = 'latest'
    access_key = 'API_KEY'

    resp = requests.get(
        'https://indices-api.com/api/'+endpoint+'?access_key='+access_key+'&base='+base_currency+'&symbols='+symbol)
    if resp.status_code != 200:
        # This means something went wrong.
        raise ApiError('GET /'+endpoint+'/ {}'.format(resp.status_code))
    print(resp.json())
    

JavaScript (jQuery.ajax)

Real-time rates: Find below a simple jQuery.ajax example for getting exchange rate data via the Indices-API API's latest endpoint.

// set endpoint and your access key
endpoint = 'latest'
access_key = 'API_KEY';

// get the most recent exchange rates via the "latest" endpoint:
$.ajax({
url: 'https://indices-api.com/api/' + endpoint + '?access_key=' + access_key,   
dataType: 'jsonp',
success: function(json) {

// exchange rata data is stored in json.rates
alert(json.rates.NYA);

// base currency is stored in json.base
alert(json.base);

// timestamp can be accessed in json.timestamp
alert(json.timestamp);

}
});

Convert currencies: Here is how to convert currencies using jQuery.ajax.

// set endpoint and your API key
endpoint = 'convert';
access_key = 'API_KEY';

// define from currency, to currency, and amount
from = 'EUR';
to = 'GBP';
amount = '10';

// execute the conversion using the "convert" endpoint:
$.ajax({
url: 'https://indices-api.com/api/' + endpoint + '?access_key=' + access_key +'&from=' + from + '&to=' + to + '&amount=' + amount,   
dataType: 'jsonp',
success: function(json) {

// access the conversion result in json.result
alert(json.result);

}
});