Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/fedeperin/potterapi

A REST Harry Potter API with images and information about books, characters and spells. Translated to many languages.
https://github.com/fedeperin/potterapi

api espanol express-api expressjs francais french french-language french-translation harry-potter harry-potter-api harrypotter italian portuguese potter potter-api rest rest-api serverless-functions spanish vercel-deployment

Last synced: 3 months ago
JSON representation

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

Lists

README

        

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

[PotterAPI](https://potterapi-fedeperin.vercel.app/) 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:
- [:us: English](https://potterapi-fedeperin.vercel.app/en)
- [:es: Español](https://potterapi-fedeperin.vercel.app/es)
- [:fr: Français](https://potterapi-fedeperin.vercel.app/fr)
- [:it: Italiano](https://potterapi-fedeperin.vercel.app/it)
- [:portugal: Português](https://potterapi-fedeperin.vercel.app/pt)

If there's any problem with the translations, you can [open an issue](https://github.com/fedeperin/potterapi/issues/new) or a [pull request](https://github.com/fedeperin/potterapi/pulls).

## Endpoints
The endpoints are the following:

GET /:lang/books
Returns information and images about Harry Potter books.



Key
Type
Value




number
number
The book number


title
string
The title of the book in the selected language


originalTitle
string
The original book title in English


releaseDate
string
The release date


description
string
A summary of the book


pages
number
The original book's number of pages


cover
string
An URL to an image with the original cover of the book


GET /:lang/characters
Returns information and images of Harry Potter characters.



Key
Type
Value




fullName
string
The full name of the character


nickname
string
The nickname of the character


hogwartsHouse
string
The Hogwarts House this character belong to


interpretedBy
string
The name of the actor/actress the character was interpreted by in the movies


children
object
An array with all the children of the character


image
string
An URL to an image of the character


birthdate
string
The birthdate of the character. Format "Month Day, Year"


GET /:lang/houses
Returns the four Hogwarts Houses with some extra data



Key
Type
Value




house
string
Name of the House


emoji
string
An emoji representing the house


founder
string
The name of the founder of the house


colors
object
An array with the colors in english of the house


animal
string
The animal of the house


GET /:lang/spells
Returns all the spells mentioned in the saga with a description.



Key
Type
Value




spell
string
The name of the spell


use
string
Description 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:

Param | Recieves | Description |
----- | -------- | ----------- |
`index` | number | Returns only one item, the one that on the whole list has the index selected |
`max` | number | Returns the whole list cropped by the number passed |
`page` | number | If `max` is used, you can also use this param to indicate where to start cropping |
`search` | string | Searches in all the items and returns the best matches |

## Examples
### Javascript
```javascript
const fetchSpells = async () => {
const res = await fetch('https://potterapi-fedeperin.vercel.app/en/spells')
const spells = await res.json()

return spells
}
```
```javascript
fetch('https://potterapi-fedeperin.vercel.app/es/characters?search=Weasley')
.then(res => res.json())
.then(res => {
console.log(res)
})
```
### Python
```python
import requests

def get_book():
response = requests.get('https://potterapi-fedeperin.vercel.app/en/books')
books = response.json()
return books
```

## Running locally
### Clone Repo:
With HTTPS
```bash
$ git clone https://github.com/fedeperin/potterapi.git
```
With SSH
```bash
$ git clone [email protected]:fedeperin/potterapi.git
```
### Run in dev mode
Run this to start a local server:
```bash
$ npm run dev
```

### Test
Before submitting a PR or making a commit run the following command:
```bash
$ npm run test
```

## Previous APIs
This is a version that unifies my [Harry Potter API](https://github.com/fedeperin/harry-potter-api) and my [Harry Potter API English](https://github.com/fedeperin/harry-potter-api-english), also adding more info. This API is using Express.js instead of json-server.