Docs
Vyhledávání⌘ K
  • Domov
  • O Grafu
  • Podporované sítě
  • Protocol Contracts
  • Podgrafy
    • Substreams
      • Token API
        • Hypergraph
          • AI Suite
            • Indexing
              • Resources
                Podgrafy > Querying

                2 minutes

                Query The Graph with Python and Subgrounds

                Subgrounds is an intuitive Python library for querying Subgraphs, built by Playgrounds⁠. It allows you to directly connect Subgraph data to a Python data environment, letting you use libraries like pandas⁠ to perform data analysis!

                Subgrounds nabízí jednoduché Pythonic API pro vytváření dotazů GraphQL, automatizuje zdlouhavé pracovní postupy, jako je stránkování, a umožňuje pokročilým uživatelům řízené transformace schémat.

                Začínáme

                Subgrounds vyžaduje Python 3.10 nebo vyšší a je k dispozici na pypi⁠.

                1pip install --upgrade subgrounds2# or3python -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⁠.

                1from subgrounds import Subgrounds23sg = Subgrounds()45# Load the Subgraph6aave_v2 = sg.load_subgraph(7    "https://api.thegraph.com/subgraphs/name/messari/aave-v2-ethereum")89# Construct the query10latest_markets = aave_v2.Query.markets(11    orderBy=aave_v2.Market.totalValueLockedUSD,12    orderDirection='desc',13    first=5,14)15# Return query to a dataframe16sg.query_df([17    latest_markets.name,18    latest_markets.totalValueLockedUSD,19])

                Dokumentace

                Subgrounds je vytvořen a spravován týmem Playgrounds⁠ a je k dispozici na stránce Playgrounds docs⁠.

                Vzhledem k tomu, že subgrounds má rozsáhlou sadu funkcí, které je třeba prozkoumat, uvádíme několik užitečných výchozích bodů:

                • Začínáme s dotazováním⁠
                  • Dobrý první krok k tomu, jak vytvářet dotazy s subgrounds.
                • Budování syntetických polí⁠
                  • Jemný úvod do definování syntetických polí, která transformují data definovaná ze schématu.
                • Souběžné dotazy⁠
                  • Zjistěte, jak zvýšit úroveň dotazů jejich paralelizací.
                • Export dat do CSV⁠
                  • A quick article on how to seamlessly save your data as CSVs for further analysis.
                ⁠Edit on GitHub⁠

                LiveÚvod
                On this page
                • Začínáme
                • Dokumentace
                The GraphStatusTestnetBrand AssetsForumSecurityPrivacy PolicyTerms of Service