---
name: analyzing-nft-rarity
description: 'Calculate NFT rarity scores and rank tokens by trait uniqueness.

  Use when analyzing NFT collections, checking token rarity, or comparing NFTs.

  Trigger with phrases like "check NFT rarity", "analyze collection", "rank tokens", "compare NFTs".'
allowed-tools: Read, Bash(python3:*)
version: 1.26.0
author: Jeremy Longshore <jeremy@intentsolutions.io>
license: MIT
tags:
  - crypto
  - analyzing-nft
compatibility: Designed for Claude Code
title: analyzing-nft-rarity
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity
last_updated: 2026-10-23T05:08:30.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [ARD.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/ARD.md), [config/settings.yaml](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/config/settings.yaml), [PRD.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/PRD.md), [references/errors.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/references/errors.md), [references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/references/examples.md), [references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/references/implementation.md), [scripts/formatters.py](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/scripts/formatters.py), [scripts/metadata_fetcher.py](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/scripts/metadata_fetcher.py), [scripts/rarity_analyzer.py](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/scripts/rarity_analyzer.py), [scripts/rarity_calculator.py](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/scripts/rarity_calculator.py), [scripts/trait_parser.py](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/scripts/trait_parser.py).
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/analyzing-nft-rarity`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/analyzing-nft-rarity`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/analyzing-nft-rarity --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/analyzing-nft-rarity --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Analyzing NFT Rarity

## Overview

NFT rarity analysis skill that:

- Fetches collection metadata from OpenSea API
- Parses and normalizes trait attributes
- Calculates rarity using multiple algorithms
- Ranks tokens by composite rarity score
- Exports data in JSON and CSV formats

## Prerequisites

- Python 3.8+ with requests library
- Optional: `OPENSEA_API_KEY` for higher rate limits
- Optional: `ALCHEMY_API_KEY` for direct metadata fetching

## Instructions

### 1. Analyze a Collection

```bash
cd ${CLAUDE_SKILL_DIR}/scripts && python3 rarity_analyzer.py collection boredapeyachtclub
```

Options:

1. `--limit 500`: Fetch more tokens for analysis
2. `--top 50`: Show top 50 tokens
3. `--traits`: Include trait distribution
4. `--rarest`: Show rarest traits
5. `--algorithm [statistical|rarity_score|average|information]`

### 2. Check Specific Token

```bash
cd ${CLAUDE_SKILL_DIR}/scripts && python3 rarity_analyzer.py token pudgypenguins 1234  # port 1234 - example/test
```

### 3. Compare Multiple Tokens

```bash
cd ${CLAUDE_SKILL_DIR}/scripts && python3 rarity_analyzer.py compare azuki 1234,5678,9012  # 5678: 1234: 9012 = configured value
```

### 4. View Trait Distribution

```bash
cd ${CLAUDE_SKILL_DIR}/scripts && python3 rarity_analyzer.py traits doodles
```

### 5. Export Rankings

JSON:

```bash
cd ${CLAUDE_SKILL_DIR}/scripts && python3 rarity_analyzer.py export coolcats > rankings.json
```

CSV:

```bash
cd ${CLAUDE_SKILL_DIR}/scripts && python3 rarity_analyzer.py export coolcats --format csv > rankings.csv
```

### 6. Manage Cache

```bash
cd ${CLAUDE_SKILL_DIR}/scripts && python3 rarity_analyzer.py cache --list
cd ${CLAUDE_SKILL_DIR}/scripts && python3 rarity_analyzer.py cache --clear
```

## Rarity Algorithms

| Algorithm | Description | Best For |
|-----------|-------------|----------|
| `rarity_score` | Sum of 1/frequency (default) | General use, matches rarity.tools |
| `statistical` | Same as rarity_score | Backward compatibility |
| `average` | Mean of trait rarities | Balanced scoring |
| `information` | Entropy-based (-log2) | Information theory approach |

## Output

- **Collection Summary**: Name, supply, trait types
- **Rankings**: Tokens sorted by rarity score with percentile
- **Token Detail**: Full trait breakdown with contribution
- **Comparison**: Side-by-side trait comparison

## Supported Collections

Works with any ERC-721/ERC-1155 collection that has:

- OpenSea listing
- Standard attributes array format
- Accessible metadata

## Error Handling

See [`references/errors.md`](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/references/errors.md) for:

- API rate limiting
- IPFS gateway issues
- Collection not found
- Token ID not found

## Examples

See [`references/examples.md`](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/analyzing-nft-rarity/references/examples.md) for:

- Collection analysis workflows
- Token comparison
- Export and caching
- Algorithm comparison

## Resources

- [OpenSea API](https://docs.opensea.io/reference/api-overview) - Metadata source
- [Rarity Tools](https://rarity.tools/) - Reference rankings
- [IPFS](https://ipfs.io/) - Decentralized metadata
