Overview
The Transak API Client SDK provides a simple and efficient way to integrate with the Transak API for cryptocurrency and fiat transactions. This SDK allows developers to:
- Fetch cryptocurrency & fiat currency data
- Get quotes for transactions
- Manage user authentication (email OTP verification)
- Submit multi-level KYC
- Reserve wallets and create orders
- Fetch order details and transaction statuses
The SDK is structured to follow best practices and provides a clean, modular interface for seamless API integration.
Installation
npm install @transak/api-client
Configuration & Setup
1️⃣ Import the SDK & Initialize with API Key & Environment
const { TransakAPI } = require('@transak/api-client');
const transak = new TransakAPI({
environment: 'staging',
partnerApiKey: 'your-api-key'
});
Note: The SDK supports both Staging and Production environments.
Authentication
Getting Started
To use this function, you must first request a frontendAuth
& ****partnerApiKey
Key from Transak. You can obtain it by reaching out to: Sales Team: sales@transak.com. Once you receive your Partner API key and Frontend Auth token, you can pass them in the request along with the user’s email address.
How It Works
- The email OTP request is user-centric—Transak sends a one-time password (OTP) to the user’s email.
- The user enters the OTP in your application.
- You verify the OTP using verifyEmailOtp to obtain an access token.
- Once authenticated, you can proceed with further actions like KYC verification, order placement, etc..
Send Email OTP
The sendEmailOtp
function is a non-authenticated API method that allows you to initiate user authentication by sending an OTP to the provided email address.
Example Usage
await transak.user.sendEmailOtp({ email: 'user@example.com', frontendAuth: 'your-frontend-auth' });
Response Output Fields:
{ "isTncAccepted": "boolean" }
Verify Email OTP
The verifyEmailOtp
is a non-authenticated API that allows you to verify a user’s email using an OTP and retrieve an access token in return.
Once you have successfully called sendEmailOtp
, you need to pass the email verification code along with the user’s email to verify the OTP.
Access Token Usage
- This access token is required for all authenticated API calls (such as placing orders, fetching user details, and submitting KYC).
- This access token remains valid for 30 days from the time of generation. Once expired, the user must restart the authentication process by requesting a new OTP.
Example Usage
const response = await transak.user.verifyEmailOtp({
email: 'user@example.com',
emailVerificationCode: '123456'
});
console.log(response);
Response Output Fields:
{
"id": "string",
"ttl": "number",
"created": "string",
"userId": "string"
}
Cryptocurrency, Fiat & Quote Data
Fetch Crypto Currencies
getCryptoCurrencies
helps you fetch the list of supported cryptocurrencies along with high-level data, including the cryptocurrency name, symbol, and whether it is allowed for transactions. This is a public API endpoint, so no authentication is required.
Example Usage
const cryptos = await transak.public.getCryptoCurrencies();
console.log(cryptos);
Fetch Fiat Currencies
getFiatCurrencies
allows you to fetch the list of supported fiat currencies along with their respective supported countries, payment methods, and transaction limits. Since different payment methods have varying transaction limits, this API provides details on the limits applicable for each fiat currency. This is a public API endpoint, so no authentication is required.
Example Usage
const fiats = await transak.public.getFiatCurrencies();
console.log(fiats);
Fetch Quote
getQuote
is a public API call that allows you to fetch a temporary price quote for a cryptocurrency transaction based on the selected fiat currency, cryptocurrency, payment method, and transaction amount. Since cryptocurrency prices are volatile, the returned quote is refreshed every minute to reflect the latest market price.
After fetching the supported cryptocurrencies and fiat currencies, you must call getQuote to get the latest exchange rate. This quote is critical for KYC verification and order placement:
KYC Process:
- The quote ID must be passed when calling
getKycForms().
- Based on the order amount, the user may be required to complete different KYC tiers (Simple KYC, Standard KYC).
Order Placement:
- The quote ID is also required when calling
createOrder().
- At the time of payment settlement, Transak sends the exact amount of cryptocurrency based on the latest exchange rate at that moment.
Thus, getQuote
plays a vital role in the entire order flow, from KYC verification to order execution.
Example Usage
const quoteData = await transak.public.getQuote({
"fiatCurrency": "EUR",
"cryptoCurrency": "USDC",
"paymentMethod": "sepa_bank_transfer",
"isBuyOrSell": "BUY",
"fiatAmount": 30,
"partnerApiKey": "string",
"network": "arbitrum",
"quoteCountryCode": "FR"
});
Response Output Fields
{
"quoteId": "string",
"conversionPrice": "number",
"fiatCurrency": "string",
"cryptoCurrency": "string",
"paymentMethod": "string",
"fiatAmount": "number",
"cryptoAmount": "number",
"isBuyOrSell": "string",
"network": "string",
"feeDecimal": "number",
"totalFee": "number",
"feeBreakdown": [
{
"name": "string",
"value": "number",
"id": "string",
"ids": "array"
}
],
"nonce": "number"
}
User Auth & KYC
Get User Details
getUser
is an authenticated API call that allows you to fetch the user details of the authenticated user. Since authentication has already been completed, the access token is automatically stored in the SDK’s session, so you don’t need to pass it explicitly. Simply calling getUser()
will return the user details if authenticated; otherwise, it will throw an error indicating that the access token is not valid or has expired.
Example Usage
const user = await transak.user.getUser();
console.log(user);
Response Output Fields & User Schema
{
"id": "string",
"firstName": "string | null",
"lastName": "string | null",
"email": "string",
"mobileNumber": "string | null",
"status": "string",
"dob": "string | null",
"kyc": {
"status": "string",
"type": "string | null",
"updatedAt": "string",
"kycSubmittedAt": "string | null"
},
"address": {
"addressLine1": "string",
"addressLine2": "string",
"state": "string",
"city": "string",
"postCode": "string",
"country": "string",
"countryCode": "string"
}
"createdAt": "string"
}
Get KYC Forms - Fetch Required KYC Forms Based on Quote ID
getKycForms
is an authenticated API call that dynamically returns the KYC forms a user needs to complete based on the quote ID. Since Transak supports multi-level KYC across different countries, this API helps determine the exact KYC requirements for a user before proceeding with transactions.
The quote ID must be passed when calling this API, as it determines the required KYC level (Simple KYC, Standard KYC, etc.). The response includes a list of required KYC forms, such as:
- Personal Details → Includes firstName, lastName, email, and mobileNumber.
- Address Details → User’s residential details.
- Purpose of Usage → Required for compliance with Transak’s regulations.
- ID Proof → Only required for Standard KYC. If the user is under Simple KYC, ID proof is not required.
As per the quote ID, the system dynamically returns the appropriate KYC forms for the user to complete.
Example Usage
const kycForms = await transak.user.getKycForms({ quoteId });
Response Output Fields & User Schema
{
"kycType": "string",
"formIds": "array"
}
Patch User - Update User’s Personal or Address Details
patchUser
is an authenticated API call that allows updating a user’s personal details or address details. The response follows the same schema as getUser()
, returning the updated user profile.
The fields that can be updated via patchUser include:
- Personal Details: firstName, lastName, mobileNumber, dob
- Address Details: Address-related fields fetched via getKycForms()
Any modifications to user data must comply with KYC requirements, and certain updates may require the user to re-submit verification documents.
await transak.user.patchUser({
firstName: 'John',
lastName: 'Doe',
mobileNumber: '1234567890',
dob: '1990-01-01'
});
Fetch ID Proof KYC Form
const idProofForm = await transak.user.getKycFormsById({ formId: 'idProof', quoteId: 'abcd-1234' });
console.log(idProofForm);
Response Output Fields:
{
"formId": { "type": "string", "isRequired": true },
"formName": { "type": "string", "isRequired": true },
"kycUrl": { "type": "string", "isRequired": true },
"expiresAt": { "type": "string", "isRequired": true }
}
Orders
Fetch Order Details
const orderDetails = await transak.order.getOrderById({ orderId: 'abcd-5678' });
console.log(orderDetails);
Response Output Fields:
{
"id": "string",
"userId": "string",
"status": "string",
"isBuyOrSell": "string",
"fiatCurrency": "string",
"cryptoCurrency": "string",
"paymentMethod": "string",
"network": "string",
"walletAddress": "string",
"addressAdditionalData": "boolean",
"quoteId": "string",
"fiatAmount": "number",
"fiatAmountInUsd": "number",
"amountPaid": "number",
"cryptoAmount": "number",
"conversionPrice": "number",
"totalFeeInFiat": "number",
"paymentOptions": [
{
"currency": "string",
"id": "string",
"name": "string",
"fields": [ { "name": "string", "value": "string"}, { "name": "string", "value": "string"} ]
}
],
"transactionHash": "string",
"createdAt": "string",
"updatedAt": "string",
"completedAt": "string",
"statusHistories": [
{
"status": "string",
"createdAt": "string"
}
]
}
Error Handling
All API calls return structured responses. If an API call fails, the SDK throws an error object:
try {
const order = await transak.order.getOrderById({ orderId: 'abcd-5678' });
} catch (error) {
console.error(error.message);
console.error(error.details);
}
License
This SDK is licensed under the MIT License.