forked from kant2002/deribit-api-clients
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 23dd651
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Deribit API clients | ||
|
||
## About | ||
Interact with the Deribit API from the comfort of your favorite programming language. | ||
The client libraries are automatically generated and cover the REST endpoints of the API. | ||
|
||
These clients interface with the Deribit API v2. | ||
[Find the documentation here](https://docs.deribit.com/v2/#deribit-api-v2-0-0) | ||
|
||
##### Important | ||
The access token is valid for a certain time, read more about the scope of access tokens, their validity time and how to refresh them [here](https://docs.deribit.com/v2/#authentication-2). | ||
|
||
## Currently supported | ||
|
||
* Android | ||
* ASP.NET Core | ||
* C | ||
* Clojure | ||
* C | ||
* C++ Qt5 | ||
* C++ REST SDK | ||
* C# | ||
* Erlang | ||
* Go | ||
* Java | ||
* JavaScript | ||
* Kotlin | ||
* Objective-C | ||
* PHP | ||
* Python | ||
* R | ||
* Ruby | ||
* Scala (Akka) | ||
* Swift 4 | ||
* TypeScript | ||
|
||
|
||
## Examples | ||
|
||
Following are example code snippets on how to do authentication (using `client_credentials`) with the Python and PHP client libraries | ||
|
||
##### Python | ||
``` | ||
# Setup configuration instance | ||
conf = configuration.Configuration() | ||
# Setup unauthenticated client | ||
client = api_client.ApiClient(conf) | ||
publicApi = public_api.PublicApi(client) | ||
# Authenticate with API credentials | ||
response = publicApi.public_auth_get('client_credentials', '', '', 'API_ACCESS_KEY', 'API_SECRET_KEY', '', '', '', scope='session:test wallet:read') | ||
access_token = response['result']['access_token'] | ||
conf_authed = configuration.Configuration() | ||
conf_authed.access_token = access_token | ||
# Use retrieved authentication token to setup private endpoint client | ||
client_authed = api_client.ApiClient(conf_authed) | ||
privateApi = private_api.PrivateApi(client_authed) | ||
response = privateApi.private_get_transfers_get(currency='BTC') | ||
print(response['result']['data'][0]['amount']) | ||
response = privateApi.private_get_current_deposit_address_get(currency='BTC') | ||
print(response['result']['address']) | ||
``` | ||
##### PHP | ||
``` | ||
$configuration = new Configuration(); | ||
$publicApi = new PublicApi($client = null, $configuration); | ||
// Authenticate with API credentials | ||
$authData = $publicApi->publicAuthGet('client_credentials', '', '', 'API_ACCESS_KEY', 'API_SECRET_KEY', '', '', '', null, null, 'session:test wallet:read'); | ||
$authDataParsed = json_decode($authData[0], true); | ||
$accessToken = $authDataParsed['result']['access_token']; | ||
// Use retrieved authentication token to setup private endpoint client | ||
$authedConfig = new Configuration(); | ||
$authedConfig->setAccessToken($accessToken); | ||
$privateApi = new PrivateApi(null, $authedConfig); | ||
$accountSummaryBTC = $privateApi->privateGetAccountSummaryGet('BTC'); | ||
var_dump($accountSummaryBTC); | ||
$currentDepositAddressBTC = $privateApi->privateGetCurrentDepositAddressGet('BTC'); | ||
var_dump($currentDepositAddressBTC); | ||
$transfersBTC = $privateApi->privateGetTransfersGet('BTC'); | ||
var_dump($transfersBTC); | ||
``` | ||
|
||
## Found a bug or have a question? | ||
Please open an issue and it will be addressed. |