A Pythonic data access layer for applications querying data from The Graph Network.
Project description
Subgrounds
A Pythonic data access layer for applications querying data from The Graph Network.
Design goals
- Simple: Easy to use toplevel API
- Automated: Schema introspection and class generation, type checking and pagination is all handled automatically
- Schema-Driven: Queries are built with
FieldPaths
while transformations are defined withSyntheticFields
, as opposed to raw GraphQL and transforming raw data
Docs
- Subgrounds Docs: User guide and API documentation (WIP)
- MetricsDAO Subgrounds Workshop: Subgrounds workshop series hosted by MetricsDAO
- Examples: A list of examples showcasing Subgrounds integration with Dash and Plotly
- Community projects: An ever growing list of projects created by our community members
Installation
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 some handy dash
wrappers. To use those wrappers, you can install the extra dash
dependencies.
pip install subgrounds[dash]
.
Simple example
>>> 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
About Us
Playgrounds Analytics was started by web3 data enthusiasts to build open source tooling for The Graph Network as part of its grants program. Playgrounds Analytics are a data solutions company leveraging The Graph to provide serverless on-chain data infrastructures and services for data teams, analysts, and engineers. Checkout us out here to learn more!
Acknowledgments
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for subgrounds-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66e14d4ea6c52c32958cca711b1d357bdfd0c695297bb65aa638d5d054beab41 |
|
MD5 | 4f8ba5e4288293085d2625a60a9ff649 |
|
BLAKE2b-256 | a22dc631702e4d08342f4bb42379bdbce7f26dcbd5d4e37bd385affa7ec58ae4 |