0x · API Governance Rules
0x API Rules
Spectral linting rules defining API design standards and conventions for 0x.
27 Rules
error 11
warn 12
info 4
Rule Categories
0x
Rules
error
0x-info-title-prefix
0x specs are titled "0x API" or "0x API" — match that pattern.
$.info.title
warn
0x-info-description-required
Every spec must have an info.description with at least 40 chars.
$.info
error
0x-info-version-required
Spec version MUST be set (e.g. v2 for Swap/Gasless, v1 for Cross-Chain).
$.info
error
0x-server-url-canonical
All 0x APIs are served from https://api.0x.org.
$.servers[*].url
warn
0x-paths-kebab-case
Path segments use kebab-case (allowance-holder, trade-analytics, gasless-approval-tokens, tx-history-beta). Reject snake_case and camelCase.
$.paths.*~
error
0x-paths-no-trailing-slash
Paths must not end with a trailing slash.
$.paths.*~
error
0x-operation-operationid-required
Every operation MUST declare an operationId (used by SDK generators).
$.paths.*[get,post,put,delete,patch]
warn
0x-operation-operationid-namespaced
0x operationIds follow `::::` (e.g. swap::permit2::getQuote, gasless::submit, crossChain::getQuotes). Enforce double-colon namespacing or camelCase verb names.
$.paths.*[get,post,put,delete,patch].operationId
error
0x-operation-summary-required
Every operation MUST have a Title Case summary.
$.paths.*[get,post,put,delete,patch]
warn
0x-operation-description-required
Operation description is required and should be at least 30 chars.
$.paths.*[get,post,put,delete,patch]
error
0x-operation-tags-required
Every operation MUST be tagged with one of: Swap, Gasless, Cross-Chain, Trade Analytics, Sources.
$.paths.*[get,post,put,delete,patch].tags
info
0x-operation-microcks-extension
Operations SHOULD include x-microcks-operation with dispatcher FALLBACK for replayable mock generation.
$.paths.*[get,post,put,delete,patch]
warn
0x-tags-title-case
Tag names use Title Case ("Swap", "Cross-Chain", "Trade Analytics").
$.paths.*[get,post,put,delete,patch].tags[*]
error
0x-header-api-key-required
All 0x API operations require the `0x-api-key` header for authentication.
$.paths.*[get,post,put,delete,patch]
warn
0x-header-version-required
Swap, Gasless, Sources, and Trade Analytics operations require the `0x-version` header (currently `v2`).
$.paths.*[get,post,put,delete,patch]
warn
0x-parameter-camelcase
Query and path parameter names use camelCase (chainId, sellToken, buyToken, sellAmount, taker, tradeHash, includedSources, excludedSources, slippageBps).
$.paths.*[get,post,put,delete,patch].parameters[?(@.in=='query' || @.in=='path')].name
warn
0x-parameter-description-required
All parameters MUST be documented.
$.paths.*[get,post,put,delete,patch].parameters[*]
info
0x-chainid-parameter-required
Almost every 0x endpoint takes a `chainId` query parameter to route the request to the correct EVM chain (or non-EVM virtual chain ID for Solana, HyperCore, Tron in the Cross-Chain API).
$.paths.*[get,post,put,delete,patch].parameters[?(@.in=='query')].name
error
0x-response-200-required
Every operation MUST document a 200 response.
$.paths.*[get,post,put,delete,patch].responses
warn
0x-response-400-recommended
Most 0x operations return 400 for INPUT_INVALID / validation failures — document it.
$.paths.*[get,post,put,delete,patch].responses
error
0x-response-json-content-type
All responses MUST be application/json.
$.paths.*[get,post,put,delete,patch].responses.*.content
warn
0x-schema-camelcase-properties
Schema properties use camelCase (buyToken, sellAmount, allowanceTarget, blockNumber, gasPrice, totalNetworkFee, liquidityAvailable).
$.components.schemas.*.properties.*~
info
0x-evm-address-pattern
EVM address fields must use the canonical regex `^0x[a-fA-F0-9]{40}$`.
$..properties[?(@property.match(/Token$|Address$|allowanceTarget|taker|recipient/i))]
info
0x-numeric-string-pattern
On-chain integer amounts (buyAmount, sellAmount, gas, value, gasPrice, blockNumber) are returned as decimal strings — enforce string type with a numeric pattern.
$..properties[?(@property.match(/Amount$|^gas$|^value$|^gasPrice$|^blockNumber$/))]
warn
0x-security-scheme-apikey
0x uses an API key passed via the `0x-api-key` request header. The spec SHOULD declare an `apiKey` security scheme.
$.components.securitySchemes
error
0x-get-no-request-body
GET operations MUST NOT have a request body.
$.paths.*.get
warn
0x-post-has-request-body
POST operations (e.g. /gasless/submit) SHOULD define a requestBody.
$.paths.*.post