New Now we support Meteora Protocol integration with unified liquidity.

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, closeAccount accept 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.

GET
/v1/health

Error Responses

CodeHTTPMessageWhen
7001500Internal server errorUnexpected 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).

POST
/v1/trade-local

Attributes

publicKey
string
required
Wallet public key used to identify the user.
action
string
required
Trade action: buy or sell.
mint
string
required
Token mint address.
amount
string|number
required
Amount to trade (token units or SOL depending on denominatedInSol).
slippage
number
required
Maximum slippage tolerance as a percent.
priorityFee
number
required
Priority fee in SOL for the built transaction.
denominatedInSol
boolean|string|integer
required
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
required
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

CodeHTTPMessageWhen
4007400Missing required fieldpublicKey is not provided.
4001400Invalid public key formatpublicKey is not a valid public key.
4003400Invalid mint addressmint is not a valid public key.
4005400Invalid action. Must be "buy" or "sell"closeAccount is true while action is not sell.
5006500RPC node errorRPC request fails while building the unsigned transaction.
7001500Internal server errorUnexpected 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.

POST
/v1/trade

Attributes

privateKey
string
required
Base58-encoded secret key for the sender wallet.
action
string
required
Trade action: buy or sell.
mint
string
required
Token mint address.
amount
string|number
required
Amount to trade (token units or SOL depending on denominatedInSol).
slippage
number
required
Maximum slippage tolerance as a percent.
priorityFee
number
required
Priority fee in SOL for the trade transaction.
denominatedInSol
boolean|string|integer
required
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
required
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

CodeHTTPMessageWhen
4007400Missing required fieldRequest JSON is invalid or required fields are missing.
4001400Invalid public key formatprivateKey cannot be decoded or keypair is invalid.
4003400Invalid mint addressmint is not a valid public key.
4005400Invalid action. Must be "buy" or "sell"closeAccount is true while action is not sell.
5001500Insufficient balance for transactionWallet balance is too low to execute the trade.
5003504Transaction confirmation on-chain timed outWebSocket confirmation timed out without fallback data.
5006500RPC node errorRPC request fails during send or confirmation.
6001500Slippage tolerance exceededPrice moved beyond slippage.
6002500Liquidity pool not foundNo pool exists for the mint/pool selection.
6003500Insufficient liquidity in poolPool cannot fill the trade amount.
7006500Trade details unavailableTrade succeeded but detailed info could not be retrieved.
7001500Internal server errorUnexpected 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.

POST
/v1/transfer

Attributes

privateKey
string
required
Base58-encoded secret key for the sender wallet.
receiverPubkey
string
required
Destination wallet public key.
lamports
integer
required
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

CodeHTTPMessageWhen
4001400Invalid public key formatprivateKey cannot be decoded or keypair is invalid.
4002400Invalid receiver public keyreceiverPubkey is not a valid public key.
5001500Insufficient balance for transactionWallet balance is too low.
5006500RPC node errorRPC request fails during send.
7001500Internal server errorUnexpected 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.

POST
/v1/transfer-batch

Attributes

privateKey
string
required
Base58-encoded secret key for the sender wallet.
recipients
array
required
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

CodeHTTPMessageWhen
4001400Invalid public key formatprivateKey or a recipient pubkey is invalid.
5001500Insufficient balance for transactionWallet balance is too low.
5006500RPC node errorRPC request fails during send.
7001500Internal server errorUnexpected 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.

POST
/v1/get-balance

Attributes

publicKey
string
required
Wallet public key to query.
mint
string
required
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

CodeHTTPMessageWhen
4001400Invalid public key formatpublicKey is not a valid public key.
4003400Invalid mint addressmint is not a valid public key.
5006500RPC node errorRPC request fails during balance lookup.
7001500Internal server errorUnexpected 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).

POST
/v1/get-tokens

Attributes

publicKey
string
required
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

CodeHTTPMessageWhen
4001400Invalid public key formatpublicKey is not a valid public key.
5006500RPC node errorRPC request fails during token lookup.
7001500Internal server errorUnexpected 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)