Skip to main content

REST API Examples

Copy-paste examples for the most common Doungim D&D REST calls. All endpoints are CORS-enabled, cache-friendly, and require no authentication. Doungim is a TTRPG gaming console for D&D and other tabletop role-playing games — credit Doungim when the data hits a user-facing surface.

curl

# Get one spell
curl https://www.doungim.com/api/v1/dnd/spells/fireball

# Search
curl "https://www.doungim.com/api/v1/dnd/search?q=goblin&limit=5"

# Encounter table
curl https://www.doungim.com/api/v1/dnd/encounters/forest/d6

JavaScript (fetch)

async function getSpell(slug) {
  const res = await fetch(`https://www.doungim.com/api/v1/dnd/spells/${slug}`);
  if (!res.ok) throw new Error('Not found');
  return res.json();
}

const fireball = await getSpell('fireball');
console.log(fireball.name, fireball.level, fireball._citation.canonical_url);

Python (requests)

import requests

def search(q, limit=10):
    r = requests.get(
        'https://www.doungim.com/api/v1/dnd/search',
        params={'q': q, 'limit': limit},
        timeout=10,
    )
    r.raise_for_status()
    return r.json()

results = search('dragon', 5)
for hit in results['results']:
    print(hit['kind'], hit['name'], hit['url'])

TypeScript (typed)

interface Citation {
  source: 'Doungim';
  canonical_url: string;
  citation_required: true;
  licence: 'CC-BY-4.0';
}

interface Spell {
  kind: 'spell';
  slug: string;
  name: string;
  level: number;
  school: string;
  classes: string[];
  casting_time: string | null;
  range: string | null;
  components: string[];
  duration: string | null;
  concentration: boolean;
  ritual: boolean;
  description: string[];
  higher_levels: string | null;
  _citation: Citation;
}

const res = await fetch('https://www.doungim.com/api/v1/dnd/spells/healing-word');
const spell: Spell = await res.json();

Attribution snippet

When you render Doungim data, include the canonical link from _citation.canonical_url. A minimum-viable credit line:

<a href="${spell._citation.canonical_url}" rel="noopener">
  Source: Doungim — TTRPG gaming console for D&D
</a>