Skip to content

Repository files navigation

PotterAPI

Important

The new base URL is https://potterapi-fedeperin.vercel.app but you can still use the old one (not recommended) https://potterapi.onrender.com/

PotterAPI is a Harry Potter API developed with Express.js and available in multiple languages.
This API stores information and images of books, characters and spells.

Languages

This API is available in the following languages:

If there's any problem with the translations, you can open an issue or a pull request.

Endpoints

The endpoints are the following:
Note: The [lang] in the endpoint should be replaced by the corresponding language reference without the brackets (GET /en/books for example)

GET /[lang]/books Returns information and images about Harry Potter books.
KeyTypeValue
numbernumberThe book number
titlestringThe title of the book in the selected language
originalTitlestringThe original book title in English
releaseDatestringThe release date
descriptionstringA summary of the book
pagesnumberThe original book's number of pages
coverstringAn URL to an image with the original cover of the book
GET /[lang]/characters Returns information and images of Harry Potter characters.
KeyTypeValue
fullNamestringThe full name of the character
nicknamestringThe nickname of the character
hogwartsHousestringThe Hogwarts House this character belong to
interpretedBystringThe name of the actor/actress the character was interpreted by in the movies
childrenobjectAn array with all the children of the character
imagestringAn URL to an image of the character
birthdatestringThe birthdate of the character. Format "Month Day, Year"
GET /[lang]/houses Returns the four Hogwarts Houses with some extra data
KeyTypeValue
housestringName of the House
emojistringAn emoji representing the house
founderstringThe name of the founder of the house
colorsobjectAn array with the colors in english of the house
animalstringThe animal of the house
GET /[lang]/spells Returns all the spells mentioned in the saga with a description.
KeyTypeValue
spellstringThe name of the spell
usestringDescription of the spell

You have to change the [lang] by one of the two-letter codes of the languages supported.
Every endpoint has a /random, which returns a random item of the full list. For example /en/spells/random returns a single random spell in English.

Params

Every endpoint (excluding the /randoms) can recieve the following query params:

ParamRecievesDescription
indexnumberReturns only one item, the one that on the whole list has the index selected
maxnumberReturns the whole list cropped by the number passed
pagenumberIf max is used, you can also use this param to indicate where to start cropping
searchstringSearches in all the items and returns the best matches

Examples

Javascript

constfetchSpells=async()=>{constres=awaitfetch('https://potterapi-fedeperin.vercel.app/en/spells')constspells=awaitres.json()returnspells}
fetch('https://potterapi-fedeperin.vercel.app/es/characters?search=Weasley').then(res=>res.json()).then(res=>{console.log(res)})

Python

importrequestsdefget_book():
response=requests.get('https://potterapi-fedeperin.vercel.app/en/books')
books=response.json()
returnbooks

Running locally

Clone Repo:

With HTTPS

$ git clone https://github.com/fedeperin/potterapi.git

With SSH

$ git clone git@github.com:fedeperin/potterapi.git

Run in dev mode

Run this to start a local server:

$ npm run dev

Test

Before submitting a PR or making a commit run the following command:

$ npm run test

Previous APIs

This is a version that unifies my Harry Potter API and my Harry Potter API English, also adding more info. This API is using Express.js instead of json-server.

About

A REST Harry Potter API with images and information about books, characters and spells. Translated to many languages.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages