JuliaMathias / pokemon

Find them all

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. Install dependencies
mix deps.get
  1. Setup a docker container for postgres
 docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres
  1. Create and migrate your database
mix ecto.setup
  1. 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

About

Find them all


Languages

Language:Elixir 77.6%Language:CSS 16.3%Language:HTML 3.8%Language:JavaScript 2.3%