请求opensea api失败

我试图通过opensea的graphql api使用request-promise检索一个集合。我用这些参数发送一个请求,作为响应,我一直收到状态码 403。我直接从浏览器复制了参数,它使用 fetch 可以正常工作。

    const options = {
      method: 'POST',
      url: 'https://api.opensea.io/graphql',
      headers: {
        Host: 'api.opensea.io',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36',
        'content-type': 'application/json',
        accept: '*/*',
        origin: 'https://opensea.io',
        'sec-fetch-site': 'same-site',
        'sec-fetch-mode': 'cors',
        'sec-fetch-dest': 'empty',
        referer: 'https://opensea.io/'
      },
      body: {
       id: 'collectionQuery',
       query: 'query collectionQuery(n  $collection: CollectionSlug!n  $collections: [CollectionSlug!]n  $collectionQuery: Stringn  $includeHiddenCollections: Booleann  $numericTraits: [TraitRangeType!]n  $query: Stringn  $sortAscending: Booleann  $sortBy: SearchSortByn  $stringTraits: [TraitInputType!]n  $toggles: [SearchToggle!]n  $showContextMenu: Booleann) {n  collection(collection: $collection) {n    isEditablen    bannerImageUrln    namen    descriptionn    imageUrln    relayIdn    representativeAsset {n      assetContract {n        openseaVersionn        idn      }n      idn    }n    ...collection_urln    ...CollectionHeader_datan    idn  }n  assets: query {n    ...AssetSearch_data_1bS60nn  }n}nnfragment AssetCardContent_asset on AssetType {n  relayIdn  namen  ...AssetMedia_assetn  assetContract {n    addressn    chainn    openseaVersionn    idn  }n  tokenIdn  collection {n    slugn    idn  }n  isDelistedn}nnfragment AssetCardContent_assetBundle on AssetBundleType {n  assetQuantities(first: 18) {n    edges {n      node {n        asset {n          relayIdn          ...AssetMedia_assetn          idn        }n        idn      }n    }n  }n}nnfragment AssetCardFooter_assetBundle on AssetBundleType {n  namen  assetCountn  assetQuantities(first: 18) {n    edges {n      node {n        asset {n          collection {n            namen            relayIdn            isVerifiedn            ...collection_urln            idn          }n          idn        }n        idn      }n    }n  }n  assetEventData {n    lastSale {n      unitPriceQuantity {n        ...AssetQuantity_datan        idn      }n    }n  }n  orderData {n    bestBid {n      orderTypen      paymentAssetQuantity {n        ...AssetQuantity_datan        idn      }n    }n    bestAsk {n      closedAtn      orderTypen      dutchAuctionFinalPricen      openedAtn      priceFnEndedAtn      quantityn      decimalsn      paymentAssetQuantity {n        quantityn        ...AssetQuantity_datan        idn      }n    }n  }n}nnfragment AssetCardFooter_asset_2V84VL on AssetType {n  namen  tokenIdn  collection {n    namen    isVerifiedn    ...collection_urln    idn  }n  hasUnlockableContentn  isDelistedn  isFrozenn  assetContract {n    addressn    chainn    openseaVersionn    idn  }n  assetEventData {n    firstTransfer {n      timestampn    }n    lastSale {n      unitPriceQuantity {n        ...AssetQuantity_datan        idn      }n    }n  }n  decimalsn  orderData {n    bestBid {n      orderTypen      paymentAssetQuantity {n        ...AssetQuantity_datan        idn      }n    }n    bestAsk {n      closedAtn      orderTypen      dutchAuctionFinalPricen      openedAtn      priceFnEndedAtn      quantityn      decimalsn      paymentAssetQuantity {n        quantityn        ...AssetQuantity_datan        idn      }n    }n  }n}nnfragment AssetCardHeader_data_27d9G3 on AssetType {n  relayIdn  favoritesCountn  isDelistedn  isFavoriten  ...AssetContextMenu_data_3z4lq0 @include(if: $showContextMenu)n}nnfragment AssetContextMenu_data_3z4lq0 on AssetType {n  ...asset_edit_urln  ...asset_urln  ...itemEvents_datan  isDelistedn  isEditable {n    valuen    reasonn  }n  isListablen  ownership(identity: {}) {n    isPrivaten    quantityn  }n  creator {n    addressn    idn  }n  collection {n    isAuthorizedEditorn    idn  }n}nnfragment AssetMedia_asset on AssetType {n  animationUrln  backgroundColorn  collection {n    displayData {n      cardDisplayStylen    }n    idn  }n  isDelistedn  displayImageUrln}nnfragment AssetQuantity_data on AssetQuantityType {n  asset {n    ...Price_datan    idn  }n  quantityn}nnfragment AssetSearchFilter_data_1GloFv on Query {n  ...CollectionFilter_data_tXjHbn  collection(collection: $collection) {n    numericTraits {n      keyn      value {n        maxn        minn      }n      ...NumericTraitFilter_datan    }n    stringTraits {n      keyn      ...StringTraitFilter_datan    }n    idn  }n  ...PaymentFilter_data_2YoIWtn}nnfragment AssetSearchList_data_gVyhu on SearchResultType {n  asset {n    assetContract {n      addressn      chainn      idn    }n    collection {n      isVerifiedn      idn    }n    relayIdn    tokenIdn    ...AssetSelectionItem_datan    ...asset_urln    idn  }n  assetBundle {n    relayIdn    idn  }n  ...Asset_data_gVyhun}nnfragment AssetSearch_data_1bS60n on Query {n  ...CollectionHeadMetadata_data_2YoIWtn  ...AssetSearchFilter_data_1GloFvn  ...SearchPills_data_2Kg4Sqn  search(collections: $collections, first: 32, numericTraits: $numericTraits, querystring: $query, resultType: ASSETS, sortAscending: $sortAscending, sortBy: $sortBy, stringTraits: $stringTraits, toggles: $toggles) {n    edges {n      node {n        ...AssetSearchList_data_gVyhun        __typenamen      }n      cursorn    }n    totalCountn    pageInfo {n      endCursorn      hasNextPagen    }n  }n}nnfragment AssetSelectionItem_data on AssetType {n  backgroundColorn  collection {n    displayData {n      cardDisplayStylen    }n    imageUrln    idn  }n  imageUrln  namen  relayIdn}nnfragment Asset_data_gVyhu on SearchResultType {n  asset {n    isDelistedn    ...AssetCardHeader_data_27d9G3n    ...AssetCardContent_assetn    ...AssetCardFooter_asset_2V84VLn    ...AssetMedia_assetn    ...asset_urln    ...itemEvents_datan    idn  }n  assetBundle {n    ...bundle_urln    ...AssetCardContent_assetBundlen    ...AssetCardFooter_assetBundlen    idn  }n}nnfragment CollectionFilter_data_tXjHb on Query {n  selectedCollections: collections(first: 25, collections: $collections, includeHidden: true) {n    edges {n      node {n        assetCountn        imageUrln        namen        slugn        isVerifiedn        idn      }n    }n  }n  collections(first: 100, includeHidden: $includeHiddenCollections, query: $collectionQuery, sortBy: SEVEN_DAY_VOLUME) {n    edges {n      node {n        assetCountn        imageUrln        namen        slugn        isVerifiedn        idn        __typenamen      }n      cursorn    }n    pageInfo {n      endCursorn      hasNextPagen    }n  }n}nnfragment CollectionHeadMetadata_data_2YoIWt on Query {n  collection(collection: $collection) {n    bannerImageUrln    descriptionn    imageUrln    namen    idn  }n}nnfragment CollectionHeader_data on CollectionType {n  namen  descriptionn  imageUrln  bannerImageUrln  ...CollectionStatsBar_datan  ...SocialBar_datan  ...verification_datan}nnfragment CollectionModalContent_data on CollectionType {n  descriptionn  imageUrln  namen  slugn}nnfragment CollectionStatsBar_data on CollectionType {n  stats {n    numOwnersn    totalSupplyn    totalVolumen    idn  }n  slugn  floorPricen}nnfragment NumericTraitFilter_data on NumericTraitTypePair {n  keyn  value {n    maxn    minn  }n}nnfragment PaymentFilter_data_2YoIWt on Query {n  paymentAssets(first: 10) {n    edges {n      node {n        symboln        relayIdn        idn        __typenamen      }n      cursorn    }n    pageInfo {n      endCursorn      hasNextPagen    }n  }n  PaymentFilter_collection: collection(collection: $collection) {n    paymentAssets {n      symboln      relayIdn      idn    }n    idn  }n}nnfragment Price_data on AssetType {n  decimalsn  imageUrln  symboln  usdSpotPricen  assetContract {n    blockExplorerLinkn    chainn    idn  }n}nnfragment SearchPills_data_2Kg4Sq on Query {n  selectedCollections: collections(first: 25, collections: $collections, includeHidden: true) {n    edges {n      node {n        imageUrln        namen        slugn        ...CollectionModalContent_datan        idn      }n    }n  }n}nnfragment SocialBar_data on CollectionType {n  relayIdn  discordUrln  externalUrln  instagramUsernamen  mediumUsernamen  slugn  telegramUrln  twitterUsernamen  ...collection_urln}nnfragment StringTraitFilter_data on StringTraitType {n  counts {n    countn    valuen  }n  keyn}nnfragment asset_edit_url on AssetType {n  assetContract {n    addressn    chainn    idn  }n  tokenIdn  collection {n    slugn    idn  }n}nnfragment asset_url on AssetType {n  assetContract {n    addressn    chainn    idn  }n  tokenIdn}nnfragment bundle_url on AssetBundleType {n  slugn}nnfragment collection_url on CollectionType {n  slugn}nnfragment itemEvents_data on AssetType {n  assetContract {n    addressn    chainn    idn  }n  tokenIdn}nnfragment verification_data on CollectionType {n  isMintablen  isSafelistedn  isVerifiedn}n',
       variables: {
        collection: 'beeple-special-edition',
        collections: ['beeple-special-edition'],
        collectionQuery: null,
        includeHiddenCollections: null,
        numericTraits: null,
        query: null,
        sortAscending: true,
        sortBy: 'PRICE',
        stringTraits: null,
        toggles: null,
        showContextMenu: true
    }
  }

这会导致响应状态代码 403 并在响应正文中显示 error code: 1020

stack overflow Request to opensea api failing
原文答案

答案:

作者头像

不幸的是,OpenSea 目前有 CloudFlaire 保护他们的 GraphQL 端点,这意味着开发人员还不能使用它。 This issue 已提交,但 OpenSea 尚未回复

作者头像

嘿,我可以毫无问题地访问它