curl --request GET \
--url https://test.deribit.com/api/v2/public/auth \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 9929,
"method": "public/auth",
"params": {
"grant_type": "client_credentials",
"client_id": "fo7WAPRm4P",
"client_secret": "W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS"
}
}
'import requests
url = "https://test.deribit.com/api/v2/public/auth"
payload = {
"jsonrpc": "2.0",
"id": 9929,
"method": "public/auth",
"params": {
"grant_type": "client_credentials",
"client_id": "fo7WAPRm4P",
"client_secret": "W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS"
}
}
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
id: 9929,
method: 'public/auth',
params: {
grant_type: 'client_credentials',
client_id: 'fo7WAPRm4P',
client_secret: 'W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS'
}
})
};
fetch('https://test.deribit.com/api/v2/public/auth', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://test.deribit.com/api/v2/public/auth",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'id' => 9929,
'method' => 'public/auth',
'params' => [
'grant_type' => 'client_credentials',
'client_id' => 'fo7WAPRm4P',
'client_secret' => 'W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://test.deribit.com/api/v2/public/auth"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 9929,\n \"method\": \"public/auth\",\n \"params\": {\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"fo7WAPRm4P\",\n \"client_secret\": \"W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS\"\n }\n}")
req, _ := http.NewRequest("GET", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://test.deribit.com/api/v2/public/auth")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": 9929,\n \"method\": \"public/auth\",\n \"params\": {\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"fo7WAPRm4P\",\n \"client_secret\": \"W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://test.deribit.com/api/v2/public/auth")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"id\": 9929,\n \"method\": \"public/auth\",\n \"params\": {\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"fo7WAPRm4P\",\n \"client_secret\": \"W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS\"\n }\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": 9929,
"result": {
"access_token": "1582628593469.1MbQ-J_4.CBP-OqOwm_FBdMYj4cRK2dMXyHPfBtXGpzLxhWg31nHu3H_Q60FpE5_vqUBEQGSiMrIGzw3nC37NMb9d1tpBNqBOM_Ql9pXOmgtV9Yj3Pq1c6BqC6dU6eTxHMFO67x8GpJxqw_QcKP5IepwGBD-gfKSHfAv9AEnLJkNu3JkMJBdLToY1lrBnuedF3dU_uARm",
"expires_in": 31536000,
"refresh_token": "1582628593469.1GP4rQd0.A9Wa78o5kFRIUP49mScaD1CqHgiK50HOl2VA6kCtWa8BQZU5Dr03BhcbXPNvEh3I_MVixKZXnyoBeKJwLl8LXnfo180ckAiPj3zOclcUu4zkXuF3NNP3sTPcDf1B3C1CwMKkJ1NOcf1yPmRbsrd7hbgQ-hLa40tfx6Oa-85ymm_3Z65LZcnCeLrqlj_A9jM",
"scope": "connection mainaccount",
"enabled_features": [],
"token_type": "bearer"
}
}public/auth
Retrieve an OAuth access token, to be used for authentication of βprivateβ requests.
π Related Article: Authentication
Authentication Methods:
Three methods of authentication are supported:
-
client_credentials- Using the client id and client secret that can be found on the API page on the website. This is the simplest method, suitable for server-to-server applications and quick setup. -
client_signature- Enhanced security method that uses a cryptographic signature instead of sending the client secret directly. You generate an HMAC-SHA256 signature of a string containing a timestamp, a random nonce, and optional data, using your Client Secret as the key. This method requires`client_id`,`timestamp`(current time in milliseconds),`nonce`,`signature`, and optionally a`data`field. Deribit verifies the signature instead of requiring the raw secret. Best for enhanced security, asymmetric key pairs, and avoiding secret transmission. See the Client Signature (WebSocket) guide for detailed signature calculation instructions. -
refresh_token- Using a refresh token that was received from an earlier invocation. This allows you to obtain a new access token without re-supplying your Client ID and Client Secret. Best for long-lived sessions, token renewal, and avoiding re-authentication.
Response:
The response will contain an access token, expiration period (number of seconds that the token is valid) and a refresh token that can be used to get a new set of tokens.
curl --request GET \
--url https://test.deribit.com/api/v2/public/auth \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 9929,
"method": "public/auth",
"params": {
"grant_type": "client_credentials",
"client_id": "fo7WAPRm4P",
"client_secret": "W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS"
}
}
'import requests
url = "https://test.deribit.com/api/v2/public/auth"
payload = {
"jsonrpc": "2.0",
"id": 9929,
"method": "public/auth",
"params": {
"grant_type": "client_credentials",
"client_id": "fo7WAPRm4P",
"client_secret": "W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS"
}
}
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
id: 9929,
method: 'public/auth',
params: {
grant_type: 'client_credentials',
client_id: 'fo7WAPRm4P',
client_secret: 'W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS'
}
})
};
fetch('https://test.deribit.com/api/v2/public/auth', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://test.deribit.com/api/v2/public/auth",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'id' => 9929,
'method' => 'public/auth',
'params' => [
'grant_type' => 'client_credentials',
'client_id' => 'fo7WAPRm4P',
'client_secret' => 'W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://test.deribit.com/api/v2/public/auth"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 9929,\n \"method\": \"public/auth\",\n \"params\": {\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"fo7WAPRm4P\",\n \"client_secret\": \"W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS\"\n }\n}")
req, _ := http.NewRequest("GET", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://test.deribit.com/api/v2/public/auth")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": 9929,\n \"method\": \"public/auth\",\n \"params\": {\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"fo7WAPRm4P\",\n \"client_secret\": \"W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://test.deribit.com/api/v2/public/auth")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"id\": 9929,\n \"method\": \"public/auth\",\n \"params\": {\n \"grant_type\": \"client_credentials\",\n \"client_id\": \"fo7WAPRm4P\",\n \"client_secret\": \"W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS\"\n }\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": 9929,
"result": {
"access_token": "1582628593469.1MbQ-J_4.CBP-OqOwm_FBdMYj4cRK2dMXyHPfBtXGpzLxhWg31nHu3H_Q60FpE5_vqUBEQGSiMrIGzw3nC37NMb9d1tpBNqBOM_Ql9pXOmgtV9Yj3Pq1c6BqC6dU6eTxHMFO67x8GpJxqw_QcKP5IepwGBD-gfKSHfAv9AEnLJkNu3JkMJBdLToY1lrBnuedF3dU_uARm",
"expires_in": 31536000,
"refresh_token": "1582628593469.1GP4rQd0.A9Wa78o5kFRIUP49mScaD1CqHgiK50HOl2VA6kCtWa8BQZU5Dr03BhcbXPNvEh3I_MVixKZXnyoBeKJwLl8LXnfo180ckAiPj3zOclcUu4zkXuF3NNP3sTPcDf1B3C1CwMKkJ1NOcf1yPmRbsrd7hbgQ-hLa40tfx6Oa-85ymm_3Z65LZcnCeLrqlj_A9jM",
"scope": "connection mainaccount",
"enabled_features": [],
"token_type": "bearer"
}
}Query Parameters
Method of authentication
client_credentials, client_signature, refresh_token "client_credentials"
Required for grant type `client_credentials` and `client_signature`
"fo7WAPRm4P"
Required for grant type `client_credentials`
"W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS"
Required for grant type `refresh_token`
Required for grant type `client_signature`.
Provides time when request has been generated (milliseconds since the UNIX epoch).
Required for grant type `client_signature`.
It's a cryptographic signature calculated over provided fields using user secret key. The signature should be calculated as an HMAC (Hash-based Message Authentication Code) with `SHA256` hash algorithm.
Optional for grant type `client_signature`.
Delivers user generated initialization vector for the server token.
Optional for grant type `client_signature`.
Contains any user specific value.
Will be passed back in the response.
Describes type of the access for assigned token.
Possible values:
`connection``session:name``trade:[read, read_write, none]``wallet:[read, read_write, none]``account:[read, read_write, none]``expires:NUMBER``ip:ADDR`
Details are elucidated in Access scope
"connection"
Response
Success response
The JSON-RPC version (2.0)
2.0 Hide child attributes
Hide child attributes
OAuth access token to be used for authentication of 'private' requests
"843SehgeX5n6XxEU4XbABx4Cny5Akai5iHiJePTsvUw7"
Authorization type, allowed value - bearer
bearer Token lifetime in seconds
315360000
Can be used to request a new token (with a new lifetime)
"6faf8L36JdaSqsjCEEiwqifPpj6JB18RWwiWHrsGTZ91"
Type of the access for assigned token
Copied from the input (if applicable)
Optional Session id
List of enabled advanced on-key features.
Available options:
- restricted_block_trades: Limit the block_trade read the scope of the API key to block trades that have been made using this specific API key
- block_trade_approval: Block trades created using this API key require additional user approval. Methods that use block_rfq scope are not affected by Block Trade approval feature
2FA is required for privileged methods
"enabled"
The access token was acquired by logging in through Google.
The id that was sent in the request
Was this page helpful?