请求公海API失败 [英] Request to opensea api failing
本文介绍了请求公海API失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Request-Promise通过OpenSEA的GraphQL API检索集合。我正在发送具有这些参数的请求,作为响应,我不断收到状态代码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(
$collection: CollectionSlug!
$collections: [CollectionSlug!]
$collectionQuery: String
$includeHiddenCollections: Boolean
$numericTraits: [TraitRangeType!]
$query: String
$sortAscending: Boolean
$sortBy: SearchSortBy
$stringTraits: [TraitInputType!]
$toggles: [SearchToggle!]
$showContextMenu: Boolean
) {
collection(collection: $collection) {
isEditable
bannerImageUrl
name
description
imageUrl
relayId
representativeAsset {
assetContract {
openseaVersion
id
}
id
}
...collection_url
...CollectionHeader_data
id
}
assets: query {
...AssetSearch_data_1bS60n
}
}
fragment AssetCardContent_asset on AssetType {
relayId
name
...AssetMedia_asset
assetContract {
address
chain
openseaVersion
id
}
tokenId
collection {
slug
id
}
isDelisted
}
fragment AssetCardContent_assetBundle on AssetBundleType {
assetQuantities(first: 18) {
edges {
node {
asset {
relayId
...AssetMedia_asset
id
}
id
}
}
}
}
fragment AssetCardFooter_assetBundle on AssetBundleType {
name
assetCount
assetQuantities(first: 18) {
edges {
node {
asset {
collection {
name
relayId
isVerified
...collection_url
id
}
id
}
id
}
}
}
assetEventData {
lastSale {
unitPriceQuantity {
...AssetQuantity_data
id
}
}
}
orderData {
bestBid {
orderType
paymentAssetQuantity {
...AssetQuantity_data
id
}
}
bestAsk {
closedAt
orderType
dutchAuctionFinalPrice
openedAt
priceFnEndedAt
quantity
decimals
paymentAssetQuantity {
quantity
...AssetQuantity_data
id
}
}
}
}
fragment AssetCardFooter_asset_2V84VL on AssetType {
name
tokenId
collection {
name
isVerified
...collection_url
id
}
hasUnlockableContent
isDelisted
isFrozen
assetContract {
address
chain
openseaVersion
id
}
assetEventData {
firstTransfer {
timestamp
}
lastSale {
unitPriceQuantity {
...AssetQuantity_data
id
}
}
}
decimals
orderData {
bestBid {
orderType
paymentAssetQuantity {
...AssetQuantity_data
id
}
}
bestAsk {
closedAt
orderType
dutchAuctionFinalPrice
openedAt
priceFnEndedAt
quantity
decimals
paymentAssetQuantity {
quantity
...AssetQuantity_data
id
}
}
}
}
fragment AssetCardHeader_data_27d9G3 on AssetType {
relayId
favoritesCount
isDelisted
isFavorite
...AssetContextMenu_data_3z4lq0 @include(if: $showContextMenu)
}
fragment AssetContextMenu_data_3z4lq0 on AssetType {
...asset_edit_url
...asset_url
...itemEvents_data
isDelisted
isEditable {
value
reason
}
isListable
ownership(identity: {}) {
isPrivate
quantity
}
creator {
address
id
}
collection {
isAuthorizedEditor
id
}
}
fragment AssetMedia_asset on AssetType {
animationUrl
backgroundColor
collection {
displayData {
cardDisplayStyle
}
id
}
isDelisted
displayImageUrl
}
fragment AssetQuantity_data on AssetQuantityType {
asset {
...Price_data
id
}
quantity
}
fragment AssetSearchFilter_data_1GloFv on Query {
...CollectionFilter_data_tXjHb
collection(collection: $collection) {
numericTraits {
key
value {
max
min
}
...NumericTraitFilter_data
}
stringTraits {
key
...StringTraitFilter_data
}
id
}
...PaymentFilter_data_2YoIWt
}
fragment AssetSearchList_data_gVyhu on SearchResultType {
asset {
assetContract {
address
chain
id
}
collection {
isVerified
id
}
relayId
tokenId
...AssetSelectionItem_data
...asset_url
id
}
assetBundle {
relayId
id
}
...Asset_data_gVyhu
}
fragment AssetSearch_data_1bS60n on Query {
...CollectionHeadMetadata_data_2YoIWt
...AssetSearchFilter_data_1GloFv
...SearchPills_data_2Kg4Sq
search(collections: $collections, first: 32, numericTraits: $numericTraits, querystring: $query, resultType: ASSETS, sortAscending: $sortAscending, sortBy: $sortBy, stringTraits: $stringTraits, toggles: $toggles) {
edges {
node {
...AssetSearchList_data_gVyhu
__typename
}
cursor
}
totalCount
pageInfo {
endCursor
hasNextPage
}
}
}
fragment AssetSelectionItem_data on AssetType {
backgroundColor
collection {
displayData {
cardDisplayStyle
}
imageUrl
id
}
imageUrl
name
relayId
}
fragment Asset_data_gVyhu on SearchResultType {
asset {
isDelisted
...AssetCardHeader_data_27d9G3
...AssetCardContent_asset
...AssetCardFooter_asset_2V84VL
...AssetMedia_asset
...asset_url
...itemEvents_data
id
}
assetBundle {
...bundle_url
...AssetCardContent_assetBundle
...AssetCardFooter_assetBundle
id
}
}
fragment CollectionFilter_data_tXjHb on Query {
selectedCollections: collections(first: 25, collections: $collections, includeHidden: true) {
edges {
node {
assetCount
imageUrl
name
slug
isVerified
id
}
}
}
collections(first: 100, includeHidden: $includeHiddenCollections, query: $collectionQuery, sortBy: SEVEN_DAY_VOLUME) {
edges {
node {
assetCount
imageUrl
name
slug
isVerified
id
__typename
}
cursor
}
pageInfo {
endCursor
hasNextPage
}
}
}
fragment CollectionHeadMetadata_data_2YoIWt on Query {
collection(collection: $collection) {
bannerImageUrl
description
imageUrl
name
id
}
}
fragment CollectionHeader_data on CollectionType {
name
description
imageUrl
bannerImageUrl
...CollectionStatsBar_data
...SocialBar_data
...verification_data
}
fragment CollectionModalContent_data on CollectionType {
description
imageUrl
name
slug
}
fragment CollectionStatsBar_data on CollectionType {
stats {
numOwners
totalSupply
totalVolume
id
}
slug
floorPrice
}
fragment NumericTraitFilter_data on NumericTraitTypePair {
key
value {
max
min
}
}
fragment PaymentFilter_data_2YoIWt on Query {
paymentAssets(first: 10) {
edges {
node {
symbol
relayId
id
__typename
}
cursor
}
pageInfo {
endCursor
hasNextPage
}
}
PaymentFilter_collection: collection(collection: $collection) {
paymentAssets {
symbol
relayId
id
}
id
}
}
fragment Price_data on AssetType {
decimals
imageUrl
symbol
usdSpotPrice
assetContract {
blockExplorerLink
chain
id
}
}
fragment SearchPills_data_2Kg4Sq on Query {
selectedCollections: collections(first: 25, collections: $collections, includeHidden: true) {
edges {
node {
imageUrl
name
slug
...CollectionModalContent_data
id
}
}
}
}
fragment SocialBar_data on CollectionType {
relayId
discordUrl
externalUrl
instagramUsername
mediumUsername
slug
telegramUrl
twitterUsername
...collection_url
}
fragment StringTraitFilter_data on StringTraitType {
counts {
count
value
}
key
}
fragment asset_edit_url on AssetType {
assetContract {
address
chain
id
}
tokenId
collection {
slug
id
}
}
fragment asset_url on AssetType {
assetContract {
address
chain
id
}
tokenId
}
fragment bundle_url on AssetBundleType {
slug
}
fragment collection_url on CollectionType {
slug
}
fragment itemEvents_data on AssetType {
assetContract {
address
chain
id
}
tokenId
}
fragment verification_data on CollectionType {
isMintable
isSafelisted
isVerified
}
',
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
OpenSea
不幸的是,推荐答案目前有CloudFlaire保护他们的GraphQL端点,这意味着开发人员还不能使用它。 This issue已提交,但OpenSea尚未回复
这篇关于请求公海API失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文