FAQ

Find answers to common questions about using the Codex API

General API Questions

  1. Do you have an explorer for testing queries with an API key?
    Yes, our explorer is a very powerful tool for testing Codex endpoints. It has been updated to allow multiple tabs and will save your progress when closed for future referencing.

  2. I'm not sure how to get started with the API. Where can I get help?
    Everything you need to get started can be found in our Getting Started page. If you need further help, refer to this FAQ or reach out to us on Discord.

  3. Where do I send my API requests?
    Use the following URL:
    🔗 https://graph.codex.io/graphql

  4. How do websocket requests work for billing purposes?
    Websocket requests are billed per message sent by the websocket, but we offer custom plans with discounts for high usage (5m+/month). Contact us on Discord or via Email for information on custom plans.

  5. Do you accept ETH/Crypto as a payment method?
    Yes, but we require a minimum of 3 months upfront. We also accept payments from all major debit and credit cards through our payment processor Stripe.

  6. How many websockets and webhooks can i run on growth plan?
    300 websocket connections and no limit on webhooks.

  7. How do I get access to the latest schema.graphql?
    https://graph.codex.io/schema/latest.graphql is always up to date.

  8. I keep getting null responses from the API. What could be wrong?
    Ensure you’re using the correct API domain: https://graph.codex.io/graphql. If the issue persists, check your request parameters.

  9. My API key is exposed in the browser's network tab. Can I use a temporary API key instead of my main private key?
    Yes, we support short-lived tokens. You can find more information below:
    Docs reference: Short-lived API Keys
    SDK Example: https://github.com/Codex-Data/sdk/blob/main/examples/simple/apiKeys.ts

  10. How do I report an issue or request further support?
    You can contact us on Discord and we will respond as soon as possible.

Token Endpoints

  1. Is there a cap on the number of tokens I can request using the Tokens query?
    Yes, the limit is 100 tokens per request.

  2. How many tokens can be passed at once in the filterTokens API?
    You can request up to 200 tokens per call.

  3. How do I get more than 200 events when querying getTokenEvents?
    Pagination is supported—use the cursor parameter to request additional events.

  4. Are native tokens, such as ETH and SOL, supported?
    No. You have to user wrapped versions of native tokens, but they are backed 1:1 so the price is the same.

  5. I'm missing data in a getTokenEvents query, such as transactions for a specific block. How do I resolve this?
    getTokenEvents looks at the top pair when filtering for events, not all pairs. Use listPairsWithMetadataForToken to find the correct pool and filter by volume.

  6. How is the data in getTokenEvents formatted compared to Etherscan?
    Our API provides swap-related data, while Etherscan shows raw transaction data.

  7. For getBars, I don't understand the from and to parameters.
    They are Unix timestamps. For example, to retrieve data for December 26th 2024 you would use:
    from: 1735171200
    to: 1735257600

  8. How does the potentialScam filter in filterTokens work?
    It’s an automated system using custom logic to detect scams. While false positives can occur, it significantly reduces exposure to scam tokens.

  9. Is it possible to fetch pair metadata for multiple pool addresses?
    Yes, filterPairs could be used for this.

  10. How is market cap calculated when circulating supply is higher than total supply?
    If circulating supply exceeds total supply, we fall back to total supply to avoid inaccuracies. You can manually adjust this using: circulatingSupply * price

  11. Is it possible to get sparklines for a past time period?
    No, but you can use getBars and extract the closing values for similar results.

  12. I'm seeing null values in getBars. What does that mean?
    If there are no transactions in a timeframe, we use the previous bar's data. There shouldn't be null values once a token is deployed. If you notice this issue, please provide an example so we can investigate.

  13. How do I obtain historical liquidity data for a pool?
    Use getDetailedPairStats or getBars for historical liquidity insights.

  14. How do I fetch historical token prices and volumes?
    Use getDetailedPairStats for the most accurate historical data. getTokenPrices provides a weighted price across all pools, while individual pool prices can vary.

  15. Can I determine the PnL (Profit and Loss) of a wallet after buying/selling tokens?
    We don't have a dedicated endpoint for this, but you can get this data by using a combination of getTokenEvents https://docs.codex.io/reference/gettokenevents using the maker filter and balances and doing the math. Our newer endpoint getTokenEventsForMaker may also simplify this process (https://docs.codex.io/reference/gettokeneventsformaker). On our end we get every event that a maker is involved in and then sum up the buys and sells, then use the balance to figure out how much is unrealized.

  16. A token contract isn't being recognized by filterTokens(query doesn't return any results), what's the reason?
    It's possible the token you are looking up has been flagged as a potential scam. If you want to include scams in your queries you can add filters: {includeScams: true} to the arguments. Tokens are sometimes flagged as a potential scam in error as the methodology isn't perfect for detecting them.

  17. What is the purpose of statsType/TokenPairStatisticsType for a query?
    This parameter is for filtering MEV results and can be set to the following:
    • FILTERED – MEV-related events are excluded from the data.
    • UNFILTERED – Includes all events, including those related to MEV activity.
      MEV transactions can significantly impact volume, liquidity, and price calculations. By using FILTERED, you get a clearer picture of organic trading activity without MEV influence. Conversely, UNFILTERED provides a full view, including arbitrage and sandwich attacks.

  18. Is it possible to get sparklines for a period of time in the past?
    No, but you can use getBars for this. Just take the close value.

  19. How do I search filterTokens for an exact token symbol? When searching, I'm getting partial matches to unrelated tokens.
    If you're not going to use the contract address you will need to add some filters and rankings to get the expected response. We index over 25m tokens so you have to narrow your query parameters for accurate results.

Token Websockets

  1. Is there a way to update token volume and holders via WebSockets?
    Yes, you can use the following:
    • onPairMetadataUpdated for volume updates.
    • onHoldersUpdated is available for enterprise users, but you can also poll the holders endpoint.

  2. Does Codex have a WebSocket that sends all token prices rather than just a set?
    No, but you can subscribe to up to 25 tokens at a time using onPricesUpdated.

  3. Is there a way to update volume and token holders of a Token via websockets?
    Yes, you can use onHodlersUpdated that is available for enterprise plans. You can also poll for this data through our holders endpoint.

  4. When using onPriceUpdated, is there a method to cancel a subscription? (eg: If I subscribe to multiple trading pairs and I want to cancel a certain trading pair later).
    Yes. You should be able to use shouldResubscribe for this. (https://www.apollographql.com/docs/react/data/subscriptions#options)

  5. How can I create a chart in real-time with the API?
    You can use getBars to fetch the bars and then onBarsUpdates to keep it updated in real-time.

  6. I’m getting a 4401 error when connecting to websockets. How can I fix this?
    This usually means that you’re trying to subscribe to a websocket before receiving confirmation that you’ve successfully connected to the server. Make sure to wait for the connection_ack before subscribing.

Didn't find the answer you need? Contact us on Discord at the link below:

👋

Join our Discord

Ask questions, share what you're working on and request new features 👬👭