Skip to content
Simon Bachmann edited this page Apr 25, 2020 · 4 revisions

Endpoints

This section describes the available endpoints provided by the Pokemate API.

🔐 Protected endpoints are marked with the lock symbol. Upon successful sign-up and log-in, a JWT token is used to access protected enpoints.

Authorization: Bearer <token>

Overview

User

Sign-up

POST /signup

Endpoint to sign up a user and request a JWT which is needed for authorized requests.

Required JSON data in body:

Parameter Type Required Description
email string yes user's email
password int yes hashed password

Example request:

curl --location --request POST 'localhost:8080/signup' \
--header 'Content-Type: application/json' \
--data-raw '{
	"email": "Simon",
	"password":"$2y$12$LmYcVgfHzwDvHOFzGCOmu0jAs50zr1JwZG2bQWuH5zXaoRKsdFsS"
}'

Example response:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}

Login

POST /login

Analog to signup endpoint

Pokemons

Pokedex

GET /pokemons?name=<name>&limit=<limit>&generations=<gen1>,<gen2>&types=<grass>,<poison>,<fire>&owned=<owned>

List of pokemons which can be filtered with the follwoing parameters.

Parameter Type Required Default Value Description
name string no '' search string for pokemon name
limit int no 100 limit number of Pokemons
generations [string] no [] list or generations
types [string] no [] list or pokemon types
owned_by string no '' id of user to only show the pokemons a user owns

Pokemon Details

GET /pokemons/<id>

Details to an individual Pokemon given its Pokedex id.

Parameter Type Required Description
id int yes Pokemon id

Example request:

curl --location --request GET 'localhost:8080/pokemon/1'

Example response:

{
  "id": 1,
  "name": "bulbasaur",
  "img_url": "http://localhost:8080/api/v1/pokemon-form/1/",
  "generation": 1,
  "is_legendary": true,
  "weight": 58,
  "fetishes": [{
     "name":"Likes slimy Pokemons.",
     "icon":"😢"
  },{
     "name":"Likes lighter Pokemons.",
    "icon":"🤦🏼‍♂️"}
  ],
  "types": ["grass", "poison"],
  "attracted_types": ["grass", "fire"],
  "nogo_types": ["poison", "rock"],
  "fertility": 0.32,
  "attractivity": 0.47,
  "fitness": 0.87,
  "nogos": ["BMI > 35", "Arrogant legendary Pokemons."]
}

Dates

Create Date

POST /dates 🔐

Send two pokemons on a date.

This is a protected enpoint. Make sure you use the JWT in the authorization header :

Authorization: Bearer <token>

Required JSON data in body:

Parameter Type Required Description
id_0 int yes pokemon id
id_1 int yes pokemon id

Example request:

curl --location --request POST 'localhost:8080/pokemon' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' \
--header 'Content-Type: application/json' \
--data-raw '{
	"id_0": 1,
	"id_1": 2
}'

Example response:

{
  "date_id": 343
}

Previous Dates

GET /dates?finished=<finished>&successfull=<successfull> 🔐

Get the list of all your dates.

This is a protected enpoint. Make sure you use the JWT in the authorization header :

Authorization: Bearer <token>
Parameter Type Required Default Value Description
finished bool no false only return finished dates
successfull bool no 100 only return successful dates

Date Details

GET /date/<date_id> 🔐

Get the list of all your dates.

This is a protected enpoint. Make sure you use the JWT in the authorization header:

Authorization: Bearer <token>
Parameter Type Required Description
date_id int yes date id

Example response:

{
  "date_id": 4,
  "successfull": false,
  "parent1_id": 43,
  "parent2_id": 122,
  "baby_id": 373,
  "date_start": 1585930153,
  "date_end": null
}

Note:

  • date_start and date_end are unix timestamps.
  • return "date_end": null if the date is still ongoing (meaning the baby image is still being generated.)

Rating

Baby Rating

Rate the name, image and its fit of a new Pokemon.

POST /rating/<id>

Parameter Type Required Description
name int yes given name rating
image int yes given image rating
rating int yes rating for how well the name fits the image

GET /rating/<id>

Averages of all rating that this Pokemon has received.

Example Response:

{
"id":1,
"name":0.4,
"image":0.5, 
"rating": 0.9
}