Fetch bitcoin exchange data for beginners using websocket
An error is returned if the quote has expired or if you have insufficient available balance. Once a quote has been discarded, it cannot be exercised even if it has not expired yet.
This API is still in beta phase. This means that it may still undergo incompatible changes. The websocket API provides streaming access to market data.
It is more efficient and provides lower latency information than repeatedly polling the orderbook and recent trades but is more complicated to implement. The streaming protocol works by requiring the client to keep an in-memory record of the order book. Update messages are then sent from the server and the client uses these to update its copy of the order book.
If they are applied correctly and fully, the client's view of the order book will be identical to the server's view. The client state consists of the following data: Each update message transmitted from the server has a unique increasing sequence number. The message with sequence number n can be applied to state sequence n-1 to produce state sequence n. In this case, an update message would be sent containing multiple trade updates. There will be no create update since the new order never enters the order book.
In this case, the update message contains multiple trade updates and a create update. The volume in the create update is the remaining volume for the order. The streaming updates protocol described above can be accessed using websockets. The server first sends the current order book state and thereafter sends update messages as quickly as possible.
Both the client and server must send regular keep alive messages to avoid disconnection during periods of low update message activity. If there is any error while processing an update e. It is critical that clients implement exponential backoff for all reconnections to avoid overloading the server in case of errors. If you are interested in integrating Bitcoin payments as a merchant, please contact Luno Support.
Android Haskell Java Node. Ticker Returns the latest ticker indicators. At most results are returned per call. Permissions Each API key is granted a set of permissions when it is created. Here is a list of the possible permissions: Accounts All transactions on the Luno platform operate on accounts. Create Account Create an additional account for the specified currency. Click here to read more about how order matching works. List Orders Returns a list of the most recently placed orders.
Some trades may have taken place but the order is not filled yet. It has been settled or has been cancelled. The pair specifies the market. Definition A market order executes immediately, and either buys as much bitcoin that can be bought for a set amount of fiat currency, or sells a set amount of bitcoin for as much fiat as possible. Results of this query may lag behind the latest data. If not provided, the default address will be used.
The currency depends on the type. This parameter is required if you have multiple bank accounts. Your bank account beneficiary ID can be found by clicking on the beneficiary name on the Beneficiaries page. XBT address string required Destination Bitcoin address or email address, or Ethereum address to send to.
Ethereum addresses must be checksummed. Ethereum sends to email addresses are not supported. This is only relevant when sending to an email address. Create a quote Creates a new quote to buy or sell a particular amount. The pair can also be flipped if you want to buy or sell the counter currency e. Protocol The client state consists of the following data: A message may contain multiple updates which must be applied atomically and in order. There are three types of update: Create Add a bid or ask order to the order book with a given id, price and volume.
A market order is placed that is immediately filled In this case, an update message would be sent containing multiple trade updates. An order is placed that is partially filled In this case, the update message contains multiple trade updates and a create update.
An order is stopped In this case, the update message contains a single delete update. Websockets The streaming updates protocol described above can be accessed using websockets. Connect to the websocket server at: The client must start by sending API key credentials: OAuth2 is no longer available for new applications. Updated websocket server to wss: Address creation is rate limited to 1 per hour, allowing for bursts of up to 10 consecutive calls. Added beta Streaming API section Error code may be returned when exceeding rate limits.
This will become the default as of You will have to generate a new API key if you require these permissions. The old URLs are now deprecated. Added POST accounts for creating additional accounts in specified currencies.
Added the "Name" field to the "Balance" response Added the "Accounts" section. Added the account transactions and pending transactions calls. Added the "Permissions" section. Documented which permissions are required for each call. Updated description of the "send" call. A pin is no longer required. The amount parameter for withdrawal requests now excludes the withdrawal fee. Added the new Quotes API. The transactions beta call has been deprecated.
The balance method can now be called with no arguments to return all account balances. Added Send API call. Orders placed through the API are no longer subject to different limits than those placed through the website. You can now create multiple API keys with different permissions e. Added calls to list, create, get and cancel withdrawal requests.
Added link to Android client library. The preferred host name for API calls has changed to api. Added experimental call to retrieve transactions list. Added call to allocate new receive addresses. A session key is only valid for 30 days and it has a sliding window period, so each time you use it, it will get extended by 30 days.
Type less than will mean there was an error. This section deals with all the requests for price data, social data and historical data. Most of it is used for dealing with subscription, top list, historical and snapshot data. Get the latest price for a list of one or more currencies. Really fast, ms. Cached each 10 seconds. Get all the current trading info price, vol, open, high, low etc of any list of cryptocurrencies in any other currency that you need.
If the crypto does not trade directly into the toSymbol requested, BTC will be used for conversion. This API also returns Display values for all the fields. If the opposite pair trades we invert it eg.: Compute the current trading info price, vol, open, high, low etc of the requested pair as a volume weighted average based on the markets requested. Get day average price. The values are based on hourly vwap data and the average can be calculated in different waysIt uses BTC conversion if data is not available because the coin is not trading in the specified currency.
If tryConversion is set to false it will give you the direct data. If no toTS is given it will automatically do the current day. Get the price of any cryptocurrency in any other currency that you need at a given timestamp. The price comes from the daily info - so it would be the price at the end of the day GMT based on the requested TS.
Tries to get direct trading pair data, if there is none or it is more than 30 days before the ts requested, it uses BTC conversion. Get data for a currency pair. It returns general block explorer information, aggregated data and individual data for each exchange available. This api is getting abused and will be moved to a min-api path in the near future. Please try not to use it. Get the general, subs used to connect to the streamer and to figure out what exchanges we have data for and what are the exact coin pairs of the coin and the aggregated prices for all pairs available.
AggregatedPrices Array yes Snapshot data about the coin volume, price, open, high, low close etc. If called with the id of a cryptopian you just get data from our website that is available to the public. UrlstringnoThe relative path without https: Get open, high, low, close, volumefrom and volumeto from the each minute historical data. This data is only stored for 7 days, if you need more,use the hourly or daily path.
It uses BTC conversion if data is not available because the coin is not trading in the specified currency. The values are based on Used to get all the mining equipment available on the website. It returns an array of mining equipment objects. Get top pairs by volume for a currency always uses our aggregated data. The number of pairs you get is the minimum of the limit you set default 5 and the total number of pairs available.
Get real-time market data updates by connecting to our web socket ' wss: We are using socket. For more example code click here. Subscribe to market data by emitting 'SubAdd' including a list of items you want to get updates on. After the first response, only updates will be sent.
The MaskInt parameter maps the response to the properties. Use our utility functions to map the response, you can find the code here. Introduction The best API for getting free cryptocurrency live pricing data, OHLC historical data, volume data, tick data or block explorer data from multiple exchanges and blockchains.
Requests Most of the requests that are related to pricing data are public at the moment and generally available via GET functions. Sessions A session key is only valid for 30 days and it has a sliding window period, so each time you use it, it will get extended by 30 days. Note that the responses to all requests, both public and private, are sent as the response body.
Data This section deals with all the requests for price data, social data and historical data. Data Object yes Empty if there is no data to return or there is an error Data [Symbol]: Id int yes The internal id, this is used in other calls Data [Symbol]: ImageUrl string yes The logo image of the coin Data [Symbol]: CoinName string yes The name Data [Symbol]: FullName string yes A combination of the name and the symbol Data [Symbol]: Algorithm string yes The algorithm of the cryptocurrency Data [Symbol]: ProofType string yes The proof type of the cryptocurrency Data [Symbol]: Invalid Market ", "Data": For PST you would pass -8 for example.
URL Parameters Parameter Type Mandatory Description fsym string yes The symbol of the currency you want to get that for tsym string yes The symbol of the currency that data will be in. Return data Parameter Type Always returned Description Response string yes The type of the response Success or Error Message string yes The message for the response Type integer yes Integer representing the type of response. Data object yes Empty if there is no data to return or there is an error Data: Algorithm string yes The algorithm of the from currency Data: BlockNumber integer yes The current block number delayed by 1 hour max Data: BlockReward integer yes The current block reward delayed by 1 hour max Data: AggregatedData object yes See success request example Data: What are you trying to do?
AggregatedPrices Array yes Snapshot data about the coin volume, price, open, high, low close etc Parameter Type Always returned Description Response string yes The type of the response Success or Error Message string yes The message for the response BaseImageUrl string yes The base url for all the images from the ImageUrl field BaseLinkUrl string yes The base url for all the links from the Url field Type int yes Integer representing the type of response.
General object yes The general data available for this coin Data: H1Text string yes The title used on our website a combination of the coin name and the symbol Data: ImageUrl string yes The relative path to the logo of the coin, prefix this value with the BaseImageUrl to get the absolute path Data: DangerTop string yes The text displayed in red on the website at the top, generally a big issue with the coin Data: WarningTop string yes The text displayed in yellow on the website at the top, generally an issue with the coin Data: InfoTop string yes The text displayed in green on the website at the top, generally an announcement or extra info that is important Data: Symbol string yes The symbol of the coin Data: Url string yes The relative path to the coin, prefix this value with the BaseLinkUrl to get the absolute path Data: Name string yes The name of the coin Data: Description string yes The description of the coin, this is returned as html Data: Features string yes The features of the coin, this is returned as html Data: Technology string yes The technology of the coin, this is returned as html Data: TotalCoinSupply int yes The maximum number of coins Data: StartDate string yes The day the first block was mined, so the day the coin actually came into existance Data: Twitter string yes The twitter address of the coin Data: TwitterWidgetId string yes The cryptocompare twitter widget id for this coin Data: Website string yes The coin official website Data: DifficultyAdjustment string yes The difficulty adjustment Data: BlockRewardReduction string yes The value by which the block reward is reduced when there is a block reward reduction Data: BlockNumber int yes The current block number delayed by 1 hour max Data: BlockTime int yes The estimated time it takes to mine a block Data: TotalCoinsMined int yes The current total coins mined delayed by 1 hour max Data: PreviousTotalCoinsMined int yes The total coins mined as of the previous block, this should be the value of the current block total coins mined - the block reward in most cases.