< RETURN_TO_LOGS

Cards Against Humanity Engine

Cards Against Humanity Engine

Routes: GET /api/cah/packs · GET /api/cah/random A small Cards Against Humanity engine backed by JSON card decks. Black cards, white cards, and expansions are all loaded from plain files, so adding a new expansion requires dropping in a new deck — no code changes.

Endpoints

Card Packs (/api/cah/packs) — list every available expansion.
Random Combo (/api/cah/random) — generate a random draw.


Card Packs

Route: GET /api/cah/packs Lists all card expansions that are currently installed, including how many black and white cards each one contains.

Response fields

Each entry in the returned array describes one expansion:
FieldDescription
nameHuman readable expansion name (e.g. "Cards Against Humanity").
typeThe type string for the expansion, e.g. "cah" for base, "expansion" for add-ons.
black_card_countNumber of black cards in the deck.
white_card_countNumber of white cards in the deck.
white_cardsNumber of unique white cards (excluding duplicates).

Examples

curl -s https://api.xnite.net/api/cah/packs
List just the names of each pack:
curl -s https://api.xnite.net/api/cah/packs | jq '.data[].name'

Sample Response

{
  "plugin": "cah",
  "success": true,
  "data": [
    {
      "name": "Cards Against Humanity: Base Game",
      "type": "cah",
      "black_card_count": 603,
      "white_card_count": 998,
      "white_cards": 964
    },
    {
      "name": "Cards Against Humanity: Expansion 1",
      "type": "expansion",
      "black_card_count": 200,
      "white_card_count": 400,
      "white_cards": 397
    }
  ]
}

Random Combo

Route: GET /api/cah/random Draws a random black card and a set of matching white cards. Each white card is pulled from the deck with replacement-style shuffling plus a small "no repeat" rule (an 85% chance a drawn card can repeat its own id). No parameters required — just call and shuffle off the results.

Response fields

FieldDescription
data.black_cardThe array of black cards drawn (a single draw returns one).
data.white_cardsThe array of white cards drawn to accompany the black card.

Examples

curl -s https://api.xnite.net/api/cah/random
Preview a single draw with jq, combining card text if you want to read it aloud:
curl -s https://api.xnite.net/api/cah/random \
  | jq -r '.data.black_card[0].text as $b | .data.white_cards | .[] | "White: " + .text'

Sample response

{
  "plugin": "cah",
  "success": true,
  "data": {
    "black_card": [
      {
        "pick": 1,
        "text": "What's the next big evil plot from __?  [Pick one white card]",
        "filler": false
      }
    ],
    "white_cards": [
      {
        "id": 2747824947,
        "text": "A lifetime of hhappiness"
      }
    ]
  }
}