# Binance Conversion API - solution to import conversions programatically

**URL:** <https://discuss.koinly.io/t/binance-conversion-api-solution-to-import-conversions-programatically/9200>\
**Category:** Site Feedback\
**Created:** [December 7, 2021, 12:41pm UTC](https://discuss.koinly.io/t/binance-conversion-api-solution-to-import-conversions-programatically/9200 "2021-12-07T12:41:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![noccer](https://yyz2.discourse-cdn.com/flex052/user_avatar/discuss.koinly.io/noccer/32/5637_2.png) [@noccer](https://discuss.koinly.io/u/noccer)\
**Post date:** [December 7, 2021, 12:41pm UTC](https://discuss.koinly.io/t/binance-conversion-api-solution-to-import-conversions-programatically/9200/1 "2021-12-07T12:41:13Z")

</div>

Relating to this issue:

> [@Binance "Convert" transactions unreachable by API](https://discuss.koinly.io/t/binance-convert-transactions-unreachable-by-api/2132):
>
> The auto-sync feature doesn’t pull any of the trades done through Binance’s Convert Portal. It’s impossible to find a transaction hash for these conversions, just to make it worse! I can see exactly the convert history, ie: 76.57680988 UDSC → 1.34361074 BNB.

I managed to programatically import my conversion records by watching the network tab in Chrome then copying the data payload returned. I then saved this as json on my machine. I imported it using Typescript, then did a little converting the data into Koinly format. I then converted the newly formatted data to CSV and then uploaded my CSV successfully to Koinly without any issues.

The api endpoint with current query strings is:  
[https://www.binance.com/bapi/margin/v1/private/new-otc/query-trade-history?startTime=1636203600000&endTime=1638881999999&page=1&rows=20](https://www.binance.com/bapi/margin/v1/private/new-otc/query-trade-history?startTime=1636203600000&endTime=1638881999999&page=1&rows=20)

I am not sure if the API key would work with this network call though, I couldnt see my api key at all in the headers. It seemed to have its own token in the headers under the csrftoken header which I havent bothered to work out where it comes from. Who knows, maybe there’s an endpoint that would do a token swap of your API key to obtain your csrftoken. Then Koinly could maybe do this integration automatically for people

I’m happy to share my typescript converter on github, you can find me [at]noccer on github or twitter, or just reply here with your interest.

Note: some web development experience/software will be required to run my converter

- chrome devtools network tab
- Postman if you want to extend range of conversions queried
- NodeJS with npm installed

My background:

- Frontend dev, specialising in api integrations. the Chrome Devtools Network tab helps pay my bills 😎

---

<div class="post-metadata">

**Author:** ![noccer](https://yyz2.discourse-cdn.com/flex052/user_avatar/discuss.koinly.io/noccer/32/5637_2.png) [@noccer](https://discuss.koinly.io/u/noccer)\
**Post date:** [January 13, 2022, 11:21am UTC](https://discuss.koinly.io/t/binance-conversion-api-solution-to-import-conversions-programatically/9200/2 "2022-01-13T11:21:13Z")

</div>

I’ve published the tool to GitHub if anyone wants it, as well as some instructions.

Hope it helps someone some day.

> **[GitHub - noccer/binancetokoinly: converts binance conversion data to csv format for...](https://github.com/noccer/binancetokoinly)**
>
> converts binance conversion data to csv format for importing into Koinly
