-
Notifications
You must be signed in to change notification settings - Fork 18
How to find SDK functions that match API docs endpoint
This guide explains some ways on how to find exact function or functionality for the endpoint you want to use that is provided by official exchange API. These methods work for all SDKs maintained and published by @tiagosiebler.
All of the functions are located in the src/
folder inside the client file that you want to use. E.g. SpotClient
, FuturesClient
- depends on what they refer to. Each function represents one endpoint from the official API docs
Every SDK will have endpoint map where you can find all functions connected to endpoint URL for quick search. It is located under docs/endpointFunctionList.md
. This document provides fastest way to search for function that represents single endpoint.
Please note that all of our SDKs have very generic function names and are most often repeated with the same format which you will quickly get used to, no matter which exchange you are working with - thus why it is easy, quick and pain-free for most developers to move to new exchange with our tools!
Most functions start with:
-
get
- getTickers, getSymbols, getFundingRates, getPositions, getOrders etc.
- when fetching something, most of time it starts with get and that is the most repeated function name within the SDK
-
submit
- submitOrder, submitWithdraw etc.
- whenever something is sent to the exchange - most often that will be order, transfer or withdraw/deposit
-
update/modify
- updateOrder, updateLeverage, updateMarginMode etc.
- when updating something that is already existing on the exchange, sometimes it can also be be modify instead of update
-
delete/cancel
- cancelOrder, deleteSubaccount, deleteAPIKey, cancelWithdrawal etc.
- when removing something from the exchange
There are some of the other function names, less frequent, like earn
, borrow
, repay
... They are very logical and should be found easily.
Each endpoint falls under some category in the official API docs. Second word in the SDK is most often category name(Spot, Futures, Margin...) and after that goes what the endpoint does. E.g. getSpotTickers, submitFuturesOrder, updateMarginBorrow... That way you can quickly search for functions.
In some SDKs, client will be divided in SpotClient or FuturesClient, which means there will be no category in the function name. Just what it does. E.g. submitOrder will be available in both SpotClient and FuturesClient because they are already divided!
This SDK is built with typescript and is heavily typed - which means your editor will help you when searching for functions! You can just start typing function or endpoint name or, even better, keywords like order, withdraw, deposit, position, ticker etc. You will see dropdown menus with list of functions like this.
As you can see, typing keyword will most likely give you a solution for what you need!
This step will always find you exact endpoint that you need, but takes a bit more time. We can divide it in few steps:
- Find the Endpoint in Official Docs
Go to the official API documentation and find the endpoint you want to use.
- Locate the Client File
Navigate to the src/
folder in your SDK and find the file that represents the client you want to use - RestClient.ts
, SpotClient.ts
or FuturesClient.ts
or something else the SDK provides, but matches your need. Most often you can logically see from the endpoint docs where you should find exact function.
- Search for the URL in client file
Open the client file and use Ctrl + F to search for the URL of the endpoint you found in the official docs.
- Identify the Function: Once you find the URL, identify the function that uses this endpoint
Example:
We want to search for Get Tickers endpoint. First, we find it in the official docs(in this example, Bybit) and locate the endpoint:
Next, we copy the part of the URL /v5/market/tickers
and go search for it in the client file using Ctrl+F. Note that some functions can have same URL, but different method like GET
, POST
or DELETE
.
In this example, we can see function name is matching the endpoint name. So, we take the function and put it in our code to get the ticker data:
Check out my related JavaScript/TypeScript/Node.js projects:
- Try my REST API & WebSocket SDKs:
- Try my misc utilities:
- Check out my examples: