Just released: A Traits API on Center.dev


October 4, 2022


← Back

We are excited to announce that we have now opened our Traits API to all users.

Builders can use this API to:

Check out a few examples below, or reach out to our support team with any questions.

Demo: Get traits of assets in a collection

Note: This demo returns the third trait set for BAYC (”Earring”) only. To return all traits, the user should not include an offset or limit in the query.

Request:

<https://api.center.dev/v1/ethereum-mainnet/>
0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/traits?offset=2&limit=1

Response:

{
  "items": [
    {
      "trait": "Earring",
      "values": [
        {
          "value": "Cross",
          "count": 149
        },
        {
          "value": "Diamond Stud",
          "count": 222
        },
        {
          "value": "Gold Hoop",
          "count": 462
        },
        {
          "value": "Gold Stud",
          "count": 439
        },
        {
          "value": "Silver Hoop",
          "count": 882
        },
        {
          "value": "Silver Stud",
          "count": 823
        }
      ],
      "totalValues": 6
    }
  ],
  "offset": 2,
  "limit": 1,
  "onLastPage": false
}

Demo: Get attribute values for a specific trait

Note: This demo returns the distribution of attributes for “Background” within BAYC.

Request:

<https://api.center.dev/v1/ethereum-mainnet/>
0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/traits/Background

Response:

{
  "items": [
    {
      "value": "Aquamarine",
      "count": 1266
    },
    {
      "value": "Army Green",
      "count": 1243
    },
    {
      "value": "Blue",
      "count": 1242
    },
    {
      "value": "Gray",
      "count": 1170
    },
    {
      "value": "New Punk Blue",
      "count": 1232
    },
    {
      "value": "Orange",
      "count": 1273
    },
    {
      "value": "Purple",
      "count": 1291
    },
    {
      "value": "Yellow",
      "count": 1283
    }
  ],
  "offset": 0,
  "limit": 10,
  "onLastPage": true
}

Demo: Search for assets within a collection that have certain traits

Note: This demo searches for all assets within BAYC that have either “Army Green” or “Blue” backgrounds. The demo limits search results to 2 for readability.

Request:

curl --request POST \\
     --url '<https://api.center.dev/v1/ethereum-mainnet/0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/assets/searchByTraits?limit=2>' \\
     --header 'accept: application/json' \\
     --header 'content-type: application/json' \\
     --data '
{
     "query": {
          "Background": [
               "Army Green",
               "Blue"
          ]
     }
}

'

Response:

{
  "items": [
    {
      "address": "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
      "collection_name": "BoredApeYachtClub",
      "token_id": "4",
      "url": "[<https://center.app/collections/0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/4>](<https://center.app/collections/0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/4>)",
      "name": "4",
      "metadata": {
        "attributes": [
          {
            "trait_type": "Clothes",
            "value": "Navy Striped Tee"
          },
          {
            "trait_type": "Mouth",
            "value": "Phoneme L"
          },
          {
            "trait_type": "Hat",
            "value": "Party Hat 2"
          },
          {
            "trait_type": "Fur",
            "value": "Golden Brown"
          },
          {
            "trait_type": "Eyes",
            "value": "Closed"
          },
          {
            "trait_type": "Background",
            "value": "Blue"
          }
        ],
        "image": "ipfs://QmSg9bPzW9anFYc3wWU5KnvymwkxQTpmqcRSfYj7UmiBa7"
      },
      "small_preview_image_url": "[<https://cdn.center.app/v2/1/c514264780694729a9951793357abfa6ac1b90f411f09545265e44d2f84502fd/f62d940a8472a403c4ed64c076d087ec09c0d40e2fd9320e2c8f7aa7fd44ebfb.png>](<https://cdn.center.app/v2/1/c514264780694729a9951793357abfa6ac1b90f411f09545265e44d2f84502fd/f62d940a8472a403c4ed64c076d087ec09c0d40e2fd9320e2c8f7aa7fd44ebfb.png>)"
    },
    {
      "address": "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
      "collection_name": "BoredApeYachtClub",
      "token_id": "5",
      "url": "[<https://center.app/collections/0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/5>](<https://center.app/collections/0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D/5>)",
      "name": "5",
      "metadata": {
        "attributes": [
          {
            "trait_type": "Hat",
            "value": "Bayc Flipped Brim"
          },
          {
            "trait_type": "Eyes",
            "value": "X Eyes"
          },
          {
            "trait_type": "Fur",
            "value": "Brown"
          },
          {
            "trait_type": "Background",
            "value": "Army Green"
          },
          {
            "trait_type": "Clothes",
            "value": "Bayc T Red"
          },
          {
            "trait_type": "Mouth",
            "value": "Dumbfounded"
          }
        ],
        "image": "ipfs://QmNwbd7ctEhGpVkP8nZvBBQfiNeFKRdxftJAxxEdkUKLcQ"
      },
      "small_preview_image_url": "[<https://cdn.center.app/v2/1/0ecc27df7a7d70161144ab9e4cd27f6b134235916b7d809fba455c02e10a577d/cd693370545ba79f717eb836d4c375f424adddee9698d7b9a51047cc0b2385d0.png>](<https://cdn.center.app/v2/1/0ecc27df7a7d70161144ab9e4cd27f6b134235916b7d809fba455c02e10a577d/cd693370545ba79f717eb836d4c375f424adddee9698d7b9a51047cc0b2385d0.png>)"
    }
  ],
  "offset": 0,
  "limit": 2,
  "onLastPage": false
}

Other requests or ideas? Please submit a feature request or reach out to our support team.