-
Notifications
You must be signed in to change notification settings - Fork 4
REST API
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.
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.
Returns all pokemon species.
HTTP-method: GET
URI suffix: none
Parameters: none
Example call:
curl -i -X GET http://localhost:8080/pa165/rest/pokemonSpecies
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
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
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
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
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
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