Getting started
Quickstart
This page walks through a complete order with an SDK: quote, create, look up, and receive status callbacks.
1. Create an API key
- Sign up and log in at speed.cc.
- Open “API” from the avatar menu at the top right and click “New key”.
- Enter a callback URL (for status callbacks) and an IP whitelist (your server's outbound IPs are recommended).
- Save the API key and Secret that appear. The Secret is shown only once — store it somewhere safe right away.
Keep the Secret on your server only. Never put it in web pages, apps or any code that ships to user devices.
2. Install an SDK
Download the package for your language from the SDKs page.
npm install ./speed-sdk-js-1.0.0.tgzpip install ./speed_sdk-1.0.0-py3-none-any.whlrequire 'speed-sdk-php/autoload.php';mvn install # run inside speed-sdk-java, then add the dependency to your project:
<dependency><groupId>cc.speed</groupId><artifactId>speed-sdk</artifactId><version>1.0.0</version></dependency>// go.mod
require github.com/speed-cc/speed-sdk-go v1.0.0
replace github.com/speed-cc/speed-sdk-go => ./third_party/speed-sdk-go3. Get a quote
const { SpeedClient } = require('speed-sdk')
const speed = new SpeedClient({
apiKey: process.env.SPEED_API_KEY,
apiSecret: process.env.SPEED_API_SECRET
})
const quote = await speed.rate({ from: 'USDT', fromNetwork: 'TRC20', to: 'BTC', toNetwork: 'Bitcoin', amount: '1000' })
console.log(quote.receiveAmount) // estimated amount received, after all feesimport os
from speed_sdk import SpeedClient
speed = SpeedClient(api_key=os.environ["SPEED_API_KEY"], api_secret=os.environ["SPEED_API_SECRET"])
quote = speed.rate("USDT", "TRC20", "BTC", "Bitcoin", "1000")
print(quote["receiveAmount"]) # estimated amount received, after all fees$speed = new \Speed\Sdk\SpeedClient([
'apiKey' => getenv('SPEED_API_KEY'),
'apiSecret' => getenv('SPEED_API_SECRET'),
]);
$quote = $speed->rate(['from' => 'USDT', 'fromNetwork' => 'TRC20', 'to' => 'BTC', 'toNetwork' => 'Bitcoin', 'amount' => '1000']);
echo $quote['receiveAmount'];SpeedClient speed = SpeedClient.builder()
.apiKey(System.getenv("SPEED_API_KEY"))
.apiSecret(System.getenv("SPEED_API_SECRET"))
.build();
Rate quote = speed.rate("USDT", "TRC20", "BTC", "Bitcoin", "1000");
System.out.println(quote.getReceiveAmount());client, err := speed.NewClient(speed.Config{
APIKey: os.Getenv("SPEED_API_KEY"),
APISecret: os.Getenv("SPEED_API_SECRET"),
})
quote, err := client.Rate(ctx, speed.RateRequest{
From: "USDT", FromNetwork: "TRC20", To: "BTC", ToNetwork: "Bitcoin", Amount: "1000",
})
fmt.Println(quote.ReceiveAmount)4. Create an order
Set clientOrderId to the order ID in your own system. If a request times out, retry with the same clientOrderId and you get the same order back.
const order = await speed.createOrder({
fromCurrency: 'USDT', fromNetwork: 'TRC20',
toCurrency: 'BTC', toNetwork: 'Bitcoin',
amount: '1000',
recipientAddress: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
clientOrderId: 'shop-1001'
})
// Ask the user to send order.sendAmount USDT (TRC20) to order.depositAddressorder = speed.create_order(
from_currency="USDT", from_network="TRC20",
to_currency="BTC", to_network="Bitcoin",
amount="1000",
recipient_address="bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
client_order_id="shop-1001",
)
print(order["depositAddress"], order["sendAmount"])$order = $speed->createOrder([
'fromCurrency' => 'USDT', 'fromNetwork' => 'TRC20',
'toCurrency' => 'BTC', 'toNetwork' => 'Bitcoin',
'amount' => '1000',
'recipientAddress' => 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
'clientOrderId' => 'shop-1001',
]);
echo $order['depositAddress'];Order order = speed.createOrder(CreateOrderRequest.builder()
.fromCurrency("USDT").fromNetwork("TRC20")
.toCurrency("BTC").toNetwork("Bitcoin")
.amount("1000")
.recipientAddress("bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh")
.clientOrderId("shop-1001")
.build());
System.out.println(order.getDepositAddress());order, err := client.CreateOrder(ctx, speed.CreateOrderRequest{
FromCurrency: "USDT", FromNetwork: "TRC20",
ToCurrency: "BTC", ToNetwork: "Bitcoin",
Amount: "1000",
RecipientAddress: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
ClientOrderID: "shop-1001",
})
fmt.Println(order.DepositAddress, order.SendAmount)Show depositAddress, sendAmount (and depositMemo, if present) to the user and ask them to pay before expireAt.
5. Receive status callbacks
When an order's status changes we send a POST request to your callback URL. Always verify using the raw request body.
const express = require('express')
const { verifyWebhook } = require('speed-sdk')
const app = express()
app.post('/speed/webhook', express.raw({ type: 'application/json' }), (req, res) => {
let event
try {
event = verifyWebhook(process.env.SPEED_API_SECRET, req.get('X-SPEED-TIMESTAMP'), req.get('X-SPEED-SIGN'), req.body)
} catch (e) {
return res.status(401).send('bad signature')
}
if (event.event === 'order.status') {
// update your order using event.order.clientOrderId
}
res.send('ok')
})from flask import Flask, request
from speed_sdk import verify_webhook, SpeedWebhookError
app = Flask(__name__)
@app.post("/speed/webhook")
def speed_webhook():
try:
event = verify_webhook(SECRET, request.headers.get("X-SPEED-TIMESTAMP"),
request.headers.get("X-SPEED-SIGN"), request.get_data())
except SpeedWebhookError:
return "bad signature", 401
if event["event"] == "order.status":
pass # update your order using event["order"]["clientOrderId"]
return "ok"use Speed\Sdk\Webhook;
use Speed\Sdk\SpeedWebhookException;
$raw = file_get_contents('php://input');
try {
$event = Webhook::verify(getenv('SPEED_API_SECRET'),
$_SERVER['HTTP_X_SPEED_TIMESTAMP'] ?? '', $_SERVER['HTTP_X_SPEED_SIGN'] ?? '', $raw);
} catch (SpeedWebhookException $e) {
http_response_code(401);
exit('bad signature');
}
if ($event['event'] === 'order.status') {
// update your order using $event['order']['clientOrderId']
}
echo 'ok';server.createContext("/speed/webhook", ex -> {
byte[] raw = ex.getRequestBody().readAllBytes();
int code = 200;
try {
WebhookEvent ev = Webhooks.verify(secret, ex.getRequestHeaders().getFirst("X-SPEED-TIMESTAMP"),
ex.getRequestHeaders().getFirst("X-SPEED-SIGN"), raw, 300);
if ("order.status".equals(ev.getEvent())) {
// update your order using ev.getOrder().getClientOrderId()
}
} catch (SpeedWebhookException e) {
code = 401;
}
ex.sendResponseHeaders(code, -1);
ex.close();
});http.HandleFunc("/speed/webhook", func(w http.ResponseWriter, r *http.Request) {
body, _ := io.ReadAll(io.LimitReader(r.Body, 1<<20))
ev, err := speed.VerifyWebhook(os.Getenv("SPEED_API_SECRET"),
r.Header.Get("X-SPEED-TIMESTAMP"), r.Header.Get("X-SPEED-SIGN"), body, 5*time.Minute)
if err != nil {
http.Error(w, "bad signature", http.StatusUnauthorized)
return
}
if ev.Event == "order.status" {
// update your order using ev.Order.ClientOrderID
}
w.WriteHeader(http.StatusOK)
})Click “Test callback” under “API” to send a ping event to your callback URL and confirm verification works.
Go-live checklist
- The Secret is stored only on your server and is not committed to source control.
- An IP whitelist is configured.
- Every order has a unique
clientOrderId, and timeouts are retried with the same value. - All amounts are handled as strings and never converted to floating point.
- Callbacks are verified with the raw request body, and you return HTTP 2xx after processing.
- Callback handling is idempotent: a repeated event never books twice.
- You handle
ACTION_REQUIRED,ON_HOLD,EXPIREDand other non-happy-path states. - For networks with
depositMemo, your UI clearly tells users to include the memo. - On
42900you slow down and back off before retrying.
Need help with your integration? Contact support: [email protected]