The 0x API docs say that the token interface is deprecated, but it seems that it's required to know which tokens are supported. For instance, I cannot send any Token symbol to the quote API, it will return a validation error for an unknown token symbol. Yet, the API docs suggest that other tokens, not listed, may work.
https://0x.org/docs/api#get-swapv1tokens
Deprecated. Get the tokens with known symbols available for trading in the /swap/v1/quote endpoint. If a token is not returned, it may still be available but not queryable by token symbol.
Can someone please explain how one would use the 0x API for a token not on the tokens list? And, if the tokens list is deprecated, should we anticipate the swap quote interface to be deprecated as well?
Example Quote Request:
https://api.0x.org/swap/v1/quote?sellToken=ETH&sellAmount=1000000000000000&buyToken=SHIB
{"code":100,"reason":"Validation Failed","validationErrors":[{"field":"buyToken","code":1004,"reason":"Could not find token `SHIB`"}]}
Best Answer
By using the token address in
sellToken
orbuyToken
fields. E.g for ETH->SHIB, https://api.0x.org/swap/v1/quote?sellToken=ETH&sellAmount=1000000000000000&buyToken=0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce or https://api.0x.org/swap/v1/quote?sellToken=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&sellAmount=1000000000000000&buyToken=0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce.The above has always worked but we added a "convenience" layer to specify the symbol. It became a source of confusion as this token list was always a subset of tokens that 0xAPI could find swaps for.