API
REST¶
Spot¶
ExchangeInfo¶
Get rules¶
GET /spot/exchangeInfo/symbols/{symbol}
Gets exchange rules for required symbol
Request¶
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
symbol |
string required |
path |
Symbol name (e.g ETH-USDT) |
Example
import requests
base_url = "https://dex-api.pepe.team"
prefix = "spot/exchangeInfo/fees"
symbol = "ETH-USDT"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
response = requests.request("GET", '{}/{}/{}'.format(base_url, prefix, symbol) , headers=headers)
print(response.json())
Response¶
200
| Field | Type | Description |
|---|---|---|
object |
ExchangeRule response | |
name |
string |
Symbol name |
base_asset |
string |
Base asset name |
quote_asset |
string |
Quote asset name |
rules |
object |
Rules for price and volume |
price |
object |
Price rule |
min |
string |
Minimum price in an order that can be placed |
max |
string |
Maximum price in an order that can be placed |
multiplicity |
string |
Order price must be a multiple of this value (i.e. divisible without remainder) |
base |
object |
Base asset rule |
min |
string |
Minimum base amount in an order that can be placed |
max |
string |
Maximum base amount in an order that can be placed |
multiplicity |
string |
Order base amount must be a multiple of this value (i.e. divisible without remainder) |
quote |
object |
Quote asset rule |
min |
string |
Minimum quote amount in an order that can be placed |
max |
string |
Maximum quote amount in an order that can be placed |
multiplicity |
string |
Order quote amount must be a multiple of this value (i.e. divisible without remainder) |
Example
Get fees¶
GET /spot/exchangeInfo/fees/{symbol}
Gets default exchange fees for required symbol
Request¶
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
symbol |
string required |
path |
Symbol name (e.g ETH-USDT) |
Example
import requests
base_url = "https://dex-api.pepe.team"
prefix = "spot/exchangeInfo/fees"
symbol = "ETH-USDT"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
response = requests.request("GET", '{}/{}/{}'.format(base_url, prefix, symbol) , headers=headers)
print(response.json())
Response¶
Market¶
Get KLines¶
GET /spot/market/klines/{symbol}/{interval}
Gets klines(candles, candlesticks) for required symbol and interval. Klines are uniquely identified by their ts_ms. KLine is not returned if trades_count==0
Request¶
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
symbol |
string required |
path |
Symbol name (e.g ETH-USDT) |
interval |
string required |
path |
Candle interval. Available values: m1,m5,m15,m30,h1,h3,d1 |
limit |
number |
query |
Maximum count of records to be returned in a single list. Default: 500, Min: 1, Max: 1000 |
after |
string |
query |
Base64 encoded previous cursor |
since |
number |
query |
Minimum candle unixtime (inclusive). Default 0 |
until |
number |
query |
Maximum candle unixtime (inclusive). Default now() |
Example
import requests
base_url = "https://dex-api.pepe.team"
prefix = "spot/market/klines"
symbol = "ETH-USDT"
interval = "d1"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
# first kline
first_response = requests.request("GET", '{}/{}/{}/{}?limit=1'.format(base_url, prefix, symbol, interval) , headers=headers)
first_response_data = first_response.json()
print(first_response_data)
# second kline
if first_response_data['has_next_page']:
second_response = requests.request("GET", '{}/{}/{}/{}?limit=1&after={}'.format(base_url, prefix, symbol, interval, first_response_data['last_cursor']) , headers=headers)
second_response_data = second_response.json()
print(second_response_data)
type CandleInterval = 'm1' | 'm5' | 'm15' | 'm30' | 'h1' | 'h3' | 'd1';
const baseUrl = 'https://dex-api.pepe.team';
const prefix = 'spot/market/klines';
const symbol = 'ETH-USDT';
const interval: CandleInterval = 'd1';
const limit = 1;
// first kline
const firstResponse = await fetch(`${baseUrl}/${prefix}/${symbol}/${interval}?limit=${limit}`);
const firstResponseData = await firstResponse.json();
console.log(firstResponseData);
// second kline
if (firstResponseData.has_next_page) {
const afterCursor = firstResponseData.last_cursor;
const secondResponse = await fetch(`${baseUrl}/${prefix}/${symbol}/${interval}?limit=${limit}&after=${afterCursor}`);
const secondResponseData = await secondResponse.json();
console.log(secondResponseData);
}
Response¶
200
| Field | Type | Description |
|---|---|---|
object |
KLines response | |
last_cursor |
string | null |
Base64 encoded subsequent data retrieval cursor |
has_next_page |
boolean |
true if data retrieval can continue |
data |
array |
Klines. Order by ts_ms desc |
object |
Kline | |
ts_ms |
number |
Kline start unixtime in ms |
open_price |
string |
First trade price |
close_price |
string |
Last trade price |
high_price |
string |
Highest price |
low_price |
string |
Lowest price |
base_volume |
string |
Volume in base asset |
quote_volume |
string |
Volume in quote asset |
trades_count |
number |
Count of trades |
Example
{
"last_cursor": "2N6XPeWTvGQTckUxH8zoNUfYv1fkvHxwNDNQg",
"has_next_page": true,
"data": [
{
"ts_ms": 1741651200000,
"open_price": "1906.28",
"close_price": "1895.13",
"low_price": "1895.13",
"high_price": "1906.28",
"base_volume": "0.0324",
"quote_volume": "61.582842",
"trades_count": 2
},
{
"ts_ms": 1741305600000,
"open_price": "2193.56",
"close_price": "2191.39",
"low_price": "2177.35",
"high_price": "2193.56",
"base_volume": "0.0419",
"quote_volume": "91.669655",
"trades_count": 3
}
]
}
Get Orderbook¶
GET /spot/market/orderbook/{symbol}
Gets orderbook (level2) for required symbol
Request¶
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
symbol |
string required |
path |
Symbol name (e.g ETH-USDT) |
limit |
number |
query |
Maximum count of order depth data in asks or bids. Min: 1 |
Example
import requests
base_url = "https://dex-api.pepe.team"
prefix = "spot/market/orderbook"
symbol = "ETH-USDT"
limit = 2
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
res = requests.request("GET", '{}/{}/{}?limit={}'.format(base_url, prefix, symbol, limit) , headers=headers)
print(res.json())
Response¶
200
| Field | Type | Description |
|---|---|---|
object |
Orderbook response | |
data |
object |
Snapshot data |
ts_ms |
number |
Snapshot unixtime in ms |
update_id |
number |
ID of the last orderbook change |
open_interest |
string |
Active orders sum in base asset |
asks |
array |
Orders to sell base asset. Order by price asc |
array |
L2 order | |
price |
string |
L2 order price |
quantity |
string |
L2 order quantity in base asset |
bids |
array |
Orders to buy base asset. Order by price desc |
array |
L2 order | |
price |
string |
L2 order price |
quantity |
string |
L2 order quantity in base asset |
Example
Get Ticker 24h by symbol¶
GET /spot/market/tickers/24h/{symbol}
Gets the 24 hour ticker for required symbol
Request¶
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
symbol |
string required |
path |
Symbol name (e.g ETH-USDT) |
Example
Response¶
200
| Field | Type | Description |
|---|---|---|
array |
Ticker response | |
symbol |
string |
Symbol name |
ts_ms |
number |
Calculation start unixtime in ms |
open_price |
string | null |
First trade price |
close_price |
string | null |
Last trade price |
high_price |
string | null |
Highest price |
low_price |
string | null |
Lowest price |
base_volume |
string |
Volume in base asset |
quote_volume |
string |
Volume in quote asset |
trades_count |
number |
Count of trades |
Get Tickers 24h¶
GET /spot/market/tickers/24h
Gets all 24 hour tickers for required symbols
Request¶
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
symbols |
string[] |
query |
Symbols array (e.g ["ETH-USDT"]) |
Example
import requests
base_url = "https://dex-api.pepe.team"
prefix = "spot/market/tickers/24h"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
# get all tickers
res = requests.request("GET", '{}/{}'.format(base_url, prefix) , headers=headers)
print(res.json())
# get required tickers
symbols = ["ETH-USDT", "WBTC-USDT"]
payload = {"symbols[]": symbols }
res = requests.request("GET", '{}/{}'.format(base_url, prefix) , headers=headers, params=payload)
print(res.json())
const baseUrl = 'https://dex-api.pepe.team';
const prefix = 'spot/market/tickers/24h';
let url = new URL(`${baseUrl}/${prefix}`);
// get all tickers
const allTickersResopnse = await fetch(url);
console.log(await allTickersResopnse.json());
// get required tickers
let queryParams = new URLSearchParams();
queryParams.append('symbols[]', 'ETH-USDT');
queryParams.append('symbols[]', 'WBTC-USDT');
url.search = queryParams;
const requiredTickersResponse = await fetch(url);
console.log(await requiredTickersResponse.json());
Response¶
200
| Field | Type | Description |
|---|---|---|
array |
Tickers | |
array |
Ticker | |
symbol |
string |
Symbol name |
ts_ms |
number |
Calculation start unixtime in ms |
open_price |
string | null |
First trade price |
close_price |
string | null |
Last trade price |
high_price |
string | null |
Highest price |
low_price |
string | null |
Lowest price |
base_volume |
string |
Volume in base asset |
quote_volume |
string |
Volume in quote asset |
trades_count |
number |
Count of trades |
Example
[
[
"ETH-USDT", // symbol
1741553924310, // ts_ms
null, // open_price
null, // close_price
null, // high_price
null, // low_price
"0", // base_volume
"0", // quote_volume
0 // trades_count
],
[
"WBTC-USDT", // symbol
1741553924453, // ts_ms
"79244.4", // open_price
"79244.4", // close_price
"79244.4", // high_price
"79244.4", // low_price
"0.00051", // base_volume
"40.414644", // quote_volume
1 // trades_count
]
]
Get Trades¶
GET /spot/market/trades/{symbol}
Gets trades for required symbol
Request¶
Parameters
| Parameter | Type | Location | Description |
|---|---|---|---|
symbol |
string required |
path |
Symbol name (e.g ETH-USDT) |
limit |
number |
query |
Maximum count of records to be returned in a single list. Default: 100, Min: 1, Max: 1000 |
after |
string |
query |
Base64 encoded previous cursor |
since |
number |
query |
Minimum trade unixtime (inclusive) |
until |
number |
query |
Maximum trade unixtime (inclusive) |
Example
import requests
base_url = "https://dex-api.pepe.team"
prefix = "spot/market/trades"
symbol = "ETH-USDT"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}
# first trade
first_response = requests.request("GET", '{}/{}/{}?limit=1'.format(base_url, prefix, symbol) , headers=headers)
first_response_data = first_response.json()
print(first_response_data)
# second trade
if first_response_data['has_next_page']:
second_response = requests.request("GET", '{}/{}/{}?limit=1&after={}'.format(base_url, prefix, symbol, first_response_data['last_cursor']) , headers=headers)
second_response_data = second_response.json()
print(second_response_data)
const baseUrl = 'https://dex-api.pepe.team';
const prefix = 'spot/market/trades';
const symbol = 'ETH-USDT';
const limit = 1;
// first trade
const firstResponse = await fetch(`${baseUrl}/${prefix}/${symbol}?limit=${limit}`);
const firstResponseData = await firstResponse.json();
console.log(firstResponseData);
// second trade
if (firstResponseData.has_next_page) {
const afterCursor = firstResponseData.last_cursor;
const secondResponse = await fetch(`${baseUrl}/${prefix}/${symbol}?limit=${limit}&after=${afterCursor}`);
const secondResponseData = await secondResponse.json();
console.log(secondResponseData);
}
Response¶
200
| Field | Type | Description |
|---|---|---|
object |
Trades response | |
last_cursor |
string | null |
Base64 encoded subsequent data retrieval cursor |
has_next_page |
boolean |
true if data retrieval can continue |
data |
array |
Trades. Order by ts_ms desc |
array |
Trade | |
ts_ms |
number |
Trade unixtime in ms |
side |
"S" | "B" |
Trade side. Sell: S, Buy: B |
price |
string |
Trade price |
base_volume |
string |
Trade volume in base quantity |
WebSocket¶
Public¶
Endpoints
- mainnet:
wss://dex-ws.pepe.team/public - testnet:
wss://dex-testnet-ws.pepe.team/public
Subscribe¶
Request¶
Parameters
| Parameter | Type | Description |
|---|---|---|
object |
JsonRPC request | |
jsonrpc |
"2.0" |
JsonRPC version |
id |
number |
JsonRPC request Id |
method |
"subscribe" |
JsonRPC method name |
params |
array |
JsonRPC params |
channels |
string[] |
Subscription channels max count is 50. Available channels format:{symbol}@t - trades {symbol}@t24 - ticker24 updates {symbol}@ob - l2 orderbook updates {symbol}@kline_{interval} - kline updates (interval: "m1", "m5", "m15", "m30", "h1", "h3", "d1") |
Example
import asyncio
import signal
from jsonrpc_websocket import Server
ws_url = "wss://dex-ws.pepe.team/public"
channels = ["ETH-USDT@t24","ETH-USDT@ob","ETH-USDT@t","ETH-USDT@kline_h1"]
def handler(subscription, result):
print(subscription, result)
async def routine(url):
server = Server(url)
try:
await server.ws_connect()
server.t = handler
server.t24 = handler
server.ob = handler
server.kline = handler
subscribtion_id = await server.subscribe(channels)
await asyncio.wait([asyncio.Future()])
except asyncio.CancelledError:
await server.unsubscribe(subscribtion_id)
finally:
await server.close()
event_loop = asyncio.new_event_loop()
asyncio.set_event_loop(event_loop)
main_task = asyncio.ensure_future(routine(ws_url))
event_loop.add_signal_handler(signal.SIGINT, main_task.cancel)
event_loop.add_signal_handler(signal.SIGTERM, main_task.cancel)
try:
event_loop.run_until_complete(main_task)
finally:
event_loop.close()
const jayson = require('jayson');
const url = "wss://dex-ws.pepe.team/public"
const channels = ["ETH-USDT@t24", "ETH-USDT@ob", "ETH-USDT@t", "ETH-USDT@kline_h1"];
const client = jayson.client.websocket({ url });
client.ws.on('open', function () {
client.request('subscribe', [channels], () => { });
});
client.ws.on('message', console.log)
Response¶
Notification¶
OrderBookUpdate
| Field | Type | Description |
|---|---|---|
object |
JsonRPC notification | |
jsonrpc |
string |
JsonRPC version |
method |
"ob" |
JsonRPC method name |
params |
object |
JsonRPC parameters |
subscription |
number |
Subscription ID |
result |
object |
Orderbook update notification |
s |
string |
Symbol name (e.g ETH-USDT) |
u |
number |
Update id. Sequential counter |
U |
number |
Update unixtime in ms |
oi |
string |
New active orders sum in base asset |
A |
array |
Orders update to sell base asset |
array |
L2 order update | |
price |
string |
L2 order update price |
price |
string |
New L2 order quantity in base asset |
B |
string |
Orders update to buy base asset |
array |
L2 order update | |
price |
string |
L2 order update price |
price |
string |
New L2 order quantity in base asset |
Ticker24
| Field | Type | Description |
|---|---|---|
object |
JsonRPC notification | |
jsonrpc |
string |
JsonRPC version |
method |
"t24" |
JsonRPC method name |
params |
object |
JsonRPC parameters |
subscription |
number |
Subscription ID |
result |
object |
Ticker update notification |
s |
string |
Symbol name (e.g ETH-USDT) |
U |
number |
Calculation start unixtime in ms |
op |
string | null |
First trade price |
cp |
string | null |
Last trade price |
lp |
string | null |
Lowest price |
hp |
string | null |
Highest price |
bv |
string |
Volume in base asset |
qv |
string |
Volume in quote asset |
t |
number |
Count of trades |
Trade
| Field | Type | Description |
|---|---|---|
object |
JsonRPC notification | |
jsonrpc |
string |
JsonRPC version |
method |
"t" |
JsonRPC method name |
params |
object |
JsonRPC parameters |
subscription |
number |
Subscription ID |
result |
object |
Trade notification |
s |
string |
Symbol name (e.g ETH-USDT) |
U |
number |
Trade unixtime in ms |
S |
"BUY" | "SELL" |
Trade side |
p |
string |
Trade price |
q |
string |
Trade volume in base quantity |
KLineUpdate
| Field | Type | Description |
|---|---|---|
object |
JsonRPC notification | |
jsonrpc |
string |
JsonRPC version |
method |
"kline" |
JsonRPC method name |
params |
object |
JsonRPC parameters |
subscription |
number |
Subscription ID |
result |
object |
KLine update notification |
s |
string |
Symbol name (e.g ETH-USDT) |
I |
"M1" | "M5" | "M15" | "M30" | "H1" | "H3" | "D1" |
KLine interval |
T |
number |
Kline start unixtime in ms |
op |
string |
First trade price |
cp |
string |
Last trade price |
lp |
string |
Lowest price |
hp |
string |
Highest price |
bv |
string |
Volume in base asset |
qv |
string |
Volume in quote asset |
t |
number |
Count of trades |
Unsubscribe¶
Request¶
Parameters
| Parameter | Type | Description |
|---|---|---|
object |
JsonRPC request | |
jsonrpc |
"2.0" |
JsonRPC version |
id |
number |
JsonRPC request Id |
method |
"unsubscribe" |
JsonRPC method name |
params |
array |
JsonRPC params |
subscription |
string |
Subscription ID |
Example
import asyncio
import signal
from jsonrpc_websocket import Server
ws_url = "wss://dex-ws.pepe.team/public"
channels = ["ETH-USDT@t24","ETH-USDT@ob","ETH-USDT@t","ETH-USDT@kline_h1"]
def handler(subscription, result):
print(subscription, result)
async def routine(url):
server = Server(url)
try:
await server.ws_connect()
server.t = handler
server.t24 = handler
server.ob = handler
server.kline = handler
subscribtion_id = await server.subscribe(channels)
await asyncio.wait([asyncio.Future()])
except asyncio.CancelledError:
await server.unsubscribe(subscribtion_id)
finally:
await server.close()
event_loop = asyncio.new_event_loop()
asyncio.set_event_loop(event_loop)
main_task = asyncio.ensure_future(routine(ws_url))
event_loop.add_signal_handler(signal.SIGINT, main_task.cancel)
event_loop.add_signal_handler(signal.SIGTERM, main_task.cancel)
try:
event_loop.run_until_complete(main_task)
finally:
event_loop.close()
const jayson = require('jayson');
const url = "wss://dex-ws.pepe.team/public"
const channels = ["ETH-USDT@t24", "ETH-USDT@ob", "ETH-USDT@t", "ETH-USDT@kline_h1"];
const client = jayson.client.websocket({ url });
client.ws.on('open', function () {
client.request('subscribe', [channels], () => { });
});
client.ws.on('message', console.log)
Response¶
Private¶
Endpoints
- mainnet:
wss://dex-ws.pepe.team/private - testnet:
wss://dex-testnet-ws.pepe.team/private
Auth¶
Request¶
Parameters
| Parameter | Type | Description |
|---|---|---|
object |
JsonRPC request | |
jsonrpc |
"2.0" |
JsonRPC version |
id |
number |
JsonRPC request Id |
method |
"auth" |
JsonRPC method name |
params |
array |
JsonRPC params |
web3_id |
string |
Web3 account id |
ts_ms |
number |
Signature unixtime in ms |
web3_alg |
number |
Signature algorithm id |
sig |
string |
Signature string (see Signature generation) Signature data bytes: - ts_ms- web3_id- web3_alg |
Example
import asyncio
import signal
import time
import struct
from eth_account import Account, messages
from jsonrpc_websocket import Server
# Replace with your Ethereum private key (without "0x" prefix)
private_key = "0FBAF463D26EF8DDFA03366ACF0B42B461C2B4F816D5EEECA778E6AB1C716B6C"
account = Account.from_key(private_key)
ws_url = "wss://dex-ws.pepe.team/private"
ts_ms = int(time.time() * 1000)
web3_id = account.address
sig_alg = 2 # EVM
signature_data_bytes = struct.pack('>q', ts_ms) + bytes.fromhex(web3_id[2:]) + struct.pack('>q', sig_alg)
signed_message = account.sign_message(messages.encode_defunct(signature_data_bytes))
signature = '0x' + signed_message.signature.hex()
def handler(subscription, result):
print(subscription, result)
async def routine(url):
server = Server(url)
try:
await server.ws_connect()
server.o = handler
server.to = handler
subscribtion_id = await server.auth(web3_id, ts_ms, sig_alg, signature)
await asyncio.wait([asyncio.Future()])
except asyncio.CancelledError:
await server.logout(subscribtion_id)
finally:
await server.close()
event_loop = asyncio.new_event_loop()
asyncio.set_event_loop(event_loop)
main_task = asyncio.ensure_future(routine(ws_url))
event_loop.add_signal_handler(signal.SIGINT, main_task.cancel)
event_loop.add_signal_handler(signal.SIGTERM, main_task.cancel)
try:
event_loop.run_until_complete(main_task)
finally:
event_loop.close()
const jayson = require('jayson');
const ethers = require('ethers');
const privateKey = "0FBAF463D26EF8DDFA03366ACF0B42B461C2B4F816D5EEECA778E6AB1C716B6C";
const wallet = new ethers.Wallet(privateKey);
const url = "wss://dex-ws.pepe.team/private"
const tsMs = Date.now();
const web3Id = wallet.address;
const sigAlg = 2; // EVM
const messageBytes = Buffer.alloc(8 + 20 + 8); // (timestamp + address + algorithm ID)
messageBytes.writeBigInt64BE(BigInt(tsMs), 0);
Buffer.from(web3Id.slice(2), "hex").copy(messageBytes, 8);
messageBytes.writeBigInt64BE(BigInt(sigAlg), 8 + 20);
const signedMessage = wallet.signMessage(messageBytes);
(async () => {
const client = jayson.client.websocket({ url });
client.ws.on('open', async function () {
client.request('auth', [web3Id, tsMs, sigAlg, await signedMessage], () => { });
});
client.ws.on('message', console.log)
})();
Response¶
Notification¶
OrderUpdate
Field |
Type | Description |
|---|---|---|
object |
JsonRPC notification | |
jsonrpc |
string |
JsonRPC version |
method |
"o" |
JsonRPC method name |
params |
object |
JsonRPC parameters |
subscription |
number |
Subscription ID |
result |
object |
Order update notification |
s |
string |
Symbol name (e.g ETH-USDT) |
U |
number |
Order update unixtime in ms |
i |
string |
Order Id |
S |
"BUY" | "SELL" |
Order side |
o |
"LIMIT" |
Order type |
p |
string |
Order price |
q |
string |
Order quantity in base asset |
st |
"ACCEPTED" | "PLACED" | "PARTIALLY_CANCELLED" | "CANCELLED" | "EXPIRED" | "EXPIRED_IN_MATCH" | "REJECTED" |
Order state |
TradedOrderUpdate
Field |
Type | Description |
|---|---|---|
object |
JsonRPC notification | |
jsonrpc |
string |
JsonRPC version |
method |
"to" |
JsonRPC method name |
params |
object |
JsonRPC parameters |
subscription |
number |
Subscription ID |
result |
object |
Traded Order update notification |
s |
string |
Symbol name (e.g ETH-USDT) |
U |
number |
Order update unixtime in ms |
i |
string |
Order Id |
S |
"BUY" | "SELL" |
Order side |
o |
"LIMIT" |
Order type |
p |
string |
Order price |
q |
string |
Order quantity in base asset |
st |
"FILLED" | "PARTIALLY_FILLED" |
Order state |
fb |
string |
Filled order quantity in base asset |
fq |
string |
Filled order quantity in quote asset |
ff |
string |
Filled order fee quantity in base asset |
fa |
string |
Fee asset name (e.g ETH) |
Example
{
"jsonrpc": "2.0",
"method": "to",
"params": {
"subscription": 4192341877843937,
"result": {
"s": "WBTC-USDT",
"U": 1742313804800,
"i": "56d720ed-0376-474c-bcee-c98d38a02f3a",
"S": "BUY",
"o": "LIMIT",
"p": "81946.2",
"q": "0.00012",
"st": "FILLED",
"fb": "0.00012",
"fq": "9.833544",
"ff": "0.00000012",
"fa": "WBTC"
}
}
}
Logout¶
Request¶
Parameters
| Parameter | Type | Description |
|---|---|---|
object |
JsonRPC request | |
jsonrpc |
"2.0" |
JsonRPC version |
id |
number |
JsonRPC request Id |
method |
"logout" |
JsonRPC method name |
params |
array |
JsonRPC params |
subscription |
string |
Subscription ID |
Example
import asyncio
import signal
import time
import struct
from eth_account import Account, messages
from jsonrpc_websocket import Server
# Replace with your Ethereum private key (without "0x" prefix)
private_key = "0FBAF463D26EF8DDFA03366ACF0B42B461C2B4F816D5EEECA778E6AB1C716B6C"
account = Account.from_key(private_key)
ws_url = "wss://dex-ws.pepe.team/private"
ts_ms = int(time.time() * 1000)
web3_id = account.address
sig_alg = 2 # EVM
signature_data_bytes = struct.pack('>q', ts_ms) + bytes.fromhex(web3_id[2:]) + struct.pack('>q', sig_alg)
signed_message = account.sign_message(messages.encode_defunct(signature_data_bytes))
signature = '0x' + signed_message.signature.hex()
def handler(subscription, result):
print(subscription, result)
async def routine(url):
server = Server(url)
try:
await server.ws_connect()
server.o = handler
server.to = handler
subscribtion_id = await server.auth(web3_id, ts_ms, sig_alg, signature)
await asyncio.wait([asyncio.Future()])
except asyncio.CancelledError:
await server.logout(subscribtion_id)
finally:
await server.close()
event_loop = asyncio.new_event_loop()
asyncio.set_event_loop(event_loop)
main_task = asyncio.ensure_future(routine(ws_url))
event_loop.add_signal_handler(signal.SIGINT, main_task.cancel)
event_loop.add_signal_handler(signal.SIGTERM, main_task.cancel)
try:
event_loop.run_until_complete(main_task)
finally:
event_loop.close()
const jayson = require('jayson');
const ethers = require('ethers');
const privateKey = "0FBAF463D26EF8DDFA03366ACF0B42B461C2B4F816D5EEECA778E6AB1C716B6C";
const wallet = new ethers.Wallet(privateKey);
const url = "wss://dex-ws.pepe.team/private"
const tsMs = Date.now();
const web3Id = wallet.address;
const sigAlg = 2; // EVM
const messageBytes = Buffer.alloc(8 + 20 + 8); // (timestamp + address + algorithm ID)
messageBytes.writeBigInt64BE(BigInt(tsMs), 0);
Buffer.from(web3Id.slice(2), "hex").copy(messageBytes, 8);
messageBytes.writeBigInt64BE(BigInt(sigAlg), 8 + 20);
const signedMessage = wallet.signMessage(messageBytes);
(async () => {
const client = jayson.client.websocket({ url });
client.ws.on('open', async function () {
client.request('auth', [web3Id, tsMs, sigAlg, await signedMessage], () => { });
});
client.ws.on('message', console.log)
})();