{ "openapi": "3.1.0", "info": { "title": "Solana API", "description": "API for generating Solana swap instructions across aggregated DEX liquidity.", "version": "0.3.7" }, "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" } } }, "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." } } }, "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": { "type": "string", "description": "Base-58 encoded recipient for swap output.\nIf output token is native SOL this must be the address of the recipient, else a valid token account for that output token mint." }, "reserve_transaction_bytes": { "type": "integer", "format": "int64", "description": "Minimum bytes to reserve in the transaction for composing with additional instructions.", "default": 0, "minimum": 0 }, "slippage_bps": { "type": "integer", "format": "int32", "description": "Slippage tolerance in basis points.", "default": 50, "maximum": 10000, "minimum": 0 }, "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": { "type": "string", "description": "Comma-separated base-58 encoded recipients for the swap fees.\nMust be provided together with `swap_fee_ppm`.\nThe number of entries must match `swap_fee_ppm`.\nIf the respective token for `swap_fee_side` is native SOL this must be an address, else a valid token account for that token mint." }, "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": { "type": "string", "description": "Base-58 encoded recipient that should receive trade surplus.\nMust be provided together with `trade_surplus_cap_ppm`, or both fields must be omitted.\nIf the output token is native SOL this must be an address, else a valid token account for that token mint.\nWhen 0x controls trade surplus collection, the request value is ignored and the configured 0x recipient is used instead." } }, "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." }, "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." } } } }, "securitySchemes": { "ApiKeyAuth": { "type": "apiKey", "in": "header", "name": "0x-api-key" } } }, "tags": [ { "name": "Swap", "description": "Solana Swap API" }, { "name": "Sources", "description": "Solana Sources API" } ] }