Authentication
Authentication
Dipcoin Perpetual API uses JWT (JSON Web Token) for authentication.
Authentication Flow
- Get JWT Token: Call the authentication interface with wallet signature to get Token
- Carry Token: Include Token in request headers for subsequent requests
Request Headers
Private Interface Request Headers
| Name | Type | Required | Description |
|---|---|---|---|
Authorization |
string | Yes | JWT Token, format: Bearer {token} |
X-Wallet-Address |
string | Yes | Wallet address |
Note
- Token must be passed in the request header in the format
Bearer {token} X-Wallet-Addressmust be the wallet address used for signing- Token has an expiration time, need to re-obtain after expiration
Authentication Example
1. Get JWT Token
POST /api/authorize
Content-Type: application/json
{
"userAddress": "0xab7f6e97232d633689cf762989455cceb769587c69a9f09a23f537f5605f9e78",
"signature": "77ac25a7a4e9c686447788d65e06366f11cc8d064fb2f8585bbce7b06cbd29b398f7b231cd4f838818688057236c9be2572b825d7d2b2d141594e7cffc98e40a1zTNoZKsgPhuhbBmPoAeD/D+135wtLJbw7luX1Nftd+M=",
"isTermAccepted": true
}
Response:
{
"code": 200,
"message": "success",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"walletAddress": "0xab7f6e97232d633689cf762989455cceb769587c69a9f09a23f537f5605f9e78"
}
}
2. Use Token to Call Private Interface
GET /api/perp-trade-api/curr-info/account
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
X-Wallet-Address: 0xab7f6e97232d633689cf762989455cceb769587c69a9f09a23f537f5605f9e78
Signature Description
The authentication interface requires wallet signature. JWT Token will only be generated after signature verification passes.
Tip
Signature requires using Sui wallet to sign a specific message. For specific signing methods, please refer to the wallet SDK documentation.