Bancor provides public API methods which take HTTP GET requests and return JSON.
Please note that making more than 6 calls per second to the public API, or repeatedly and needlessly fetching excessive amounts of data, can result in your IP being banned.
What is the “Historical Volume” API?
The “Historical Volume” API returns historical volume for any pair of tokens indicated from the day this pair was created on the Bancor Network.
Basic URL format:
GET: https://api.bancor.network/0.1/currencies/volumeHistory?
Values you are required to pass:
- toCurrencyCode={currency_symbol}
Indicates the destination token in the pair you would like to receive volume for - fromCurrencyCode={currency_symbol}
Indicates the origin token in the pair you would like to receive volume for - timeFrame={hour, day, week, year}
Indicates the Interval & Range - Hour: returns aggregated volume per minute for any 1 hour time frame
- Day: returns aggregated volume per minute for any 1 day time frame
- Week: returns aggregated volume per hour for any 7 days time frame
- Year: returns aggregated volume per day for up to 365 days from current date
- NOTE: timeFrame data is always limited to the last 365 days for any timeFrame indication.
Optional values:
- startDate={UNIX time in milliseconds}
- endDate={UNIX time in milliseconds}
- Note -
- If you do not indicate start/end date, the API response will be for the previous timeframe (last full hour, day, week, or year)
- When selecting timeframe value, you will only be able to set start/end to that time frame restrictions.
Example: if timeframe=hour, start/end can only be within a 1-hour range.
Sample request:
Pull historical volume for the pair ETH/BNT by day for the last 7 days
https://api.bancor.network/0.1/currencies/volumeHistory?toCurrencyCode=BNT&fromCurrencyCode=ETH&timeFrame=week
Sample output:
{"data":{"data":[{"timeStamp":1540465200000,"volume":{"eth":"165","usd":"33551","eur":"29403"}},{"timeStamp":1540468800000,"volume":{"eth":"249","usd":"50665","eur":"44404"}},{"timeStamp":1540472400000,"volume":{"eth":"336","usd":"68412","eur":"59968"}},{"timeStamp":1540476000000,"volume":{"eth":"273","usd":"55496","eur":"48752"}},{"timeStamp":1540479600000,"volume":{"eth":"310","usd":"62892","eur":"55284"}},{"timeStamp":1540483200000,"volume":{"eth":"339","usd":"68809","eur":"60519"}},{"timeStamp":1540486800000,"volume":{"eth":"228","usd":"46186","eur":"40633"}},
…
…
,{"timeStamp":1541070000000,"volume":{"eth":"74","usd":"14669","eur":"12884"}}],"totalVolume":{"eth":"30321.000000000000000000","usd":"6099367.000000","eur":"5360310.000000"},"startDate":1540465200000,"endDate":1541072965138,"fromCurrencyCode":"ETH","toCurrencyCode":"BNT"}}
Important Note:
The Bancor API is currently in alpha and is likely to break or be slow to respond.
We offer several APIs for our partners, for more information please visit our API Documentation.