From cf2392ad73159eaa9733cfcb9b238cb67b9520f9 Mon Sep 17 00:00:00 2001 From: 0xMochan Date: Thu, 9 Nov 2023 09:16:09 -0500 Subject: [PATCH 1/4] Querying with Python, Subgrounds --- .../en/querying/querying-with-python.mdx | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 website/pages/en/querying/querying-with-python.mdx diff --git a/website/pages/en/querying/querying-with-python.mdx b/website/pages/en/querying/querying-with-python.mdx new file mode 100644 index 000000000000..8f6a1c419158 --- /dev/null +++ b/website/pages/en/querying/querying-with-python.mdx @@ -0,0 +1,53 @@ +--- +title: Subgrounds +--- + +Subgrounds is an intuitive Python library for querying subgraphs, build by [Playgrounds Analytics](https://playgrounds.network). It allows you to directly connect subgraph data to a Python data environment, letting you use libraries like [pandas](https://pandas.pydata.org/) to perform data analysis! + +Subgrounds offers a simple Pythonic API for building GraphQL queries, automates tedious workflows such as pagination, and empowers advanced users through controlled schema transformations. + +## Getting Started + +Subgrounds requires Python 3.10 or higher and is available on [pypi](https://pypi.org/project/subgrounds/). + +```bash +pip install --upgrade subgrounds +# or +python -m pip install --upgrade subgrounds +``` + +Once installed, you can test out subgrounds with the following query. The following example grabs a subgraph for the Aave v2 protocol and queries the top 5 markets ordered by TVL (Total Value Locked), selects their name and their TVL (in USD) and returns the data as a pandas [DataFrame](https://pandas.pydata.org/pandas-docs/dev/reference/api/pandas.DataFrame.html#pandas.DataFrame). + +```python +from subgrounds import Subgrounds + +sg = Subgrounds() + +# Load the subgraph +aave_v2 = sg.load_subgraph( + "https://api.thegraph.com/subgraphs/name/messari/aave-v2-ethereum") + +# Construct the query +latest_markets = aave_v2.Query.markets( + orderBy=aave_v2.Market.totalValueLockedUSD, + orderDirection='desc', + first=5, +) +# Return query to a dataframe +sg.query_df([ + latest_markets.name, + latest_markets.totalValueLockedUSD, +]) +``` + +## Documentation + +Subgrounds is built and maintained the [Playgrounds](https://playgrounds.network) team and can be accessed on the [Playgrounds docs](https://docs.playgrounds.network/subgrounds). + +Since subgrounds has a large feature set to explore, here are some helpful starting places: + +- [Getting Started with Querying](https://docs.playgrounds.network/subgrounds/getting_started/basics/) + - T +- [Building Synthetic Fields](https://docs.playgrounds.network/subgrounds/getting_started/synthetic_fields/) +- [Concurrent Queries](https://docs.playgrounds.network/subgrounds/getting_started/async/) +- [Exporting Data to CSVs](https://docs.playgrounds.network/subgrounds/faq/exporting/) From 97c7b5e044342039a99c078117c68def59c97c03 Mon Sep 17 00:00:00 2001 From: 0xMochan Date: Thu, 9 Nov 2023 09:55:59 -0500 Subject: [PATCH 2/4] New routes --- website/route-lockfile.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/website/route-lockfile.txt b/website/route-lockfile.txt index 7ed59cfe3fec..c4663e075f06 100644 --- a/website/route-lockfile.txt +++ b/website/route-lockfile.txt @@ -217,6 +217,7 @@ /en/querying/querying-from-an-application/ /en/querying/querying-the-graph/ /en/querying/querying-the-hosted-service/ +/en/querying/querying-with-python/ /en/quick-start/ /en/release-notes/assemblyscript-migration-guide/ /en/release-notes/graphql-validations-migration-guide/ From 90a5bce4ebedbc136e9656bd12d166165b01bd1e Mon Sep 17 00:00:00 2001 From: 0xMochan Date: Thu, 9 Nov 2023 10:15:02 -0500 Subject: [PATCH 3/4] Typos and incomplete descriptions --- website/pages/en/querying/querying-with-python.mdx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/website/pages/en/querying/querying-with-python.mdx b/website/pages/en/querying/querying-with-python.mdx index 8f6a1c419158..099cde563b8b 100644 --- a/website/pages/en/querying/querying-with-python.mdx +++ b/website/pages/en/querying/querying-with-python.mdx @@ -2,7 +2,7 @@ title: Subgrounds --- -Subgrounds is an intuitive Python library for querying subgraphs, build by [Playgrounds Analytics](https://playgrounds.network). It allows you to directly connect subgraph data to a Python data environment, letting you use libraries like [pandas](https://pandas.pydata.org/) to perform data analysis! +Subgrounds is an intuitive Python library for querying subgraphs, built by [Playgrounds Analytics](https://playgrounds.network). It allows you to directly connect subgraph data to a Python data environment, letting you use libraries like [pandas](https://pandas.pydata.org/) to perform data analysis! Subgrounds offers a simple Pythonic API for building GraphQL queries, automates tedious workflows such as pagination, and empowers advanced users through controlled schema transformations. @@ -47,7 +47,10 @@ Subgrounds is built and maintained the [Playgrounds](https://playgrounds.network Since subgrounds has a large feature set to explore, here are some helpful starting places: - [Getting Started with Querying](https://docs.playgrounds.network/subgrounds/getting_started/basics/) - - T + - A good first step for how to build queries with subgrounds. - [Building Synthetic Fields](https://docs.playgrounds.network/subgrounds/getting_started/synthetic_fields/) + - A gentle introduction to defining synthetic fields that transform data defined from the schema. - [Concurrent Queries](https://docs.playgrounds.network/subgrounds/getting_started/async/) + - Learn how to level up your queries by parallelizing them. - [Exporting Data to CSVs](https://docs.playgrounds.network/subgrounds/faq/exporting/) + - A quick article on how to seemlessly save your data as CSVs for further analysis. From a0ed7eeffd2063343c73d38a673a2644bbfbcf16 Mon Sep 17 00:00:00 2001 From: 0xMochan Date: Thu, 9 Nov 2023 10:38:29 -0500 Subject: [PATCH 4/4] Minor typos --- website/pages/en/querying/querying-with-python.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/pages/en/querying/querying-with-python.mdx b/website/pages/en/querying/querying-with-python.mdx index 099cde563b8b..c6f59d476141 100644 --- a/website/pages/en/querying/querying-with-python.mdx +++ b/website/pages/en/querying/querying-with-python.mdx @@ -2,7 +2,7 @@ title: Subgrounds --- -Subgrounds is an intuitive Python library for querying subgraphs, built by [Playgrounds Analytics](https://playgrounds.network). It allows you to directly connect subgraph data to a Python data environment, letting you use libraries like [pandas](https://pandas.pydata.org/) to perform data analysis! +Subgrounds is an intuitive Python library for querying subgraphs, built by [Playgrounds](https://playgrounds.network/). It allows you to directly connect subgraph data to a Python data environment, letting you use libraries like [pandas](https://pandas.pydata.org/) to perform data analysis! Subgrounds offers a simple Pythonic API for building GraphQL queries, automates tedious workflows such as pagination, and empowers advanced users through controlled schema transformations. @@ -42,7 +42,7 @@ sg.query_df([ ## Documentation -Subgrounds is built and maintained the [Playgrounds](https://playgrounds.network) team and can be accessed on the [Playgrounds docs](https://docs.playgrounds.network/subgrounds). +Subgrounds is built and maintained by the [Playgrounds](https://playgrounds.network/) team and can be accessed on the [Playgrounds docs](https://docs.playgrounds.network/subgrounds). Since subgrounds has a large feature set to explore, here are some helpful starting places: