Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 3 min read

Free tarot card data for your app: JSON, CSV and a daily card embed

If you are building a tarot app, a card game, a journaling tool or a "card of the day" widget, the first job is typing up 78 cards. I've published that data so you can skip it: JSON: https://tarostarot.com/tarot-card-d

If you are building a tarot app, a card game, a journaling tool or a "card of the day" widget, the first job is typing up 78 cards. I've published that data so you can skip it:

No key, no sign-up, and the files send Access-Control-Allow-Origin: *, so browser code on any site can fetch them.

What is in it

Each of the 78 cards has:

  • id, name, number, arcana (major or minor), suit and rank
  • eight keywords
  • a one-sentence upright and reversed meaning
  • yes_no: an upright and a reversed answer (yes, no or maybe) and a one-line reason
  • element and astrology (planet, sign, decan and dates where the card has them; court cards carry their elemental dignity)
  • image: a picture of the card from the 1909 Rider-Waite-Smith deck, which is in the public domain
  • url: the card's full meaning page

Here is The Fool:

{
  "id": "the-fool",
  "name": "The Fool",
  "number": 0,
  "arcana": "major",
  "suit": null,
  "rank": null,
  "keywords": ["new beginnings", "innocence", "spontaneity", "free spirit", "adventure", "faith", "potential", "risk"],
  "upright": "New beginnings, unlimited potential, and a leap of faith into the unknown.",
  "reversed": "Recklessness, poor judgment, or fear of taking necessary risks.",
  "yes_no": {
    "upright": "yes",
    "reversed": "no",
    "summary": "A yes for the leap itself; the landing is not shown yet"
  },
  "element": "air",
  "astrology": { "planet": "Uranus", "sign": "Aquarius", "decan": null, "dates": null, "elemental_dignity": null },
  "image": "https://cdn.tarostarot.com/cards/00-TheFool.webp",
  "url": "https://tarostarot.com/tarot-cards/the-fool"
}

Draw a card in the browser

const res = await fetch('https://tarostarot.com/tarot-card-data/tarot-cards.json');
const { cards } = await res.json();

const card = cards[Math.floor(Math.random() * cards.length)];
const reversed = Math.random() < 0.5;

console.log(
  `${card.name}${reversed ? ' (reversed)' : ''}:`,
  reversed ? card.reversed : card.upright,
  `Yes or no: ${card.yes_no[reversed ? 'reversed' : 'upright']}`
);

The file changes only when the data version does, so fetch it once and keep it rather than fetching on every draw.

A yes or no answer

Every card has a yes/no answer for both orientations, plus a short reason, which is enough to build a one-card yes or no reading:

const card = cards[Math.floor(Math.random() * cards.length)];
const answer = card.yes_no.upright;   // "yes", "no" or "maybe"
const why = card.yes_no.summary;      // under 100 characters

Python and pandas

The CSV has one row per card, with keywords separated by ;:

import pandas as pd

cards = pd.read_csv("https://tarostarot.com/tarot-card-data/tarot-cards.csv")
print(cards.groupby(["arcana", "element"]).size())

A daily card for your site

If you only want a card of the day on a page, there is an embed. Paste this where the card should appear:

<div data-taros-tarot-daily-card><a href="https://tarostarot.com/tarot-card-of-the-day">Daily card by Taro's Tarot</a></div>
<script src="https://tarostarot.com/embed/daily-card.js" async></script>

It is one cached script with no cookies and no tracking. The card changes at midnight UTC, and data-theme="dark" on the div gives a dark card.

Licence

The card data is CC BY 4.0: use it for anything, commercial projects included, and credit it with a link:

Tarot card data by <a href="https://tarostarot.com/tarot-card-data">Taro's Tarot</a> (CC BY 4.0)

The card images are public domain. They are scans of Pamela Colman Smith's art for the 1909 Rider-Waite-Smith deck, not the 1971 recoloured edition, which has its own copyright. All 78 are also in one ZIP: https://cdn.tarostarot.com/downloads/tarot-card-images-1909-v1.zip

If a field is missing for what you are building, open an issue on the repository.

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.