# Traits & Rarity API

The Traits & Rarity API provides **read-only** access to detailed NFT attributes and rarity metrics for the BabySneklets collection. This tool is ideal for developers, collectors, and community members who wish to integrate rarity data into dashboards or analytical tools.

**Base URL:**\
`https://api.babysneklets.fun`\
\&#xNAN;*(Replace with your actual endpoint as needed.)*

**Authentication:**\
No API key is required for read-only access; however, rate limits may apply.

### Get NFT Traits

#### Endpoint

`GET /api/nft/traits?token_id={TOKEN_ID}`

#### Description

Retrieve the complete set of traits for a specific BabySneklet NFT, including details like background, body, clothes, eyes, head, mouth, and tail, along with its calculated rarity score and rank.

#### Sample Request

```bash
curl -X GET "https://api.babysneklets.fun/api/nft/traits?token_id=BabySneklet#123"
```

#### Sample Response

```json
{
  "token_id": "BabySneklet#123",
  "traits": {
    "background": "Forest Green",
    "body": "Scaled",
    "clothes": "Urban Jacket",
    "eyes": "Mystic Blue",
    "head": "Spiked",
    "mouth": "Smirk",
    "tail": "Curled"
  },
  "rarity": {
    "score": 85.4,
    "rank": 102
  }
}
```

#### Get Global Rarity Statistics

**Endpoint**

```bash
GET /api/nft/rarity
```

**Description**

This endpoint provides overall rarity statistics for the entire BabySneklets collection, including average rarity scores, trait distributions, and the breakdown of NFTs into rarity tiers.

**Sample Request**

```bash
curl -X GET "https://api.babysneklets.fun/api/nft/rarity"
```

**Sample Response**

```json
{
  "average_rarity_score": 72.5,
  "total_nfts": 7777,
  "trait_distribution": {
    "background": {
      "Forest Green": 1500,
      "Lava Red": 1200,
      "Sky Blue": 1300,
      "Ice White": 1777
    },
    "body": {
      "Scaled": 4000,
      "Sleek": 3777
    }
  },
  "rarity_tiers": {
    "legendary": 50,
    "epic": 500,
    "rare": 1500,
    "common": 5727
  }
}
```

**Use Cases**

* **Collector Dashboards:** Build dashboards to display detailed NFT traits and rarity rankings.
* **Rarity Analysis:** Develop tools to analyze trait distributions and compare rarity across the collection.
* **Community Integrations:** Create widgets or bots that share real-time rarity data with the community.

**Rate Limits & Error Handling**

* **Rate Limits:** The API enforces rate limits (e.g., 60 requests per minute). Exceeding these limits returns an HTTP 429 Too Many Requests error.
* **Common Errors:**
  * 400 Bad Request – Missing or invalid token\_id.
  * 404 Not Found – Specified token\_id does not exist.
  * 500 Internal Server Error – Server error; try again later.

#### Example Rarity Score Calculation

**NFT #123** (hypothetical) has the following trait appearances in the collection:

| Trait      | Name           | Count | Score Formula | Score |
| ---------- | -------------- | ----- | ------------- | ----- |
| Background | Celestial Blue | 500   | 7,777 / 500   | 15.55 |
| Body       | Scaled         | 3,000 | 7,777 / 3,000 | 2.59  |
| Clothes    | Urban Jacket   | 2,000 | 7,777 / 2,000 | 3.89  |
| Eyes       | Mystic Blue    | 1,500 | 7,777 / 1,500 | 5.18  |
| Head       | Spiked         | 1,000 | 7,777 / 1,000 | 7.78  |
| Mouth      | Smirk          | 2,500 | 7,777 / 2,500 | 3.11  |
| Tail       | Curled         | 3,500 | 7,777 / 3,500 | 2.22  |

**Total Rarity Score:** ≈ 40.22\
This score is then ranked against the rest of the collection to determine its rarity tier.

> 🔎 *Note: This is a simplified example. Actual rarity scores may include additional weighting or normalizing factors.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://babysneklets.gitbook.io/babysneklets/minting-and-mining/openapi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
