blinktrade / bitex

BlinkTrade - Open Source Bitcoin Exchange
GNU General Public License v3.0
428 stars 233 forks source link

Publish a REST API for basic market data (ticker) #19

Closed dllud closed 9 years ago

dllud commented 9 years ago

I know @pinhopro opposes a REST API:

Unfortunately, most of those websites keep pooling the website for more data. This is just not right, that is why I will never release any public REST api.

I think you should reconsider this. Sure he is right, those websites should use Websockets instead of pooling a REST API. However, Websockets are not a good solution in all scenarios (to each problem its solution). I would like to add bitex based exchanges to Boilr (check drpout/boilr#170). Boilr fetches the last value with a given update interval (e.g. 5 min). On mobile apps, such as Boilr, you should not leave a Websocket open in background as it would waste energy and bandwidth resources. Opening it every time you need to fetch last value isn't good either, (depending on the implementation) you may have to wait until the next trade takes places, which can take an indefinite amount of time. In this scenario a REST API is the best solution.

As @amingilani correctly said:

Web server load is only a scalability issue. If it's that large a problem, a separate instance can easily be spawned to deal with that part of the problem :confused:

Furthermore, you can always block consecutive REST API calls coming from the same IP address (e.g. cap it to one request per second per IP).

pinhopro commented 9 years ago

I already reconsidered.... I am working on a version that will offer a REST API.

pinhopro commented 9 years ago

Hi @dllud

Here is our public api.

Ticker - https://api.blinktrade.com/api/v1/[CURRENCY]/ticker?crypto_currency=BTC Order book - https://api.blinktrade.com/api/v1/[CURRENCY]/orderbook?crypto_currency=BTC Trades - https://api.blinktrade.com/api/v1/[CURRENCY]/trades?crypto_currency=BTC?since=[unix_timestamp]

You should replace the Currency for: BRL - FoxBit in Brazil VEF - SurBitcoin in Venezuela CLP - ChileBit in Chile PKR - UrduBit in Pakistan

For example: Ticker from FoxBit Brazil https://api.blinktrade.com/api/v1/BRL/ticker?crypto_currency=BTC

The api also supports JSONP, but it is very likely I will disable that in the near future. It all depends in how people use it.

dllud commented 9 years ago

Super! That's all that I need. We're adding all 4 exchanges to Boilr really soon. Thanks @pinhopro