Tool

Query Decentralized Subgraphs with Playgrounds API

Query and inspect decentralized blockchain subgraphs via Playgrounds API in a LlamaIndex agent.

Works with llama indexlangchainopenaithe graph

74
Spark score
out of 100
Updated 2 days ago
Version 0.14.23

Add to Favorites

Why it matters

Seamlessly query and introspect decentralized subgraphs on The Graph's network using the Playgrounds API. Develop AI applications that leverage blockchain data without managing wallets or GRT.

Outcomes

What it gets done

01

Connect LLM agents to decentralized subgraphs via Playgrounds API.

02

Query blockchain data (e.g., Uniswap V3 financials) without wallet management.

03

Introspect subgraph schemas to understand available blockchain datasets.

04

Integrate blockchain data into AI applications using LlamaIndex or LangChain.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-tool-tools-playgrounds | bash

Overview

Playgrounds Tool Specs

A LlamaIndex tool pair for querying and inspecting decentralized blockchain subgraphs via the Playgrounds API. Use the inspector to discover a subgraph's schema first, then the connector to query its data.

What it does

The Playgrounds Tool Specs give a LlamaIndex agent access to decentralized subgraphs - indexed blockchain datasets on The Graph's network - through the Playgrounds API, a service from Playgrounds Analytics built to streamline interfacing with these subgraphs. The package bundles two distinct tools.

PlaygroundsSubgraphConnectorToolSpec lets an agent actually query a subgraph: it is initialized with an identifier (a Subgraph ID or Deployment ID), a Playgrounds api_key, and a use_deployment_id flag to indicate which kind of identifier was supplied. The source's own worked example queries the financialsDailySnapshots entity from a Uniswap V3 subgraph for id, timestamp, totalValueLockedUSD, and dailyVolumeUSD, limited to the first two rows - illustrating a real GraphQL-style query against live blockchain data through the agent. PlaygroundsSubgraphInspectorToolSpec complements this by letting an agent introspect and understand a subgraph's schema, rather than query its data - useful for discovering what fields and entities exist in an unfamiliar subgraph before writing a query against it.

Both tools remove the need for wallet or GRT (The Graph's token) management to access this data, and both are designed to work with either LlamaIndex or LangChain agents. The source's own worked example for the connector wraps the query in a standard async Python entrypoint (asyncio.run under if __name__ == "__main__":), and links to a further, more in-depth examples notebook in the connector's own GitHub repository for developers who want additional worked queries.

When to use - and when NOT to

Use PlaygroundsSubgraphConnectorToolSpec when an agent needs to actually query data from a known subgraph on The Graph's network. Use PlaygroundsSubgraphInspectorToolSpec first, when the agent (or developer) doesn't yet know a subgraph's schema and needs to discover its available fields and entities before querying. Do not use either without a Playgrounds API key and a real Subgraph or Deployment ID - both are required to initialize the connector, and the tools have no functionality without valid blockchain dataset access already identified via The Graph's explorer.

Capabilities

PlaygroundsSubgraphConnectorToolSpec runs queries against a specified subgraph and returns the requested fields. PlaygroundsSubgraphInspectorToolSpec introspects a subgraph's schema so its structure can be understood before querying.

How to install

pip install llama-index-tools-playgrounds
connector_spec = PlaygroundsSubgraphConnectorToolSpec(
    identifier="YOUR_SUBGRAPH_OR_DEPLOYMENT_IDENTIFIER",
    api_key="YOUR_PLAYGROUNDS_API_KEY",
    use_deployment_id=False,  # Set to True if using Deployment ID
)

agent = FunctionAgent(
    tools=connector_spec.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

Requires a Playgrounds API key and a Subgraph or Deployment identifier, found via The Graph's explorer.

Who it's for

Developers building LlamaIndex agents that need to query or explore decentralized blockchain datasets (subgraphs) without managing a wallet or GRT tokens directly.

Source README

Playgrounds Tool Specs

playgrounds_subgraph_connector

pip install llama-index-tools-playgrounds

Playgrounds API is a service provided by Playgrounds Analytics to streamline interfacing with decentralized subgraphs (indexed blockchain datasets).

The PlaygroundsSubgraphConnector is a tool designed for LLM agents to seamlessly interface with and query subgraphs on The Graph's decentralized network via Playgrounds API.

This tool is specifically designed to be used alongside Llama index or langchain

Advantages of this tool:

  • Easy access to Decentralized Subgraphs (Datasets): No need for wallet or GRT management.
  • LLM x Blockchain data: Develop Ai applications that leverage blockchain data seamlessly.

Basic Usage:

To utilize the tool, simply initialize it with the appropriate identifier (Subgraph ID or Deployment ID) and api_key. Optionally, specify if you're using a deployment ID.

import openai
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
from llama_index.tools.playgrounds import PlaygroundsSubgraphConnectorToolSpec


async def simple_test():
    """
    Run a simple test querying the financialsDailySnapshots from Uniswap V3 subgraph using FunctionAgent and Playgrounds API.
    """

    # Initialize the tool specification with the subgraph's identifier and the Playgrounds API key
    connector_spec = PlaygroundsSubgraphConnectorToolSpec(
        identifier="YOUR_SUBGRAPH_OR_DEPLOYMENT_IDENTIFIER",
        api_key="YOUR_PLAYGROUNDS_API_KEY",
        use_deployment_id=False,  # Set to True if using Deployment ID
    )

    # Setup agent with the tool
    agent = FunctionAgent(
        tools=connector_spec.to_tool_list(),
        llm=OpenAI(model="gpt-4.1"),
    )

    # Make a query using the agent
    response = await agent.run(
        "query the financialsDailySnapshots for id, timestamp, totalValueLockedUSD, and dailyVolumeUSD. only give me the first 2 rows"
    )
    print(response)


if __name__ == "__main__":
    import asyncio

    asyncio.run(simple_test())

Visit here for more in-depth Examples.

This loader is designed to be used as a way to load data into LlamaIndex
and/or subsequently used as a Tool in a LangChain Agent.

playgrounds_subgraph_inspector

Playgrounds API is a service provided by Playgrounds Analytics to facilitate interactions with decentralized subgraphs (indexed blockchain datasets).

The PlaygroundsSubgraphInspectorToolSpec is a tool designed for LLM agents to introspect and understand the schema of subgraphs on The Graph's decentralized network via the Playgrounds API.

This tool is specifically designed to be used alongside Llama index or langchain.

  • To learn more about Playgrounds API, please visit our website: Playgrounds Network
  • Obtain your Playgrounds API Key and get started for free here.
  • Discover any Subgraph (dataset) you need here.

Advantages of this tool:

  • Introspection of Decentralized Subgraphs (Datasets): Understand the schema of any subgraph without hassle.
  • **LLM x Block

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.