Pokemon
Welcome to Pokemon! 😊 This is a simple Phoenix project that specific data from the Poke API and displays it through REST endpoints. The project also saves the full information it got from the Poke API in a database, making a sort of cache.
Running the Project
- Install dependencies
mix deps.get
- Setup a docker container for postgres
docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres
- Create and migrate your database
mix ecto.setup
- Start Phoenix endpoint
mix phx.server
Now you can visit localhost:4000
from your browser.
Making API requests
After the project is running, you can make API request to the available endpoints. At the moment we have the following endpoints:
get name
Using this endpoint you can get the name of a pokemon by its id in the Poke api.
curl -X GET http://localhost:4000/api/name/:pokeapi_id
Example:
> curl -X GET http://localhost:4000/api/name/132
{"data":{"name":"ditto"}}%
get pokeapi_id
Using this endpoint you can get the id of a pokemon in the Poke api by its name.
curl -X GET http://localhost:4000/api/pokeapi_id/:name
Example:
> curl -X GET http://localhost:4000/api/pokeapi_id/ditto
{"data":{"pokeapi_id":"132"}}%
Running tests
To run the test suite, make sure you have the postgres container up and run
mix test