> ## Documentation Index
> Fetch the complete documentation index at: https://docs.afkcrypto.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cotations de swap (EVM + Solana)

> Obtenez des cotations de swap sur EVM et Solana pour un couple de tokens et un montant.

<Note>
  Utilisez le mot-clé `NATIVE` pour `fromToken`/`toToken` pour échanger des actifs natifs (ETH, SOL, etc.). Limité (15/min par utilisateur). Solana mainnet uniquement (devnet/testnet non supportés). Si `from` fourni avec ERC20, renvoie `approvalNeeded` et `spender`.
</Note>

<ResponseExample>
  ```json 200 theme={null}
  {
    "quote": {
      "srcAmount": "1000000000000000000",
      "dstAmount": "998700000000000000",
      "fromToken": "0xSrc",
      "toToken": "0xDst",
      "approvalNeeded": true,
      "spender": "0xRouter",
      "allowanceTarget": "0xRouter",
      "raw": { "...": "..." }
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /trade/quote
openapi: 3.1.0
info:
  title: AFK Crypto API
  description: >-
    AFK Crypto - Non-custodial wallet automation. Simple REST APIs for EVM and
    Solana.
  version: 1.0.0
servers:
  - url: https://api.afkcrypto.com/v1
    description: Production
security:
  - apiKeyAuth: []
paths:
  /trade/quote:
    post:
      summary: Get trade quote (EVM + Solana)
      description: Get swap quotes on EVM and Solana; may include router and approval info.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TradeQuoteRequest'
      responses:
        '200':
          description: Quote response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TradeQuoteResponse'
          headers:
            x-request-id:
              $ref: '#/components/headers/XRequestId'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            x-request-id:
              $ref: '#/components/headers/XRequestId'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            x-request-id:
              $ref: '#/components/headers/XRequestId'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            x-request-id:
              $ref: '#/components/headers/XRequestId'
            Retry-After:
              schema:
                type: integer
              description: Seconds until next window
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  schemas:
    TradeQuoteRequest:
      oneOf:
        - $ref: '#/components/schemas/EvmTradeQuoteRequest'
        - $ref: '#/components/schemas/SolanaTradeQuoteRequest'
    TradeQuoteResponse:
      type: object
      properties:
        quote:
          type: object
          properties:
            srcAmount:
              type: string
              description: Input amount in base units.
            dstAmount:
              type:
                - string
                - 'null'
              description: >-
                Estimated output amount in base units (may be null if upstream
                omits).
            fromToken:
              type:
                - string
                - 'null'
              description: Input token or native indicator (EVM native uses 0xEeee...).
            toToken:
              type:
                - string
                - 'null'
              description: Output token address or mint.
            approvalNeeded:
              type:
                - boolean
                - 'null'
              description: Whether ERC20 approval is required (EVM).
            spender:
              type:
                - string
                - 'null'
              description: Router address to approve (EVM).
            allowanceTarget:
              type:
                - string
                - 'null'
              description: Alias of spender for some providers (EVM).
            raw:
              type: object
              additionalProperties: true
              description: Raw upstream quote payload for transparency.
          required:
            - srcAmount
      required:
        - quote
    ApiError:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
        code:
          type: string
          enum:
            - FORBIDDEN
            - UNAUTHORIZED
            - RATE_LIMITED
            - INVALID_INPUT
            - WALLET_NOT_FOUND
            - USER_NOT_LINKED
            - WALLET_NOT_DELEGATED
            - WALLET_ID_REQUIRED
            - CHAIN_UNKNOWN
            - IDEMPOTENT_BODY_MISMATCH
            - IDEMPOTENT_REPLAY
            - PRIVY_RPC_ERROR
            - SEND_FAILED
            - SERVICE_UNAVAILABLE
            - QUOTE_FAILED
            - NOT_FOUND
            - INSUFFICIENT_FUNDS
            - INTERNAL_ERROR
          description: Stable error code for programmatic handling.
        requestId:
          type:
            - string
            - 'null'
          description: Unique request identifier (also in x-request-id header).
      required:
        - error
    EvmTradeQuoteRequest:
      title: EVM
      type: object
      properties:
        chain:
          type: string
          description: EVM chain slug
        fromToken:
          type: string
        toToken:
          type: string
        amount:
          type: string
          description: Amount in wei (decimal or 0x-hex)
        from:
          type:
            - string
            - 'null'
          description: Wallet address for allowance checks (optional)
        includeGas:
          type:
            - boolean
            - 'null'
          description: Include gas estimates (optional)
        protocols:
          type:
            - string
            - 'null'
          description: Comma-separated allowlist of protocols (optional)
        excludeProtocols:
          type:
            - string
            - 'null'
          description: Comma-separated blocklist of protocols (optional)
      required:
        - chain
        - fromToken
        - toToken
        - amount
    SolanaTradeQuoteRequest:
      title: Solana
      type: object
      properties:
        chain:
          type: string
          description: Solana chain slug
        fromToken:
          type: string
        toToken:
          type: string
        amount:
          type: string
          description: Amount in base units
        slippage:
          type: number
          description: Percentage (e.g., 1 = 1%). Optional; defaults to 1%.
          default: 1
      required:
        - chain
        - fromToken
        - toToken
        - amount
  headers:
    XRequestId:
      description: Unique request identifier
      schema:
        type: string
  responses:
    ErrorResponse:
      description: Error envelope
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
      headers:
        x-request-id:
          $ref: '#/components/headers/XRequestId'
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````