Subgraph Query in Python
The following example queries the Carbon DeFi Subgraph using Python.
1. Copy the following code snippet into a Python development environment:
Note that you must assign the value for "GRAPH_API_KEY" with your API key. This example acquires the key from an .env file. To get an API key, visit: https://thegraph.com/studio/apikeys/
2. Run the code!
If successful, you will see a printout of:
The number of pairs found in Carbon DeFi
The token symbols of the first pair
The printout should look like:
number of pairs from subgraph: 87
first pair: {'token0': {'symbol': 'BIAO'}, 'token1': {'symbol': 'ETH'}}
Last updated