4

I tried https://docs.opensea.io/reference opensea.io docs to fetch data. However, I think there are 2 APIs.

curl --request GET \
     --url https://api.opensea.io/api/v1/asset/0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb/1/

This is for a single asset and it requires a token id as well. But I want data of all the NFTs of a particular smart contract address just by giving the smart contract address.

And this is for a single contract.

curl --request GET \
     --url https://api.opensea.io/api/v1/asset_contract/0x06012c8cf97bead5deae237070f9587f8e7a266d
Haider Yaqoob
  • 1,725
  • 2
  • 11
  • 17

1 Answers1

5

The assets endpoint (docs) has the asset_contract_address filter that allows you to filter by a contract address. Which will effectively allow you to paginate through all NFTs of the contract (that Opensea knows of).

Example:

curl 'https://api.opensea.io/api/v1/assets?offset=0&limit=20&asset_contract_address=0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb'
Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • 1
    Thanks for your assistance. Is that possible to get all the NFTs of a particular asset_contract_address without pagination? Because I can see there is a max limit: 50 However, I want to perform computation on each NFT of any asset_contract_address. – Haider Yaqoob Aug 04 '21 at 18:26
  • 1
    @HaiderYaqoob Unfortunately the pagination is limited by the Opensea API, so it's not currently possible to bypass it. – Petr Hejda Aug 04 '21 at 23:42
  • @PetrHejda You ever had problem that they are not returning all assets. I/E on their page opnsea.io you see 88 and by api call you get only 7 example address:0x6f5174b6015238acf4ffdbece7c722a5911d104a – PyDeveloper Oct 01 '21 at 12:25
  • 1
    @programerAnel It seems that the [UI](https://opensea.io/kriscrypto87) (88 assets) takes the data from other sources as well than just the [API](https://api.opensea.io/api/v1/assets?format=json&owner=0x6F5174b6015238ACF4FFdbeCe7c722A5911D104A) (7 assets). Unfortunately I don't know the other sources. It's possible that the UI includes some deleted or sold or in-order NFTs, while the API doesn't? – Petr Hejda Oct 01 '21 at 14:24
  • the url above no longer points to a valid response, however removing the pagination parameter `?offset=0&limit=20` does point the a response with the first 20 items in the contract (https://api.opensea.io/api/v1/assets?asset_contract_address=0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb). Does anyone have an updated url with correct pagination parameters – xiaolingxiao Feb 19 '22 at 17:58