You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python调用Axie Infinity GraphQL接口报introspection result无效如何解决

问题原因与修复方案

核心错误原因

你遇到的报错是因为Axie Infinity的公开GraphQL网关关闭了内省查询功能,fetch_schema_from_transport=True参数会触发客户端主动调用内省接口拉取schema定义,被网关拦截后返回空值,直接抛出你看到的类型错误。

修复步骤

  • 第一步:关闭schema自动拉取,Client初始化时将fetch_schema_from_transport改为False
  • 第二步:补全GraphQL查询的变量声明,同时删掉你没有用到的$criteria参数,避免参数校验失败
  • 第三步:确认你填写的owner字段为正确的0x开头钱包地址

修正后完整代码

from gql import gql, Client
from gql.transport.requests import RequestsHTTPTransport


header = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
    'Content-Type': 'application/json'
}


transport = RequestsHTTPTransport(url="https://graphql-gateway.axieinfinity.com/graphql", headers=header, use_json=True)

# 关闭自动拉取schema
client = Client(transport=transport, fetch_schema_from_transport=False)

# 补全变量声明,删除未使用的criteria参数
query = gql('''
query GetAxieList($auctionType: AuctionType, $from: Int, $sort: Sort, $size: Int, $owner: String) {
    GetAxieBriefList{
  axies(
    auctionType: $auctionType
    from: $from
    sort: $sort
    size: $size
    owner: $owner
  ) {
    total
    results {
      ...AxieBrief
      __typename
    }
    __typename
  }
}

fragment AxieBrief on Axie {
  id
  name
  stage
  class
  breedCount
  image
  title
  battleInfo {
    banned
    __typename
  }
  auction {
    currentPrice
    currentPriceUSD
    __typename
  }
  parts {
    id
    name
    class
    type
    specialGenes
    __typename
  }
  __typename
}
}

''')

variables = {
    "from": 0,
    "size": 100,
    "sort": "IdDesc",
    "auctionType": "All",
    "owner": "替换为你的0x开头钱包地址"
    }

response_query = client.execute(query, variables)

print(response_query)

其他注意事项

如果请求仍然被拦截,可以把User-Agent替换为你本地浏览器的真实UA,避免反爬策略拦截。


内容的提问来源于stack exchange,提问作者Thömmy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.27 03:06:04