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 days ago
JSON representation
A REST Harry Potter API with images and information about books, characters and spells. Translated to many languages.
- Host: GitHub
- URL: https://github.com/fedeperin/potterapi
- Owner: fedeperin
- License: mit
- Created: 2023-12-14T03:32:23.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-07-16T17:47:59.000Z (4 months ago)
- Last Synced: 2024-11-01T17:37:29.424Z (7 days ago)
- Topics: 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
- Language: JavaScript
- Homepage: https://potterapi-fedeperin.vercel.app
- Size: 8.13 MB
- Stars: 42
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- public-apis - Harry Potter
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:
- [`/en` 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)
- [`/pt` 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:
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.
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/random
s) 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 requestsdef 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.