Skip to main content

Starknet API Overview

Welcome to the Starknet API documentation. Our API provides powerful endpoints for finding optimal trading routes and executing swaps on Base network.

Starknet URL

https://api.fibrous.finance/starknet

Common Concepts

Authentication

No authentication is required for the API endpoints.

Rate Limiting

Please refer to our Rate Limit documentation for details about rate limiting.

Common Token Addresses

Here are some commonly used token addresses on Starknet:
TokenAddressDecimals
ETH0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc718
USDC0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a86
STRK0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d18

Response Codes

CodeDescription
200Success - The request was successful
400Bad Request - Check your request parameters
429Too Many Requests - You’ve hit the rate limit
500Internal Server Error - Something went wrong on our end

Available Endpoints

Route

Find the optimal trading route through Fibrous’ liquidity pools to maximize output and minimize slippage.

Execute

Generate calldata for the Fibrous router contract to execute the swap.

Calldata

Get the calldata for executing the swap transaction.

Best Practices

Slippage Protection

  • Always set a reasonable slippage value (0.1% - 1% for stable pairs)
  • Use higher slippage for volatile pairs or low liquidity tokens
  • Monitor price impact to ensure favorable trades

Gas Optimization

  • Use the direct parameter for simple swaps between major tokens
  • Set excludeProtocols to skip specific protocols if needed
  • Consider batch swaps for multiple transactions

Error Handling

  • Always check the success field in responses
  • Implement proper error handling in your code
  • Monitor transaction status after execution

Quick Start Example

Here’s a complete example of how to perform a swap using our API:
  1. First, get the optimal route:
curl -X GET "https://api.fibrous.finance/starknet/route" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": "1000000000000000000",  # 1 ETH
    "tokenInAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
    "tokenOutAddress": "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8"
  }'
  1. Then, get the execution calldata:
curl -X GET "https://api.fibrous.finance/starknet/execute" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": "1000000000000000000",
    "tokenInAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
    "tokenOutAddress": "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
    "slippage": 0.5,
    "destination": "YOUR_ADDRESS"
  }'
  1. Finally, execute the transaction using the returned calldata with your preferred Web3 library.

Need Help?