· 4 years ago · Jun 20, 2021, 07:06 PM
1const fetch = require("node-fetch");
2const data = {"id":"AssetSearchQuery","query":"query AssetSearchQuery(\n $categories: [CollectionSlug!]\n $chains: [ChainScalar!]\n $collection: CollectionSlug\n $collectionQuery: String\n $collectionSortBy: CollectionSort\n $collections: [CollectionSlug!]\n $count: Int\n $cursor: String\n $identity: IdentityInputType\n $includeHiddenCollections: Boolean\n $includeIsListable: Boolean = false\n $numericTraits: [TraitRangeType!]\n $paymentAssets: [PaymentAssetSymbol!]\n $priceFilter: PriceFilterType\n $query: String\n $resultModel: SearchResultModel\n $shouldShowQuantity: Boolean = false\n $sortAscending: Boolean\n $sortBy: SearchSortBy\n $stringTraits: [TraitInputType!]\n $toggles: [SearchToggle!]\n) {\n query {\n ...AssetSearch_data_1tAP2Z\n }\n}\n\nfragment AssetCardContent_assetBundle on AssetBundleType {\n assetQuantities(first: 18) {\n edges {\n node {\n asset {\n relayId\n ...AssetMedia_asset\n id\n }\n id\n }\n }\n }\n}\n\nfragment AssetCardContent_asset_1kiIrM on AssetType {\n ...AssetMedia_asset\n assetContract {\n account {\n address\n chain {\n identifier\n id\n }\n id\n }\n openseaVersion\n id\n }\n tokenId\n collection {\n slug\n id\n }\n isDelisted\n}\n\nfragment AssetCardFooter_assetBundle on AssetBundleType {\n name\n assetQuantities(first: 18) {\n edges {\n node {\n asset {\n collection {\n name\n relayId\n id\n }\n id\n }\n id\n }\n }\n }\n assetEventData {\n lastSale {\n unitPriceQuantity {\n ...AssetQuantity_data\n id\n }\n }\n }\n orderData {\n bestBid {\n orderType\n paymentAssetQuantity {\n ...AssetQuantity_data\n id\n }\n }\n bestAsk {\n closedAt\n orderType\n dutchAuctionFinalPrice\n openedAt\n priceFnEndedAt\n quantity\n decimals\n paymentAssetQuantity {\n quantity\n ...AssetQuantity_data\n id\n }\n }\n }\n}\n\nfragment AssetCardFooter_asset_fdERL on AssetType {\n ownedQuantity(identity: $identity) @include(if: $shouldShowQuantity)\n name\n tokenId\n collection {\n name\n id\n }\n hasUnlockableContent\n isDelisted\n assetContract {\n account {\n address\n chain {\n identifier\n id\n }\n id\n }\n openseaVersion\n id\n }\n assetEventData {\n firstTransfer {\n timestamp\n }\n lastSale {\n unitPriceQuantity {\n ...AssetQuantity_data\n id\n }\n }\n }\n decimals\n orderData {\n bestBid {\n orderType\n paymentAssetQuantity {\n ...AssetQuantity_data\n id\n }\n }\n bestAsk {\n closedAt\n orderType\n dutchAuctionFinalPrice\n openedAt\n priceFnEndedAt\n quantity\n decimals\n paymentAssetQuantity {\n quantity\n ...AssetQuantity_data\n id\n }\n }\n }\n}\n\nfragment AssetCardHeader_data on AssetType {\n relayId\n favoritesCount\n isDelisted\n isFavorite\n}\n\nfragment AssetMedia_asset on AssetType {\n animationUrl\n backgroundColor\n collection {\n description\n displayData {\n cardDisplayStyle\n }\n imageUrl\n hidden\n name\n slug\n id\n }\n description\n name\n tokenId\n imageUrl\n isDelisted\n}\n\nfragment AssetQuantity_data on AssetQuantityType {\n asset {\n ...Price_data\n id\n }\n quantity\n}\n\nfragment AssetSearchFilter_data_3zwQJ6 on Query {\n ...CollectionFilter_data_1W5IQW\n collection(collection: $collection) {\n numericTraits {\n key\n value {\n max\n min\n }\n ...NumericTraitFilter_data\n }\n stringTraits {\n key\n ...StringTraitFilter_data\n }\n id\n }\n ...PaymentFilter_data_2YoIWt\n}\n\nfragment AssetSearchList_data_3ZVFPC on SearchResultType {\n asset {\n assetContract {\n account {\n address\n chain {\n identifier\n id\n }\n id\n }\n id\n }\n isListable @include(if: $includeIsListable)\n relayId\n tokenId\n ...AssetSelectionItem_data\n ...asset_url\n id\n }\n assetBundle {\n relayId\n id\n }\n ...Asset_data_28Onen\n}\n\nfragment AssetSearch_data_1tAP2Z on Query {\n ...CollectionHeadMetadata_data_2YoIWt\n ...AssetSearchFilter_data_3zwQJ6\n ...CategoryBar_data\n ...SearchPills_data_2Kg4Sq\n search(after: $cursor, chains: $chains, categories: $categories, collections: $collections, first: $count, identity: $identity, numericTraits: $numericTraits, paymentAssets: $paymentAssets, priceFilter: $priceFilter, querystring: $query, resultType: $resultModel, sortAscending: $sortAscending, sortBy: $sortBy, stringTraits: $stringTraits, toggles: $toggles) {\n edges {\n node {\n ...AssetSearchList_data_3ZVFPC\n __typename\n }\n cursor\n }\n totalCount\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n\nfragment AssetSelectionItem_data on AssetType {\n backgroundColor\n collection {\n displayData {\n cardDisplayStyle\n }\n imageUrl\n id\n }\n imageUrl\n name\n relayId\n}\n\nfragment Asset_data_28Onen on SearchResultType {\n asset {\n assetContract {\n account {\n chain {\n identifier\n id\n }\n id\n }\n id\n }\n isDelisted\n ...AssetCardHeader_data\n ...AssetCardContent_asset_1kiIrM\n ...AssetCardFooter_asset_fdERL\n ...AssetMedia_asset\n ...asset_url\n id\n }\n assetBundle {\n slug\n assetCount\n ...AssetCardContent_assetBundle\n ...AssetCardFooter_assetBundle\n id\n }\n}\n\nfragment CategoryBar_data on Query {\n categories {\n imageUrl\n name\n slug\n }\n}\n\nfragment CollectionFilter_data_1W5IQW on Query {\n selectedCollections: collections(first: 25, collections: $collections, includeHidden: true) {\n edges {\n node {\n assetCount\n imageUrl\n name\n slug\n id\n }\n }\n }\n collections(assetOwner: $identity, chains: $chains, first: 100, includeHidden: $includeHiddenCollections, parents: $categories, query: $collectionQuery, sortBy: $collectionSortBy) {\n edges {\n node {\n assetCount\n imageUrl\n name\n slug\n id\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n\nfragment CollectionHeadMetadata_data_2YoIWt on Query {\n collection(collection: $collection) {\n bannerImageUrl\n description\n imageUrl\n name\n id\n }\n}\n\nfragment CollectionModalContent_data on CollectionType {\n description\n imageUrl\n name\n slug\n}\n\nfragment NumericTraitFilter_data on NumericTraitTypePair {\n key\n value {\n max\n min\n }\n}\n\nfragment PaymentFilter_data_2YoIWt on Query {\n paymentAssets(first: 10) {\n edges {\n node {\n asset {\n symbol\n id\n }\n relayId\n id\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n PaymentFilter_collection: collection(collection: $collection) {\n paymentAssets {\n asset {\n symbol\n id\n }\n relayId\n id\n }\n id\n }\n}\n\nfragment Price_data on AssetType {\n decimals\n imageUrl\n symbol\n usdSpotPrice\n assetContract {\n blockExplorerLink\n id\n }\n}\n\nfragment SearchPills_data_2Kg4Sq on Query {\n selectedCollections: collections(first: 25, collections: $collections, includeHidden: true) {\n edges {\n node {\n imageUrl\n name\n slug\n ...CollectionModalContent_data\n id\n }\n }\n }\n}\n\nfragment StringTraitFilter_data on StringTraitType {\n counts {\n count\n value\n }\n key\n}\n\nfragment asset_url on AssetType {\n assetContract {\n account {\n address\n chain {\n identifier\n id\n }\n id\n }\n id\n }\n tokenId\n}\n","variables":{"categories":null,"chains":null,"collection":"myfuckingpickle","collectionQuery":null,"collectionSortBy":"SEVEN_DAY_VOLUME","collections":["myfuckingpickle"],"count":32,"cursor":null,"identity":null,"includeHiddenCollections":true,"includeIsListable":false,"numericTraits":null,"paymentAssets":null,"priceFilter":null,"query":"","resultModel":null,"shouldShowQuantity":false,"sortAscending":true,"sortBy":"PRICE","stringTraits":null,"toggles":["BUY_NOW"]}}
3const headers = {
4 "accept": "*/*",
5 "accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
6 "content-type": "application/json",
7 "sec-fetch-dest": "empty",
8 "sec-fetch-mode": "cors",
9 "sec-fetch-site": "same-site",
10 "x-api-key": "your api key",
11 "x-build-id": "your build id",
12 "x-viewer-address": "your ethereum address (or anyone elses)",
13 "x-viewer-chain": "ETHEREUM"
14 }
15
16const init = async () => {
17 const request = await fetch("https://api.opensea.io/graphql/", {method: 'post', body: JSON.stringify(data), headers})
18 if(request.ok) {
19 const response = await request.json();
20 const pickles = response.data.query.search.edges;
21 }
22}
23
24init()
25