Bancor provides public API methods which take HTTPS 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 “Conversion Path” API?
At the heart of the Bancor Protocol is Bancor's conversion functionality. This unique feature allows you to convert any token to any token in a single and simple action.
When building a "quickConvert" transaction directly on the blockchain, you will need to pass an array of addresses that indicate the path between two defined tokens. For ease of use, the conversionPath API will allow you to check the array to use instead of identifying this from the blockchain.
Basic URL format:
(GET) https://api.bancor.network/0.1/transactions/conversionPath?{FromToken}&{ToToken}
Appended Values:
This API call requires you to pass the two tokens you would like to convert in the following way:
FromToken:
Indicate the FromToken in the following ways:
- fromCurrencyCode - Pass the code of the token in our system. Example: ETH, BNT, DAI, EOS
- fromCurrencyID - Pass the bancor identifier of the token. Example: 5c9a078447a87f2e3cf108b1
ToToken:
Indicate the ToToken in the following ways:
- toCurrencyCode - Pass the code of the token in our system. Example: ETH, BNT, DAI, EOS
- toCurrencyID - Pass the bancor identifier of the token. Example: 5c9a078447a87f2e3cf108b1
NOTE - You must use the same value format in the call. Meaning, either pass fromCurrencyId & toCurrecyId, or fromCurrencyCode & toCurrencyCode.
Sample Call:
https://api.bancor.network/0.1/transactions/conversionPath?fromCurrencyCode=BNT&toCurrencyCode=SAI
Sample Response:
{"data":["0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c","0xee01b3ab5f6728adc137be101d99c678938e6e72","0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"]}
How to use this response data?
Use the response data (array of addresses) when following the process outlined here.