Skip to main content
cURL
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

grant_type
enum<string>
required

Method of authentication

Available options:
client_credentials,
client_signature,
refresh_token
Example:

"client_credentials"

client_id
string
required

Required for grant type `client_credentials` and `client_signature`

Example:

"fo7WAPRm4P"

client_secret
string
required

Required for grant type `client_credentials`

Example:

"W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS"

refresh_token
string
required

Required for grant type `refresh_token`

timestamp
integer
required

Required for grant type `client_signature`.

Provides time when request has been generated (milliseconds since the UNIX epoch).

signature
string
required

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.

nonce
string

Optional for grant type `client_signature`.

Delivers user generated initialization vector for the server token.

data
string

Optional for grant type `client_signature`.

Contains any user specific value.

state
string

Will be passed back in the response.

scope
string

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

Example:

"connection"

Response

200 - application/json

Success response

jsonrpc
enum<string>
required

The JSON-RPC version (2.0)

Available options:
2.0
result
object
required
id
integer

The id that was sent in the request