Skip to content

REST API

rozsa117 edited this page Jan 14, 2019 · 9 revisions

Pokemon League Participation Manager REST API

Introduction

The Pokemon League Participation Manager API is a HTTP-based RESTfull API. At the moment it is provided as a demo API for the entity pokemon species only. There is no authorization needed to use the api. It is localized in 3 languages, English (as default), Slovak and Hungarian.

 

Usage

The API runs at context /pa165/rest/. The pokemon species entity uses a prefix pokemonSpecies.

You can install the application using following commands (you must have Git and Maven installed on your machine):

git clone https://github.com/rozsa117/PA165-Pokemon-league-participation-manager.git
cd PA165-Pokemon-league-participation-manager
mvn clean install
cd pokemon-rest
mvn cargo:run

By default the REST API starts at http://localhost:8080

You can test the API using Curl by following command:

curl -i -X GET http://localhost:8080/pa165/rest/

You will get the list of available URIs (at the moment only pokemon species):

{"pokemon_species_uri":"/pokemonSpecies"}

Using following command you can get the root action getPokemonSpecies:

curl -i -X GET http://localhost:8080/pa165/rest/pokemonSpecies

 

Please note that lower stated examples do not work in Windows shell. To use the commands in Windows you have to substitute single quotes (') with double quotes (") and double quotes (") with escaped double quotes (\") for all JSON objects used.

 

Actions

Get all pokemon species

Returns all pokemon species.

HTTP-method: GET

URI suffix: none

Parameters: none

Example call:

curl -i -X GET http://localhost:8080/pa165/rest/pokemonSpecies

Find a pokemon species by id

Returns pokemon species with the given id.

HTTP-method: GET

URI suffix: /{id}

Parameters:

  • id Identification of the pokemon species.

Example call:

curl -i -X GET http://localhost:8080/pa165/rest/pokemonSpecies/1

 

Create new pokemon species

Creates a new pokemon species.

HTTP-method: POST

URI suffix: none

Parameters:

  • speciesName Name of pokemon species

  • primaryType Primary type of pokemon species

  • secondaryType Secondary type of pokemon species (nullable)

  • evolvesFromId Identification of pokemon species it is evolved from (nullable)

Example call:

curl -X POST -i -H "Content-Type: application/json" --data '{"speciesName":"Gastly","primaryType":"GHOST","secondaryType":"POISON","evolvesFromId":null}' http://localhost:8080/pa165/rest/pokemonSpecies/create

 

Remove a pokemon species

Removes selected pokemon species by Id.

HTTP-method: DELETE

URI suffix: /{id}

Parameters:

  • id Identification of the pokemon species to be deleted

Example call:

curl -i -X DELETE http://localhost:8080/pa165/rest/pokemonSpecies/15

 

Get all evolutions of pokemon species

Returns all evolutions of selected pokemon species.

HTTP-method: GET

URI suffix: /{id}/allEvolutions

Parameters:

  • id Identification of the pokemon species to find all evolutions.

Example call:

curl -i -X GET http://localhost:8080/pa165/rest/pokemonSpecies/1/allEvolutions

 

Change preevolution of a pokemon species

Changes preevolution of selected pokemon species.

HTTP-method: POST

URI suffix: /changePreevolution

Parameters:

  • id Identification of pokemon species to change the preevolution.

  • evolvesFrom Identification the new preevolution of the pokemon species.

Example call:

curl -X POST -i -H "Content-Type: application/json" --data '{"id":"15","evolvesFrom":"10"}' http://localhost:8080/pa165/rest/pokemonSpecies/changePreevolution

 

Change the type of a pokemon species.

Changes primary or secondary type (or both) of selected pokemon species.

HTTP-method: POST

URI suffix: /changeTyping

Parameters:

  • id Identification of pokemon species to change the types.

  • primaryType New primary type of pokemon species.

  • secondaryType New secondary type of pokemon species.

Example call:

curl -X POST -i -H "Content-Type: application/json" --data '{"id":"15","primaryType":"FIRE","secondaryType":"DRAGON"}' http://localhost:8080/pa165/rest/pokemonSpecies/changeTyping