{ "openapi": "3.1.0", "info": { "title": "Solana API", "description": "API for generating Solana swap instructions across aggregated DEX liquidity.", "version": "0.3.18" }, "servers": [ { "url": "https://api.0x.org/solana" } ], "paths": { "/enabled-sources": { "get": { "tags": [ "Sources" ], "summary": "Get Enabled Sources", "description": "Returns the list of enabled sources for the calling team.", "operationId": "enabled_sources", "parameters": [ { "name": "0x-api-key", "in": "header", "description": "Visit dashboard.0x.org to get your API Key", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Enabled DEX sources", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/EnabledSourcesResponse" } } } }, "400": { "description": "Missing or invalid required header", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiError" } } } } } } }, "/swap-instructions": { "post": { "tags": [ "Swap" ], "summary": "Create Swap Instructions", "description": "Returns Solana swap instructions for a given token pair and amount.", "operationId": "swap_instructions", "parameters": [ { "name": "0x-api-key", "in": "header", "description": "Visit dashboard.0x.org to get your API Key", "required": true, "schema": { "type": "string" } } ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SwapInstructionsRequest" } } }, "required": true }, "responses": { "200": { "description": "Swap instructions", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SwapInstructionsResponse" } } } }, "4XX": { "description": "Client error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiError" } } } }, "5XX": { "description": "Server error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiError" } } } } } } } }, "components": { "schemas": { "AccountMeta": { "type": "object", "description": "OpenAPI schema mirror for `solana_instruction::AccountMeta`.", "required": [ "pubkey", "is_signer", "is_writable" ], "properties": { "is_signer": { "type": "boolean" }, "is_writable": { "type": "boolean" }, "pubkey": { "type": "array", "items": { "type": "integer", "format": "int32", "minimum": 0 }, "description": "Account public key as a 32-byte array.", "maxItems": 32, "minItems": 32 } } }, "ApiError": { "type": "object", "description": "API error response body.", "required": [ "code", "error" ], "properties": { "code": { "type": "string" }, "error": { "type": "string" }, "zid": { "type": "string" } } }, "AssociatedTokenAccountDestination": { "type": "object", "required": [ "associatedTokenAccount" ], "properties": { "associatedTokenAccount": { "$ref": "#/components/schemas/AssociatedTokenAccountOwner" } }, "additionalProperties": false }, "AssociatedTokenAccountOwner": { "type": "object", "required": [ "owner" ], "properties": { "owner": { "type": "string", "description": "Base-58 encoded owner address that the created token account belongs to." } }, "additionalProperties": false }, "Destination": { "oneOf": [ { "type": "string", "description": "An existing base-58 encoded token account (or wallet for native SOL) address." }, { "$ref": "#/components/schemas/AssociatedTokenAccountDestination", "description": "A base-58 encoded owner address for a token account." } ], "description": "A swap destination: either an existing token account (or wallet for native SOL)\naddress, or an owner whose token account should be used, and created if required.\nIf an account is created, its rent is paid by `sponsor` if present, else by `taker`.\nIf the created ATA belongs to the taker, the sponsor keeps close authority and can\nreclaim the rent once the account is empty. ATAs created for anyone else (custom\nrecipient, fee or surplus recipient) leave the rent as a permanent sponsor cost." }, "EnabledSourcesResponse": { "type": "object", "description": "Enabled sources API response.", "required": [ "sources" ], "properties": { "sources": { "type": "array", "items": { "type": "string" }, "description": "List of enabled sources, as DEX labels." } } }, "FeeRecipients": { "oneOf": [ { "type": "string", "description": "Comma-separated base-58 encoded token account addresses." }, { "type": "array", "items": { "$ref": "#/components/schemas/Destination" }, "description": "Structured list of destinations, one per fee entry." } ], "description": "Fee recipients for the swap fees: either a comma-separated list of\nexisting token accounts, or a structured list mixing addresses with\nowners whose token accounts should be the fee recipient." }, "Instruction": { "type": "object", "description": "OpenAPI schema mirror for `solana_instruction::Instruction`.", "required": [ "program_id", "accounts", "data" ], "properties": { "accounts": { "type": "array", "items": { "$ref": "#/components/schemas/AccountMeta" } }, "data": { "type": "array", "items": { "type": "integer", "format": "int32", "minimum": 0 }, "description": "Serialized instruction data bytes." }, "program_id": { "type": "array", "items": { "type": "integer", "format": "int32", "minimum": 0 }, "description": "Program ID as a 32-byte array.", "maxItems": 32, "minItems": 32 } } }, "SwapInstructionsRequest": { "type": "object", "description": "Request body for the swap-instructions endpoint.", "required": [ "token_in", "amount_in", "token_out", "taker" ], "properties": { "amount_in": { "type": "integer", "format": "int64", "description": "Input amount in its base units.", "examples": [ 1000000 ], "minimum": 1 }, "disabled_sources": { "type": "array", "items": { "type": "string" }, "description": "DEX sources to exclude from routing. Valid source names are returned by `/enabled-sources`." }, "recipient": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/Destination", "description": "Base-58 encoded recipient for swap output." } ] }, "reserve_transaction_accounts": { "type": "integer", "format": "int64", "description": "Minimum static account keys to reserve in the transaction for composing with additional instructions.\nOnly applies to `v1` transactions; ignored when `transaction_version` is `v0`.", "default": 0, "minimum": 0 }, "reserve_transaction_bytes": { "type": "integer", "format": "int64", "description": "Minimum bytes to reserve in the transaction for composing with additional instructions.\nOnly applies to `v0` transactions; ignored when `transaction_version` is `v1`.", "default": 0, "minimum": 0 }, "slippage_bps": { "type": "integer", "format": "int32", "description": "Slippage tolerance in basis points.", "default": 50, "maximum": 10000, "minimum": 0 }, "sponsor": { "type": "string", "description": "Transaction fee payer and rent payer for a fully-sponsored swap.\nMust differ from the taker and from every native destination in the request.\nThe taker remains the swap authority and must still sign.", "examples": [ "Sponsor111111111111111111111111111111111111" ] }, "swap_fee_ppm": { "type": "string", "description": "Comma-separated volume-based swap fees in parts per million.\nMust be provided together with `swap_fee_recipient`.\nEach entry must be between `0` and the per-app maximum (`100_000` unless configured otherwise).\nA value of `0` disables that fee entry.\nMultiple fees on the same side are applied sequentially, each on the amount remaining after prior deductions — not the original amount. Fee amounts are rounded up to the nearest base unit." }, "swap_fee_recipient": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/FeeRecipients", "description": "Fee recipients for the swap fees.\nMust be provided together with `swap_fee_ppm`.\nThe number of entries must match `swap_fee_ppm`.\nA sponsored swap rejects the owner form for wSOL fee recipients: the sponsor\nwould pay rent to create the account, and closing (unwrapping) a wSOL account\nsends that rent to its owner. Use an existing token account instead." } ] }, "swap_fee_side": { "type": "string", "description": "Comma-separated fee sides for each fee entry.\nSupported values are `buy` and `sell`.\nThis field may be omitted only when every fee uses the default `buy` side.\nWhen provided, the number of entries must match `swap_fee_ppm`." }, "taker": { "type": "string", "description": "Base-58 encoded taker wallet address.", "examples": [ "ZeroEx1111111111111111111111111111111111111" ] }, "token_in": { "type": "string", "description": "Input token mint, base-58 encoded. Use `So11111111111111111111111111111111111111111` for native SOL.", "examples": [ "So11111111111111111111111111111111111111112" ] }, "token_out": { "type": "string", "description": "Output token mint, base-58 encoded. Use `So11111111111111111111111111111111111111111` for native SOL.", "examples": [ "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" ] }, "trade_surplus_cap_ppm": { "type": "integer", "format": "int32", "description": "Trade surplus cap in parts per million of the total realized trade size.\nMust be provided together with `trade_surplus_recipient`, or both fields must be omitted.\nA value of `0` disables trade surplus collection for the request.\nWhen 0x controls trade surplus collection, the request value is ignored and the configured 0x policy is applied instead.\nThe transferred amount is capped relative to trade size.", "maximum": 1000000, "minimum": 0 }, "trade_surplus_recipient": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/Destination", "description": "Recipient that should receive trade surplus.\nMust be provided together with `trade_surplus_cap_ppm`, or both fields must be omitted.\nWhen 0x controls trade surplus collection, the request value is ignored and the configured 0x recipient is used instead." } ] }, "transaction_version": { "oneOf": [ { "type": "null" }, { "$ref": "#/components/schemas/TransactionVersion", "description": "Transaction format to target.\n`v0` (default) budgets routing by transaction bytes and the response may include address lookup tables.\n`v1` budgets routing by static account count (max 64) and never returns address lookup tables." } ], "default": "v0" } }, "example": { "amount_in": 1000000000, "slippage_bps": 50, "taker": "ZeroEx1111111111111111111111111111111111111", "token_in": "So11111111111111111111111111111111111111112", "token_out": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" } }, "SwapInstructionsResponse": { "type": "object", "description": "Swap instructions API response.", "required": [ "amount_out", "min_amount_out", "instructions", "address_lookup_tables", "route_plan", "zid" ], "properties": { "address_lookup_tables": { "type": "array", "items": { "type": "string" }, "description": "Address Lookup Table addresses that must be included in the versioned transaction." }, "amount_out": { "type": "integer", "format": "int64", "description": "The estimated output amount after fees, in its base units.", "minimum": 0 }, "instructions": { "type": "array", "items": { "$ref": "#/components/schemas/Instruction" }, "description": "The instructions to perform the swap." }, "min_amount_out": { "type": "integer", "format": "int64", "description": "The minimum output amount after slippage and fees, in its base units. Transaction will fail if this amount is not met.", "minimum": 0 }, "route_plan": { "type": "array", "items": { "$ref": "#/components/schemas/SwapInstructionsRoutePlanStep" }, "description": "List of swap legs comprising the swap." }, "sponsor": { "type": "string", "description": "Present when the caller requested full sponsorship. The returned\ntransaction must use this address as fee payer; both sponsor and taker sign." }, "zid": { "type": "string", "description": "Unique 12-byte hex identifier for this request." } } }, "SwapInstructionsRoutePlanStep": { "type": "object", "description": "One swap leg in the swap route plan.", "required": [ "dex_address", "dex_label", "dex_program_id", "token_in", "token_out", "amount_in", "amount_out", "ppb" ], "properties": { "amount_in": { "type": "string", "description": "The amount of the input token to swap, in its base units." }, "amount_out": { "type": "string", "description": "The estimated amount of the output token received from the swap, in its base units." }, "dex_address": { "type": "string", "description": "The base-58 encoded address of the DEX." }, "dex_label": { "type": "string", "description": "The label for the DEX. Matches labels returned by the `enabled-sources` endpoint." }, "dex_program_id": { "type": "string", "description": "The base-58 encoded program ID address of the DEX." }, "ppb": { "type": "integer", "format": "int32", "description": "Proportion of _remaining_ amount routed through this step in parts per billion.", "minimum": 0 }, "token_in": { "type": "string", "description": "The base-58 encoded address of the input mint." }, "token_out": { "type": "string", "description": "The base-58 encoded address of the output mint." } } }, "TransactionVersion": { "type": "string", "description": "Transaction format the client will compile the instructions into.", "enum": [ "v0", "v1" ] } }, "securitySchemes": { "ApiKeyAuth": { "type": "apiKey", "in": "header", "name": "0x-api-key" } } }, "tags": [ { "name": "Swap", "description": "Solana Swap API" }, { "name": "Sources", "description": "Solana Sources API" } ] }