# create a program that automatically scans cryptocurrency price differences between CEX and DEX exchanges

**URL:** <https://discourse.nodered.org/t/create-a-program-that-automatically-scans-cryptocurrency-price-differences-between-cex-and-dex-exchanges/89310>\
**Category:** General\
**Created:** [6 July 2024 05:42 UTC](https://discourse.nodered.org/t/create-a-program-that-automatically-scans-cryptocurrency-price-differences-between-cex-and-dex-exchanges/89310 "2024-07-06T05:42:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henrybluesky](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henrybluesky/32/92613_2.png) [@Henrybluesky](https://discourse.nodered.org/u/Henrybluesky)\
**Post date:** [6 July 2024 05:42 UTC](https://discourse.nodered.org/t/create-a-program-that-automatically-scans-cryptocurrency-price-differences-between-cex-and-dex-exchanges/89310/1 "2024-07-06T05:42:59Z")

</div>

I'm struggling and having trouble creating a program that automatically scans for price differences between CEX exchanges (such as: Binance, Bybit, Okx, Bitget.. etc.) and DEX exchanges ( such as: Uniswap, Sushiswap, Pancakeswap, 1inch.v..v..), if anyone has any suggestions for this program, please comment, thank you very much!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [6 July 2024 09:00 UTC](https://discourse.nodered.org/t/create-a-program-that-automatically-scans-cryptocurrency-price-differences-between-cex-and-dex-exchanges/89310/2 "2024-07-06T09:00:33Z")

</div>

There was a forum member working on something similar here [Cryptocurrency Exchange Array (searching, tabling, etc)](https://discourse.nodered.org/t/cryptocurrency-exchange-array-searching-tabling-etc/55579) , Their flow might give you some ideas.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [6 July 2024 11:34 UTC](https://discourse.nodered.org/t/create-a-program-that-automatically-scans-cryptocurrency-price-differences-between-cex-and-dex-exchanges/89310/3 "2024-07-06T11:34:19Z")

</div>

Data = money, blockchain has lots of data, so this is mostly locked behind api's for which needs to be paid.

Coingecko had an api that did not require an api key (up some months ago) - this api still works, their new api is free but requires registration. Their previous api still works, but I don't know for how long.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/1/d1be5d7ffc3e01f7a8b9ab0680f37c31cbf2fee0.png)

You can use a flow like this:

```auto
[{"id":"ce91e76dc754682f","type":"inject","z":"51924a530596d728","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":295,"y":2160,"wires":[["9c9a155a38c6ef3f"]],"l":false},{"id":"6de7f5c4bf8b8dfb","type":"debug","z":"51924a530596d728","name":"debug 592","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":2200,"wires":[]},{"id":"9c9a155a38c6ef3f","type":"function","z":"51924a530596d728","name":"multiple tokens","func":"const tokens = ['bitcoin','ethereum','open-ticketing-ecosystem']\nmsg.url = `https://api.coingecko.com/api/v3/simple/price?ids=${tokens.join(\",\")}&vs_currencies=eur%2Cusd&include_market_cap=true&include_24hr_change=true`\n\nreturn msg","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":2160,"wires":[["e49939c94740d8da"]]},{"id":"e49939c94740d8da","type":"http request","z":"51924a530596d728","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":690,"y":2200,"wires":[["6de7f5c4bf8b8dfb"]]},{"id":"45bae5bcd68ecbeb","type":"function","z":"51924a530596d728","name":"single token, market data","func":"const token = 'bitcoin'\nmsg.url = `https://api.coingecko.com/api/v3/coins/${token}?tickers=true&market_data=true&community_data=true&developer_data=true&sparkline=true`\n\nreturn msg","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":2200,"wires":[["e49939c94740d8da"]]},{"id":"9596754660bd41c5","type":"inject","z":"51924a530596d728","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":295,"y":2200,"wires":[["45bae5bcd68ecbeb"]],"l":false},{"id":"f897d86bfd83f04d","type":"function","z":"51924a530596d728","name":"dex contract - market info","func":"const token = 'open-ticketing-ecosystem'\nconst contract_address = '0xc28eb2250d1AE32c7E74CFb6d6b86afC9BEb6509' // ethereum\nconst base_url = `https://api.coingecko.com/api/v3/`\nconst contract_info = `/coins/${token}/contract/${contract_address}`\n\nmsg.url = `${base_url}${contract_info}`\n\nreturn msg","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":2240,"wires":[["e49939c94740d8da"]]},{"id":"c44ba00e40d23d46","type":"inject","z":"51924a530596d728","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":295,"y":2240,"wires":[["f897d86bfd83f04d"]],"l":false},{"id":"a30deb04c9635835","type":"function","z":"51924a530596d728","name":"dex contract history","func":"const token = 'open-ticketing-ecosystem'\nconst contract_address = '0xc28eb2250d1AE32c7E74CFb6d6b86afC9BEb6509' // ethereum\nconst base_url = `https://api.coingecko.com/api/v3/`\nconst market_chart = `/coins/${token}/contract/${contract_address}/market_chart?vs_currency=usd&days=1`\n\nmsg.url = `${base_url}${market_chart}`\n\nreturn msg","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":2280,"wires":[["e49939c94740d8da"]]},{"id":"c98a8aea57c26ca6","type":"inject","z":"51924a530596d728","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":295,"y":2280,"wires":[["a30deb04c9635835"]],"l":false}]

```

With this flow you can get what you are looking for.  
Dex data is a little more involved as you will need to specify the token name as specified by their api and the contract address you want to retrieve

[Documentation](https://web.archive.org/web/20230306023326/https://www.coingecko.com/en/api/documentation) via the internet archive

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 October 2024 11:34 UTC](https://discourse.nodered.org/t/create-a-program-that-automatically-scans-cryptocurrency-price-differences-between-cex-and-dex-exchanges/89310/4 "2024-10-04T11:34:31Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
