> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spicerack.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Public Decklist Database API

> Access our database of tournament decklists and results

Spicerack maintains a comprehensive database of Magic: The Gathering tournament results and decklists. This API endpoint provides public access to this database, allowing you to retrieve decklists and results from completed tournaments across all participating stores and events.

This database is particularly valuable for:

* Tournament organizers analyzing metagame trends
* Data analysts studying competitive Magic
* Deck builders researching successful strategies
* Content creators tracking tournament results
* Community tools and applications needing tournament data

## Endpoint

```bash theme={null}
GET https://api.spicerack.gg/api/export-decklists/
```

## Query Parameters

| Parameter          | Type    | Default | Description                                        |
| ------------------ | ------- | ------- | -------------------------------------------------- |
| `num_days`         | integer | 14      | Number of days to look back for tournament results |
| `event_format`     | string  | null    | Filter results by tournament format                |
| `organization_id`  | integer | null    | Filter results by organization/store ID            |
| `decklist_as_text` | boolean | false   | Include plaintext decklist in the response         |

### Available Format Options

The following formats are supported for the `event_format` parameter:

| Format               | Description                    |
| -------------------- | ------------------------------ |
| "STANDARD"           | Standard format                |
| "MODERN"             | Modern format                  |
| "PIONEER"            | Pioneer format                 |
| "LEGACY"             | Legacy format                  |
| "VINTAGE"            | Vintage format                 |
| "COMMANDER2"         | Commander/EDH format           |
| "PAUPER"             | Pauper format                  |
| "BOOSTER\_DRAFT"     | Booster Draft events           |
| "SEALED\_DECK"       | Sealed Deck events             |
| "HISTORIC"           | Historic format                |
| "EXPLORER"           | Explorer format                |
| "TIMELESS"           | Timeless format                |
| "GLADIATOR"          | Gladiator format               |
| "OATHBREAKER"        | Oathbreaker format             |
| "PREMODERN"          | Premodern format               |
| "STANDARD\_BRAWL"    | Standard Brawl format          |
| "PAUPER\_COMMANDER"  | Pauper Commander format        |
| "DUEL"               | Duel Commander format          |
| "OLDSCHOOL"          | Oldschool format               |
| "PREDH"              | PrEDH format                   |
| "TRIOS\_CONSTRUCTED" | Team Constructed format        |
| "OTHER"              | Other formats not listed above |

## Response Format

The endpoint returns an array of tournament objects, each containing:

```json theme={null}
{
  "TID": "string",                // Tournament ID
  "tournamentName": "string",     // Tournament name including store name
  "format": "string",             // Tournament format
  "bracketUrl": "string",         // URL to view tournament brackets
  "players": "integer",           // Number of players
  "startDate": "integer",         // Unix timestamp of tournament start
  "swissRounds": "integer",       // Number of Swiss rounds played
  "topCut": "integer",           // Size of playoff cut (e.g., Top 8)
  "standings": [
    {
      "name": "string",           // Player name
      "decklist": "string",       // Moxfield decklist URL
      "winsSwiss": "integer",     // Wins in Swiss rounds
      "lossesSwiss": "integer",   // Losses in Swiss rounds
      "draws": "integer",         // Number of draws
      "winsBracket": "integer",   // Wins in playoff bracket
      "lossesBracket": "integer", // Losses in playoff bracket
      "decklist_text": "string"   // Plaintext decklist (only present if decklist_as_text=true)
    }
  ]
}
```

## Example Request

```bash theme={null}
# Get Modern format tournaments from the last 30 days with plaintext decklists
curl "https://api.spicerack.gg/api/export-decklists/?num_days=30&event_format=MODERN&decklist_as_text=true" \
  -H "X-API-Key: sk_*****"
```

## Notes

* Only tournaments with the following statuses are included:
  * Decklists Publishing
  * Decklists Published
  * Event Finished
* Test events are excluded from the results
* Tournaments are ordered by start date, with most recent first
* The endpoint supports both JSON and NDJSON response formats
* If an invalid format is provided, the endpoint will return a 400 error with a list of all valid format options
* Data is typically available shortly after tournament completion
* Historical data is maintained for research and analysis purposes
