Quick start

Make your first request in under a minute.

There is nothing to install and nothing to sign up for. Make a request.

Your first request

curl
JavaScript
Python
PHP
curl https://hogwarts-api.com/api/spells/expecto-patronum

Looking things up

A single record is addressed by its slug. The route also accepts a full name, and anything that slugifies to a known slug — so all three of these return Hermione:

curl https://hogwarts-api.com/api/characters/hermione-granger
curl https://hogwarts-api.com/api/characters/Hermione%20Granger
curl "https://hogwarts-api.com/api/characters/Hermione Jean Granger"

If you do not know the slug, search for it first:

curl "https://hogwarts-api.com/api/characters?search=weasley"

A worked example

Pulling every Gryffindor with a known patronus:

const gryffindors = [];
let page = 1;
let totalPages = 1;

do {
  const res = await fetch(
    `https://hogwarts-api.com/api/characters?page=${page}&page_size=100`,
  );
  const { data, meta } = await res.json();

  totalPages = meta.total_pages;
  gryffindors.push(
    ...data.filter(c => c.house === 'Gryffindor' && c.patronus),
  );
  page += 1;
} while (page <= totalPages);

console.log(`${gryffindors.length} Gryffindors with a known patronus`);

Next steps