Bitquery GraphQL Skill
Use this skill to run Bitquery GraphQL API operations through uxc.
Reuse the uxc skill for discovery, GraphQL execution, OAuth lifecycle, and generic error handling.
Prerequisites
- -
uxc is installed and available in PATH. - Network access to
https://streaming.bitquery.io/graphql. - A Bitquery application
client_id and client_secret are available.
Authentication
Bitquery uses bearer access tokens. The most stable agent path is OAuth client_credentials, not a copied temporary token.
- 1. Create a Bitquery application and note:
- application
client_id
- application
client_secret
- token scope
api
- 2. Login once with OAuth client credentials:
-
uxc auth oauth login bitquery-graphql --endpoint https://streaming.bitquery.io/graphql --flow client_credentials --client-id <client_id> --client-secret <client_secret> --scope api --token-endpoint https://oauth2.bitquery.io/oauth2/token
- This flow completes in one command. No browser approval page is required.
- 3. Bind the GraphQL endpoint:
-
uxc auth binding add --id bitquery-graphql --host streaming.bitquery.io --path-prefix /graphql --scheme https --credential bitquery-graphql --priority 100
- 4. Verify auth mapping:
-
uxc auth binding match https://streaming.bitquery.io/graphql
- INLINECODE14
Core Workflow
- 1. Use fixed link command by default:
-
command -v bitquery-graphql-cli
- If missing, create it:
uxc link bitquery-graphql-cli https://streaming.bitquery.io/graphql
-
bitquery-graphql-cli -h
- If command conflict is detected and cannot be safely reused, stop and ask skill maintainers to pick another fixed command name.
- 2. Discover available root operations:
-
bitquery-graphql-cli -h
- Verified roots currently include
query/EVM,
query/Solana,
query/Trading,
query/Tron, and matching
subscription/* roots.
- 3. Inspect a specific operation:
-
bitquery-graphql-cli query/EVM -h
-
bitquery-graphql-cli query/Trading -h
- 4. Execute with positional JSON and explicit GraphQL selection sets:
-
bitquery-graphql-cli query/EVM '{"network":"base","dataset":"combined","_select":"DEXTrades(limit: {count: 1}) { Transaction { Hash } }"}'
- 5. Prefer
query/* operations first.
-
uxc subscribe now auto-negotiates modern
graphql-transport-ws and legacy
graphql-ws compatibility profiles for
subscription/*.
- Live Bitquery subscription validation now succeeds when you provide an explicit
_select that matches a stream-friendly entity shape.
- Prefer
subscription/EVM as the first validation target rather than
subscription/Trading.
Capability Map
-
query/EVM
-
subscription/EVM
- - Solana onchain queries:
-
query/Solana
-
subscription/Solana
- - Cross-market / trading queries:
-
query/Trading
-
subscription/Trading
-
query/Tron
- INLINECODE42
Within those roots, Bitquery exposes entities for tasks such as:
- - DEX trades
- token balances and holder analysis
- transfers
- blocks and transactions
- mempool and realtime activity
- market or trading views depending on the root
Always inspect the current schema with -h and use the narrowest _select needed.
For subscriptions specifically:
- - always provide INLINECODE45
- start with a high-frequency root such as INLINECODE46
- prefer direct event shapes before adding INLINECODE47
- treat empty selections or query-oriented shapes as likely application-level errors
Recommended Usage Pattern
- 1. Inspect root arguments first:
-
bitquery-graphql-cli query/EVM -h
- 2. Start with a minimal query on one network:
-
bitquery-graphql-cli query/EVM '{"network":"eth","dataset":"combined","_select":"DEXTrades(limit: {count: 1}) { Transaction { Hash } }"}'
- 3. Add only the fields needed for the task:
- buyers / sellers
- token addresses
- symbols
- amounts
- timestamps
- 4. Narrow with GraphQL arguments inside
_select:
-
limit
-
orderBy
-
where
- 5. Treat large or realtime queries carefully:
- avoid wide selections
- prefer one chain / token / wallet at a time on first pass
- 6. For live subscriptions, start with a known-good high-frequency shape:
- INLINECODE54
Tested Real Scenario
The following authenticated Bitquery flow was verified successfully through uxc:
- - OAuth login with INLINECODE56
- auth binding on INLINECODE57
- GraphQL host help
- INLINECODE58
- authenticated
query/EVM call on INLINECODE60 - daemon-backed
subscription/EVM over WebSocket against live Bitquery infra - repeated live
data events from a BSC mempool transfer stream
The verified query shape was:
CODEBLOCK0
The verified subscription shape was:
CODEBLOCK1
Guardrails
- - Keep automation on JSON output envelope; do not rely on
--text. - Parse stable fields first:
ok, kind, protocol, data, error. - Use
bitquery-graphql-cli as the default command path. - INLINECODE70 is equivalent to
uxc https://streaming.bitquery.io/graphql <operation> .... - Prefer positional JSON for GraphQL calls because
_select is usually required. - Keep
_select small on first pass and add explicit filters before expanding scope. - Prefer
query/* for stable agent workflows. subscription/* is now validated at runtime, but still depends on provider-specific selection shape. - For subscription validation or automation, start with
subscription/EVM and an explicit _select; do not assume an empty selection or subscription/Trading default shape will yield events. - If a subscription opens successfully but immediately returns GraphQL errors, treat that as a query-shape problem before assuming transport failure.
- If auth fails:
- confirm
uxc auth binding match https://streaming.bitquery.io/graphql resolves to
bitquery-graphql
- inspect token state with
uxc auth oauth info bitquery-graphql
- manually refresh with
uxc auth oauth refresh bitquery-graphql
- if needed, rerun
uxc auth oauth login ... --flow client_credentials ...
- - Do not paste temporary IDE tokens into long-lived skill docs. Prefer application-based
client_credentials.
References
- INLINECODE85
Bitquery GraphQL 技能
使用此技能通过 uxc 运行 Bitquery GraphQL API 操作。
复用 uxc 技能进行发现、GraphQL 执行、OAuth 生命周期和通用错误处理。
前提条件
- - uxc 已安装并位于 PATH 中。
- 可访问 https://streaming.bitquery.io/graphql 网络。
- 拥有 Bitquery 应用程序的 clientid 和 clientsecret。
认证
Bitquery 使用 Bearer 访问令牌。最稳定的代理路径是 OAuth client_credentials,而不是复制的临时令牌。
- 1. 创建 Bitquery 应用程序并记录:
- 应用程序 client_id
- 应用程序 client_secret
- 令牌作用域 api
- 2. 使用 OAuth 客户端凭据登录一次:
- uxc auth oauth login bitquery-graphql --endpoint https://streaming.bitquery.io/graphql --flow client
credentials --client-id id> --client-secret --scope api --token-endpoint https://oauth2.bitquery.io/oauth2/token
- 此流程通过一条命令完成。无需浏览器审批页面。
- 3. 绑定 GraphQL 端点:
- uxc auth binding add --id bitquery-graphql --host streaming.bitquery.io --path-prefix /graphql --scheme https --credential bitquery-graphql --priority 100
- 4. 验证认证映射:
- uxc auth binding match https://streaming.bitquery.io/graphql
- uxc auth oauth info bitquery-graphql
核心工作流程
- 1. 默认使用固定链接命令:
- command -v bitquery-graphql-cli
- 如果缺失,创建它:uxc link bitquery-graphql-cli https://streaming.bitquery.io/graphql
- bitquery-graphql-cli -h
- 如果检测到命令冲突且无法安全复用,停止并请技能维护者选择另一个固定命令名称。
- 2. 发现可用的根操作:
- bitquery-graphql-cli -h
- 已验证的根包括 query/EVM、query/Solana、query/Trading、query/Tron 以及对应的 subscription/* 根。
- 3. 检查特定操作:
- bitquery-graphql-cli query/EVM -h
- bitquery-graphql-cli query/Trading -h
- 4. 使用位置 JSON 和显式 GraphQL 选择集执行:
- bitquery-graphql-cli query/EVM {network:base,dataset:combined,_select:DEXTrades(limit: {count: 1}) { Transaction { Hash } }}
- 5. 优先使用 query/* 操作。
- uxc subscribe 现在自动协商现代 graphql-transport-ws 和传统 graphql-ws 兼容性配置文件,用于 subscription/*。
- 当您提供与流友好实体形状匹配的显式 _select 时,实时 Bitquery 订阅验证现在可以成功。
- 优先选择 subscription/EVM 作为第一个验证目标,而不是 subscription/Trading。
能力映射
- query/EVM
- subscription/EVM
- query/Solana
- subscription/Solana
- query/Trading
- subscription/Trading
- query/Tron
- subscription/Tron
在这些根中,Bitquery 为以下任务公开实体:
- - DEX 交易
- 代币余额和持有者分析
- 转账
- 区块和交易
- 内存池和实时活动
- 市场或交易视图(取决于根)
始终使用 -h 检查当前模式,并使用所需的最窄 _select。
对于订阅,特别要注意:
- - 始终提供 _select
- 从高频根开始,例如 subscription/EVM
- 在添加 limit 之前优先选择直接事件形状
- 将空选择或查询导向的形状视为可能的应用程序级错误
推荐使用模式
- 1. 首先检查根参数:
- bitquery-graphql-cli query/EVM -h
- 2. 从一个网络的最小查询开始:
- bitquery-graphql-cli query/EVM {network:eth,dataset:combined,_select:DEXTrades(limit: {count: 1}) { Transaction { Hash } }}
- 3. 仅添加任务所需的字段:
- 买方/卖方
- 代币地址
- 符号
- 数量
- 时间戳
- 4. 使用 _select 内的 GraphQL 参数缩小范围:
- limit
- orderBy
- where
- 5. 谨慎处理大型或实时查询:
- 避免宽泛的选择
- 首次通过时优先选择一条链/一个代币/一个钱包
- 6. 对于实时订阅,从已知良好的高频形状开始:
- ./target/debug/uxc subscribe start https://streaming.bitquery.io/graphql subscription/EVM {network:bsc,mempool:true,_select:Transfers { Transaction { Hash From To } Transfer { Amount Type Currency { Name } } }} --auth bitquery-graphql --sink file:$HOME/.uxc/subscriptions/bitquery-mempool.ndjson
已验证的真实场景
以下经过认证的 Bitquery 流程已通过 uxc 成功验证:
- - 使用 client_credentials 进行 OAuth 登录
- 在 https://streaming.bitquery.io/graphql 上进行认证绑定
- GraphQL 主机帮助
- query/EVM -h
- 在 base 上经过认证的 query/EVM 调用
- 通过 WebSocket 针对实时 Bitquery 基础设施的守护进程支持的 subscription/EVM
- 来自 BSC 内存池转账流的重复实时 data 事件
已验证的查询形状为:
json
{
network: base,
dataset: combined,
_select: DEXTrades(limit: {count: 1}) { Block { Time } Transaction { Hash } Trade { Buy { Amount Buyer Currency { Symbol SmartContract } } Sell { Amount Seller Currency { Symbol SmartContract } } } }
}
已验证的订阅形状为:
json
{
network: bsc,
mempool: true,
_select: Transfers { Transaction { Hash From To } Transfer { Amount Type Currency { Name } } }
}
防护措施
- - 保持自动化使用 JSON 输出格式;不要依赖 --text。
- 首先解析稳定字段:ok、kind、protocol、data、error。
- 使用 bitquery-graphql-cli 作为默认命令路径。
- bitquery-graphql-cli ... 等同于 uxc https://streaming.bitquery.io/graphql ...。
- 优先使用位置 JSON 进行 GraphQL 调用,因为通常需要 select。
- 首次通过时保持
select 较小,并在扩展范围前添加显式过滤器。
对于稳定的代理工作流程,优先使用 query/。subscription/ 现在在运行时已验证,但仍取决于提供者特定的选择形状。对于订阅验证或自动化,从 subscription/EVM 和显式 _select 开始;不要假设空选择或 subscription/Trading 默认形状会产生事件。如果订阅成功打开但立即返回 GraphQL 错误,在假设传输失败之前,将其视为查询形状问题。如果认证失败:
- 确认 uxc auth binding match https://streaming.bitquery.io/graphql 解析为 bitquery-graphql
- 使用 uxc auth oauth info bitquery-graphql 检查令牌状态
- 使用 uxc auth oauth refresh bitquery-graphql 手动刷新
- 如有必要,重新运行 uxc auth oauth login ... --flow client_credentials ...
- - 不要将临时 IDE 令牌粘贴到长期技能文档中。优先使用基于应用程序的 client_credentials。
参考资料
- references/usage-patterns.md