bitquery-graphql-skill
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBitquery GraphQL Skill
Bitquery GraphQL Skill
Use this skill to run Bitquery GraphQL API operations through .
uxcReuse the skill for discovery, GraphQL execution, OAuth lifecycle, and generic error handling.
uxc使用本Skill通过执行Bitquery GraphQL API操作。
uxc复用 Skill来实现服务发现、GraphQL执行、OAuth生命周期管理以及通用错误处理。
uxcPrerequisites
前提条件
- is installed and available in
uxc.PATH - Network access to .
https://streaming.bitquery.io/graphql - A Bitquery application and
client_idare available.client_secret
- 已安装且其路径已添加至
uxc环境变量。PATH - 能够访问网络地址。
https://streaming.bitquery.io/graphql - 拥有Bitquery应用的和
client_id。client_secret
Authentication
认证方式
Bitquery uses bearer access tokens. The most stable agent path is OAuth , not a copied temporary token.
client_credentials- Create a Bitquery application and note:
- application
client_id - application
client_secret - token scope
api
- application
- 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.
- 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
- Verify auth mapping:
uxc auth binding match https://streaming.bitquery.io/graphqluxc auth oauth info bitquery-graphql
Bitquery使用Bearer访问令牌。最稳定的代理方式是采用OAuth 授权流程,而非复制临时令牌。
client_credentials- 创建一个Bitquery应用并记录以下信息:
- 应用的
client_id - 应用的
client_secret - 令牌权限范围
api
- 应用的
- 使用OAuth客户端凭证登录一次:
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- 该流程通过一条命令即可完成,无需浏览器授权页面。
- 绑定GraphQL端点:
uxc auth binding add --id bitquery-graphql --host streaming.bitquery.io --path-prefix /graphql --scheme https --credential bitquery-graphql --priority 100
- 验证认证映射:
uxc auth binding match https://streaming.bitquery.io/graphqluxc auth oauth info bitquery-graphql
Core Workflow
核心工作流程
- 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.
- Discover available root operations:
bitquery-graphql-cli -h- Verified roots currently include ,
query/EVM,query/Solana,query/Trading, and matchingquery/Tronroots.subscription/*
- Inspect a specific operation:
bitquery-graphql-cli query/EVM -hbitquery-graphql-cli query/Trading -h
- 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 } }"}'
- Prefer operations first.
query/*- now auto-negotiates modern
uxc subscribeand legacygraphql-transport-wscompatibility profiles forgraphql-ws.subscription/* - Live Bitquery subscription validation now succeeds when you provide an explicit that matches a stream-friendly entity shape.
_select - Prefer as the first validation target rather than
subscription/EVM.subscription/Trading
- 默认使用固定链接命令:
command -v bitquery-graphql-cli- 若该命令不存在,创建它:
uxc link bitquery-graphql-cli https://streaming.bitquery.io/graphql bitquery-graphql-cli -h- 若检测到命令冲突且无法安全复用,请停止操作并联系Skill维护者选择其他固定命令名称。
- 发现可用的根操作:
bitquery-graphql-cli -h- 当前已验证的根操作包括、
query/EVM、query/Solana、query/Trading以及对应的query/Tron根操作。subscription/*
- 查看特定操作详情:
bitquery-graphql-cli query/EVM -hbitquery-graphql-cli query/Trading -h
- 使用位置参数JSON和显式GraphQL选择集执行操作:
bitquery-graphql-cli query/EVM '{"network":"base","dataset":"combined","_select":"DEXTrades(limit: {count: 1}) { Transaction { Hash } }"}'
- 优先使用操作。
query/*- 对于根操作,
subscription/*现在会自动协商现代uxc subscribe和旧版graphql-transport-ws的兼容配置。graphql-ws - 当你提供与流式友好实体结构匹配的显式时,Bitquery实时订阅验证现在会成功。
_select - 优先选择作为首个验证目标,而非
subscription/EVM。subscription/Trading
- 对于
Capability Map
能力映射
- EVM onchain queries:
query/EVMsubscription/EVM
- Solana onchain queries:
query/Solanasubscription/Solana
- Cross-market / trading queries:
query/Tradingsubscription/Trading
- Tron onchain queries:
query/Tronsubscription/Tron
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 and use the narrowest needed.
-h_selectFor subscriptions specifically:
- always provide
_select - start with a high-frequency root such as
subscription/EVM - prefer direct event shapes before adding
limit - treat empty selections or query-oriented shapes as likely application-level errors
- EVM链上查询:
query/EVMsubscription/EVM
- Solana链上查询:
query/Solanasubscription/Solana
- 跨市场/交易查询:
query/Tradingsubscription/Trading
- Tron链上查询:
query/Tronsubscription/Tron
在这些根操作中,Bitquery提供了适用于以下任务的实体:
- DEX交易
- 代币余额与持有者分析
- 转账
- 区块与交易
- 内存池与实时活动
- 基于根操作的市场或交易视图
始终使用查看当前模式,并使用所需的最精简。
-h_select针对订阅的特殊说明:
- 始终提供
_select - 从高频根操作开始,例如
subscription/EVM - 在添加之前优先使用直接事件结构
limit - 将空选择集或面向查询的结构视为可能的应用级错误
Recommended Usage Pattern
推荐使用模式
- Inspect root arguments first:
bitquery-graphql-cli query/EVM -h
- Start with a minimal query on one network:
bitquery-graphql-cli query/EVM '{"network":"eth","dataset":"combined","_select":"DEXTrades(limit: {count: 1}) { Transaction { Hash } }"}'
- Add only the fields needed for the task:
- buyers / sellers
- token addresses
- symbols
- amounts
- timestamps
- Narrow with GraphQL arguments inside :
_selectlimitorderBywhere
- Treat large or realtime queries carefully:
- avoid wide selections
- prefer one chain / token / wallet at a time on first pass
- For live subscriptions, start with a known-good high-frequency shape:
./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-graphql-cli query/EVM -h
- 从单个网络的最小查询开始:
bitquery-graphql-cli query/EVM '{"network":"eth","dataset":"combined","_select":"DEXTrades(limit: {count: 1}) { Transaction { Hash } }"}'
- 仅添加任务所需的字段:
- 买家/卖家
- 代币地址
- 代币符号
- 金额
- 时间戳
- 在内使用GraphQL参数缩小范围:
_selectlimitorderBywhere
- 谨慎处理大型或实时查询:
- 避免宽泛的选择集
- 首次执行时优先一次处理一条链/一个代币/一个钱包
- 对于实时订阅,从已知可用的高频结构开始:
./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
Tested Real Scenario
已测试的真实场景
The following authenticated Bitquery flow was verified successfully through :
uxc- OAuth login with
client_credentials - auth binding on
https://streaming.bitquery.io/graphql - GraphQL host help
query/EVM -h- authenticated call on
query/EVMbase - daemon-backed over WebSocket against live Bitquery infra
subscription/EVM - repeated live events from a BSC mempool transfer stream
data
The verified query shape was:
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 } } } }"
}The verified subscription shape was:
json
{
"network": "bsc",
"mempool": true,
"_select": "Transfers { Transaction { Hash From To } Transfer { Amount Type Currency { Name } } }"
}以下经过认证的Bitquery流程已通过成功验证:
uxc- 使用进行OAuth登录
client_credentials - 在上绑定认证
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 } } }"
}Guardrails
注意事项
- Keep automation on JSON output envelope; do not rely on .
--text - Parse stable fields first: ,
ok,kind,protocol,data.error - Use as the default command path.
bitquery-graphql-cli - is equivalent to
bitquery-graphql-cli <operation> ....uxc https://streaming.bitquery.io/graphql <operation> ... - Prefer positional JSON for GraphQL calls because is usually required.
_select - Keep small on first pass and add explicit filters before expanding scope.
_select - Prefer for stable agent workflows.
query/*is now validated at runtime, but still depends on provider-specific selection shape.subscription/* - For subscription validation or automation, start with and an explicit
subscription/EVM; do not assume an empty selection or_selectdefault shape will yield events.subscription/Trading - 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 resolves to
uxc auth binding match https://streaming.bitquery.io/graphqlbitquery-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 ...
- confirm
- Do not paste temporary IDE tokens into long-lived skill docs. Prefer application-based .
client_credentials
- 自动化流程依赖JSON输出格式,不要依赖格式。
--text - 优先解析稳定字段:、
ok、kind、protocol、data。error - 使用作为默认命令路径。
bitquery-graphql-cli - 等价于
bitquery-graphql-cli <operation> ...。uxc https://streaming.bitquery.io/graphql <operation> ... - GraphQL调用优先使用位置参数JSON,因为通常需要。
_select - 首次执行时保持精简,在扩大范围前添加显式过滤器。
_select - 稳定的代理工作流优先使用操作。
query/*现在会在运行时验证,但仍依赖于服务商特定的选择集结构。subscription/* - 对于订阅验证或自动化,从和显式
subscription/EVM开始;不要假设空选择集或_select默认结构会产生事件。subscription/Trading - 如果订阅成功建立但立即返回GraphQL错误,先将其视为查询结构问题,再考虑传输故障。
- 如果认证失败:
- 确认解析到
uxc auth binding match https://streaming.bitquery.io/graphqlbitquery-graphql - 使用查看令牌状态
uxc auth oauth info bitquery-graphql - 使用手动刷新令牌
uxc auth oauth refresh bitquery-graphql - 如有必要,重新运行命令
uxc auth oauth login ... --flow client_credentials ...
- 确认
- 不要将临时IDE令牌粘贴到长期使用的Skill文档中,优先使用基于应用的。
client_credentials
References
参考资料
- Invocation patterns:
references/usage-patterns.md
- 调用模式:
references/usage-patterns.md