0

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`"}]}

1 Answer 1

0

By using the token address in sellToken or buyToken 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.

1
  • I tested this and I swear it wasn't working. But really glad it is, thanks!
    – amaurer
    Dec 7, 2021 at 22:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.