KuCoin TypeScript SDK example: authorizationHeader.ts
KuCoin Auth authorization header example for the Siebly KuCoin SDK, with TypeScript source for exchange REST API and WebSocket integration, setup, and production SDK docs.
What This Example Covers
- KuCoin authentication and request-signing example in TypeScript.
- Uses the Siebly KuCoin SDK package
kucoin-apiinstead of hand-written signing code. - Source path:
Kucoin/Auth/authorizationHeader.ts. - Example category: Auth.
- Imports SDK symbols including
SpotClient. - Calls SDK methods such as
getBalances(),setAccessToken().
How To Use This Example
- Start here for the specific request or stream pattern, then check the matching SDK guide for install, credentials, and operational notes.
- For private or order-management examples, keep credentials in environment variables or a secret manager. Use read-only keys where possible, and check the execution mode reference before any exchange write path can run.
- Open the repository source when you need the latest committed version: GitHub source file.
Example Path
Kucoin/Auth/authorizationHeader.ts
Source Link
Repository source: https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Kucoin/Auth/authorizationHeader.ts
Related SDK Docs
Example Source
import { SpotClient } from 'kucoin-api';
async function start() {
/**
* All REST clients support passing the access token. If available, sign will be skipped for the request and the access token will instead be used via an authorization header.
*
* More details: https://github.com/tiagosiebler/kucoin-api/issues/2
*/
const client = new SpotClient({
apiAccessToken: 'accessTokenHere!',
});
try {
const result = await client.getBalances();
console.log('result ', JSON.stringify(result, null, 2));
} catch (e) {
console.error('Req error: ', e);
}
// If you later need to set a new access token (e.g. it expired):
client.setAccessToken('newAccessTokenHere');
}
start();