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.
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.
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 |
|
/character/{id} | Same response as above |
/patronus |
|
/patronus/{id} | Same response as above |
/spells |
|
/spells/{id} | Same response as above |
/species |
|
/species/{id} | Same response as above |
/houses |
|
/houses/{id} | Same response as above |
/ancestries |
|
/ancestries/{id} | Same response as above |
Code: 401 Bad Request
Content: Id parameter has to be a number
Found when id requested isn’t in the correct format.
Code: 404 Not Found
Content: No request with that id found
Found when id requested doesn’t exist in database.
All samples will be showed using the character endpoints
document.addEventListener("DOMContentLoaded", () => {
fetch("url/characters")
.then((response) => response.json())
.then((data) => {
//do what you need with the data
});
});
document.addEventListener("DOMContentLoaded", () => {
fetch("url/characters/1")
.then((response) => response.json())
.then((data) => {
//do what you need with the data
});
});
The Magical Harry Potter Api is a non-commercial project.
Harry Potter and all associated names are copyright J.K. Rowling and Warner Bros.