Skip to main content

Overview

The Code Export feature converts your current GraphQL query into a ready-to-use code snippet in your language of choice. The generated code includes the full HTTP request setup — endpoint URL, authentication headers, query body, and variables — so you can copy it directly into your project.

Supported Languages

LanguageFormatUse Case
cURLShell commandQuick terminal testing, CI/CD scripts
Pythonrequests libraryBackend services, data pipelines, Jupyter notebooks
JavaScriptfetch APIBrowser apps, Node.js services
Gonet/httpBackend microservices, CLI tools
Rustreqwest crateHigh-performance services
Rubynet/httpRails applications, scripts
PHPcURL extensionPHP backends, WordPress plugins

How to Export

1

Write your query

Enter or load a query into the editor. Make sure it executes successfully before exporting.
2

Click Export Code

Click the Export Code button in the toolbar. A modal opens with the language selector and generated snippet.
3

Select a language

Choose your target language from the dropdown. The snippet updates immediately.
4

Copy the snippet

Click the Copy button to copy the generated code to your clipboard.
The exported code uses the GraphQL endpoint and API key from your current IDE configuration. If you’ve set a custom endpoint or headers, those are reflected in the generated snippet.

Example Snippets

The following examples export a simple DEXTrades query — fetching the 10 latest Solana DEX trades:
query {
  DEXTrades(
    network: sol
    limit: {count: 10}
    orderBy: Block_Time_DESC
  ) {
    Block { Time }
    Transaction { Hash }
    Trade {
      Buy { Currency { MintAddress } Amount PriceInUSD }
      Sell { Currency { MintAddress } Amount }
      Dex { ProtocolName }
    }
  }
}
curl -X POST "https://graphql.chainstream.io/graphql" \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: your_api_key" \
  -d '{
    "query": "{ DEXTrades(network: sol, limit: {count: 10}, orderBy: Block_Time_DESC) { Block { Time } Transaction { Hash } Trade { Buy { Currency { MintAddress } Amount PriceInUSD } Sell { Currency { MintAddress } Amount } Dex { ProtocolName } } } }"
  }'

What’s Included in Exported Code

Every generated snippet includes:
ComponentDescription
Endpoint URLhttps://graphql.chainstream.io/graphql
AuthenticationX-API-KEY header from your IDE Headers panel
Content-Typeapplication/json
Query bodyThe full GraphQL query from the editor
VariablesIncluded if the Variables panel contains values
Remember to replace your_api_key with your actual API key before running the exported code. The IDE does not embed your real key in exported snippets for security.

Tips

  • Test before exporting — Run the query in the IDE first to confirm it works. Exported code copies the query as-is.
  • Parameterize with variables — Use GraphQL variables instead of hardcoded values. The exported code includes the variables JSON alongside the query.
  • Check dependencies — Python snippets use requests, Rust uses reqwest, Go uses the standard library. Make sure the required packages are installed in your project.