Lattency API Documentation
Low-latency Solana trading and utility API built in Rust (Actix Web).
Response Format: All responses include a code string and message (success: message, error: error).
Authentication
Requests use wallet keys in the payload. private_key is required for trade and transfer to sign transactions. For trade-local, the key is used only to derive user_pubkey and the transaction is returned unsigned.
Security Tip: We recommend using a dedicated "trading wallet" for your bot instead of your main vault wallet.
Quick Start
Send JSON requests to the public API endpoint.
- Base URL:
http://api.lattency.com:8080 - Base path:
/v1 - Content-Type:
application/json - Methods: Use the endpoints below for trading, transfers, balances, and logs.
API Conventions
- Base path:
/v1 - Response shape: All responses include a code string and message (success: message, error: error).
- Flexible booleans:
denominatedInSol,ultraLowLatency,closeAccountaccept true/false, "true"/"false", or 1/0. - Amount parsing: amount may be a number or string. Percent values are not supported.
system Health
Simple health check.
Error Responses
| Code | HTTP | Message | When |
|---|---|---|---|
7001 | 500 | Internal server error | Unexpected server failure. |
Health
curl -s "http://api.lattency.com:8080/v1/health"application/json
{
"code": "2000",
"message": "Service is healthy and operational",
"status": "ok",
"latencyServer": 12.3,
"latencyOnChainConfirmation": null
}trade Trade Local
Builds an unsigned transaction (no on-chain send).
Attributes
publicKey string | Wallet public key used to identify the user. |
action string | Trade action: buy or sell. |
mint string | Token mint address. |
amount string|number | Amount to trade (token units or SOL depending on denominatedInSol). |
slippage number | Maximum slippage tolerance as a percent. |
priorityFee number | Priority fee in SOL for the built transaction. |
denominatedInSol boolean|string|integer | When true, amount is in SOL instead of token units. |
ultraLowLatency boolean|string|integer | Optional; when true, uses the low-latency sender path and tip. Defaults to false. |
pool string | Protocol ID, pool ID, or auto for latest. |
closeAccount boolean|string|integer | Optional; when true on sell, closes the token account after selling. Defaults to false. |
apiKey string | Optional API key for fee exemptions or rate limits. |
Notes
- publicKey identifies the wallet; the transaction remains unsigned.
- ultraLowLatency and closeAccount are optional and default to false.
- Invalid mint addresses return code 4003.
Error Responses
| Code | HTTP | Message | When |
|---|---|---|---|
4007 | 400 | Missing required field | publicKey is not provided. |
4001 | 400 | Invalid public key format | publicKey is not a valid public key. |
4003 | 400 | Invalid mint address | mint is not a valid public key. |
4005 | 400 | Invalid action. Must be "buy" or "sell" | closeAccount is true while action is not sell. |
5006 | 500 | RPC node error | RPC request fails while building the unsigned transaction. |
7001 | 500 | Internal server error | Unexpected server failure. |
Trade Local
curl -s "http://api.lattency.com:8080/v1/trade-local" \ -H "Content-Type: application/json" \ -d '{"publicKey":"wallet pubkey","action":"buy","mint":"token mint address","amount":10,"slippage":25.0,"priorityFee":0.001,"denominatedInSol":false,"ultraLowLatency":false,"pool":"auto","closeAccount":false}'application/json
{
"code": "2004",
"message": "Trade transaction built successfully",
"tx_bytes_base64": "" ,
"latencyServer": 95.7,
"latencyOnChainConfirmation": null
}trade Trade
Signs and submits a trade transaction on-chain.
Attributes
privateKey string | Base58-encoded secret key for the sender wallet. |
action string | Trade action: buy or sell. |
mint string | Token mint address. |
amount string|number | Amount to trade (token units or SOL depending on denominatedInSol). |
slippage number | Maximum slippage tolerance as a percent. |
priorityFee number | Priority fee in SOL for the trade transaction. |
denominatedInSol boolean|string|integer | When true, amount is in SOL instead of token units. |
ultraLowLatency boolean|string|integer | Optional; when true, uses the low-latency sender path and tip. Defaults to false. |
pool string | Protocol ID, pool ID, or auto for latest. |
closeAccount boolean|string|integer | Optional; when true on sell, closes the token account after selling. Defaults to false. |
apiKey string | Optional API key for fee exemptions or rate limits. |
Notes
- Developer fee of 0.25% is applied unless apiKey matches the exemption key.
- ultraLowLatency is optional; when true it uses the low-latency sender and adds a 0.0002 SOL tip. Defaults to false.
- closeAccount is optional, defaults to false, and is only valid for sell.
- ws_status indicates websocket confirmation state; on timeout, a fallback on-chain query is used.
- Invalid mint addresses return code 4003.
Error Responses
| Code | HTTP | Message | When |
|---|---|---|---|
4007 | 400 | Missing required field | Request JSON is invalid or required fields are missing. |
4001 | 400 | Invalid public key format | privateKey cannot be decoded or keypair is invalid. |
4003 | 400 | Invalid mint address | mint is not a valid public key. |
4005 | 400 | Invalid action. Must be "buy" or "sell" | closeAccount is true while action is not sell. |
5001 | 500 | Insufficient balance for transaction | Wallet balance is too low to execute the trade. |
5003 | 504 | Transaction confirmation on-chain timed out | WebSocket confirmation timed out without fallback data. |
5006 | 500 | RPC node error | RPC request fails during send or confirmation. |
6001 | 500 | Slippage tolerance exceeded | Price moved beyond slippage. |
6002 | 500 | Liquidity pool not found | No pool exists for the mint/pool selection. |
6003 | 500 | Insufficient liquidity in pool | Pool cannot fill the trade amount. |
7006 | 500 | Trade details unavailable | Trade succeeded but detailed info could not be retrieved. |
7001 | 500 | Internal server error | Unexpected server failure. |
Trade
curl -s "http://api.lattency.com:8080/v1/trade" \ -H "Content-Type: application/json" \ -d '{"privateKey":"base58-encoded secret key","action":"buy","mint":"token mint address","amount":10,"slippage":25.0,"priorityFee":0.001,"denominatedInSol":false,"ultraLowLatency":false,"pool":"auto","closeAccount":false}'application/json
{
"code": "2003",
"message": "Trade executed successfully",
"signature": "" ,
"mint": "" ,
"operation": "buy|sell",
"token_amount": "123.456",
"solana_amount": "0.123456789",
"protocol": "pumpfun_amm",
"ws_status": "ws_timeout | api_fallback | ws_stream_ended | null",
"latencyServer": 210.4,
"latencyOnChainConfirmation": 180.2
}utility Transfer
Transfers SOL from the provided private key to a receiver.
Attributes
privateKey string | Base58-encoded secret key for the sender wallet. |
receiverPubkey string | Destination wallet public key. |
lamports integer | Amount to transfer in lamports. |
priorityFee number | Optional priority fee in SOL for the transaction. |
Notes
- priorityFee is specified in SOL and converted to a compute-unit price.
Error Responses
| Code | HTTP | Message | When |
|---|---|---|---|
4001 | 400 | Invalid public key format | privateKey cannot be decoded or keypair is invalid. |
4002 | 400 | Invalid receiver public key | receiverPubkey is not a valid public key. |
5001 | 500 | Insufficient balance for transaction | Wallet balance is too low. |
5006 | 500 | RPC node error | RPC request fails during send. |
7001 | 500 | Internal server error | Unexpected server failure. |
Transfer
curl -s "http://api.lattency.com:8080/v1/transfer" \ -H "Content-Type: application/json" \ -d '{"privateKey":"base58-encoded secret key","receiverPubkey":"receiver pubkey","lamports":1000000,"priorityFee":0.000001}'application/json
{
"code": "2001",
"message": "Transfer completed successfully",
"signature": "" ,
"latencyServer": 42.1,
"latencyOnChainConfirmation": null
}utility Transfer Batch
Transfers SOL to multiple recipients in one transaction.
Attributes
privateKey string | Base58-encoded secret key for the sender wallet. |
recipients array | List of recipients with pubkey and lamports fields. |
priorityFee number | Optional priority fee in SOL for the transaction. |
Notes
- priorityFee is specified in SOL and converted to a compute-unit price.
Error Responses
| Code | HTTP | Message | When |
|---|---|---|---|
4001 | 400 | Invalid public key format | privateKey or a recipient pubkey is invalid. |
5001 | 500 | Insufficient balance for transaction | Wallet balance is too low. |
5006 | 500 | RPC node error | RPC request fails during send. |
7001 | 500 | Internal server error | Unexpected server failure. |
Transfer Batch
curl -s "http://api.lattency.com:8080/v1/transfer-batch" \ -H "Content-Type: application/json" \ -d '{"privateKey":"base58-encoded secret key","recipients":[{"pubkey":"...","lamports":500000},{"pubkey":"...","lamports":300000}],"priorityFee":0.000002}'application/json
{
"code": "2002",
"message": "Batch transfer completed successfully",
"signature": "" ,
"latencyServer": 55,
"latencyOnChainConfirmation": null
}utility Get Balance
Returns SOL or SPL token balance for a wallet.
Attributes
publicKey string | Wallet public key to query. |
mint string | Token mint to query (use SOL mint for SOL balance). |
Notes
- For SPL tokens, balance is normalized to 6 decimals (UI balance).
- Returns "0" if no token account is found (standard or Token2022).
Error Responses
| Code | HTTP | Message | When |
|---|---|---|---|
4001 | 400 | Invalid public key format | publicKey is not a valid public key. |
4003 | 400 | Invalid mint address | mint is not a valid public key. |
5006 | 500 | RPC node error | RPC request fails during balance lookup. |
7001 | 500 | Internal server error | Unexpected server failure. |
Get Balance
curl -s "http://api.lattency.com:8080/v1/get-balance" \ -H "Content-Type: application/json" \ -d '{"publicKey":"wallet pubkey","mint":"So11111111111111111111111111111111111111112"}'application/json
{
"code": "2005",
"message": "Balance retrieved successfully",
"balance": "1.523456789",
"latencyServer": 8.6,
"latencyOnChainConfirmation": null
}utility Get Tokens
Returns token holdings (standard SPL + Token2022).
Attributes
publicKey string | Wallet public key to list token holdings for. |
Notes
- balance is the raw token amount (string) and decimals indicates precision.
- Zero-balance token accounts are omitted.
Error Responses
| Code | HTTP | Message | When |
|---|---|---|---|
4001 | 400 | Invalid public key format | publicKey is not a valid public key. |
5006 | 500 | RPC node error | RPC request fails during token lookup. |
7001 | 500 | Internal server error | Unexpected server failure. |
Get Tokens
curl -s "http://api.lattency.com:8080/v1/get-tokens" \ -H "Content-Type: application/json" \ -d '{"publicKey":"wallet pubkey"}'application/json
{
"code": "2006",
"message": "Tokens retrieved successfully",
"tokens": [
{
"mint": "...",
"balance": "100.5",
"decimals": 6
}
],
"latencyServer": 14.2,
"latencyOnChainConfirmation": null
}Error Codes
Errors return a string code and a human-readable message.
ERROR RESPONSE SCHEMA
{
"code": "4001",
"error": "invalid_action",
"message": "action must be buy or sell"
}- validation (4xxx)
- blockchain (5xxx)
- trade (6xxx)
- server (7xxx)
- auth (8xxx)
- network (9xxx)