markdowns

The Magical Harry Potter API

This is an API for people who love Harry Potter and Coding

Homepage

This project was made with the intention of learning how to create RESTApi’s and it’s based on the characters created by J.K.Rowling.

Usage

This is a step by step of how to use the API

The api consists of a number of endpoints that are fetched through any language.

Javascript will be used to show examples on how to use the API.

Endpoints

All endpoints have the following pre url : TO BE INPUTED

All ID endpoints have the same response but on a specific ID

GET Response - JSON
/character

{
  "id": 1,
  "actor": "Daniel Radcliffe",
  "alive": true,
  "ancestry": "half-blood",
  "dateOfBirth": {
    "year": 1980,
    "month": 7,
    "day": 31
  },
  "gender": "male",
  "hogwartsOccupation": "student",
  "house": "Gryffindor",
  "image": "",
  "patronus": "stag",
  "species": "human",
  "name": "Harry Potter"
}

/character/{id} Same response as above
/patronus

{
  "patronus_id": 2,
  "patronus_title": "stag"
}

/patronus/{id} Same response as above
/spells

{
  "spell_id": 2,
  "spell_title": "accio"
}

/spells/{id} Same response as above
/species

{
  "species_id": 2,
  "species_title": "werewolf"
}

/species/{id} Same response as above
/houses

{
  "house_id": 4,
  "house_title": "Slytherin"
}

/houses/{id} Same response as above
/ancestries

{
  "ancestry_id": 3,
  "ancestry_title": "half-blood"
}

/ancestries/{id} Same response as above

Error Responses

Samples

All samples will be showed using the character endpoints

Get All Character

document.addEventListener("DOMContentLoaded", () => {
  fetch("url/characters")
    .then((response) => response.json())
    .then((data) => {
      //do what you need with the data
    });
});

Get Specific Character

document.addEventListener("DOMContentLoaded", () => {
  fetch("url/characters/1")
    .then((response) => response.json())
    .then((data) => {
      //do what you need with the data
    });
});

Copyright

The Magical Harry Potter Api is a non-commercial project.

Content

Harry Potter and all associated names are copyright J.K. Rowling and Warner Bros.