An intuitive python library for interfacing with Subgraphs.
- Simple: Leverage a Pythonic API to easily build queries and transformations without the need for raw GraphQL manipulation.
- Automated: Automatically handle pagination and schema introspection for effortless data retrieval.
- Powerful: Create sophisticated queries using the
SyntheticFields
transformation system.
- Subgrounds Docs: User guide and API documentation
- Examples: A list of examples showcasing Subgrounds integration with Dash and Plotly
- Tutorials: Subgrounds video workshops and tutorials
- Community Projects: An ever growing list of projects created by our community members
Subgrounds requires atleast Python 3.10+
Subgrounds is available on PyPi. To install it, run the following:
pip install subgrounds
.
Subgrounds also comes bundled with extra modules that may require extra libraries. You can get all functionality of subgrounds
via the following:
pip install subgrounds[all]
.
>>> from subgrounds import Subgrounds
>>> sg = Subgrounds()
>>> # Load
>>> aave_v2 = sg.load_subgraph('https://api.thegraph.com/subgraphs/name/messari/aave-v2-ethereum')
>>> # Construct the query
>>> latest = aave_v2.Query.markets(
orderBy=aave_v2.Market.totalValueLockedUSD,
orderDirection='desc',
first=5,
)
>>> # Return query to a dataframe
>>> sg.query_df([
latest.name,
latest.totalValueLockedUSD,
])
markets_name markets_totalValueLockedUSD
0 Aave interest bearing STETH 1.522178e+09
1 Aave interest bearing WETH 1.221299e+09
2 Aave interest bearing USDC 8.140547e+08
3 Aave interest bearing WBTC 6.615692e+08
4 Aave interest bearing USDT 3.734017e+08
Playgrounds Analytics is a data solutions company providing serverless on-chain data infrastructures and services for data teams, analysts, and engineers. Checkout us out here to learn more!
This software project would not be possible without the support of The Graph Foundation. You can learn more about The Graph and its mission here.