Categorygithub.com/Fairuzzzzz/pokedex-api
repository
0.0.0-20241110125723-b572e518ba86
Repository: https://github.com/fairuzzzzz/pokedex-api.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author

# README

Pokedex API

A RESTful API service for managing pokemon teams using data from PokeAPI.

Features

  • User authentication (signup & login)
  • Pokemon search
  • Team management (create, delete, get details)
  • Pokemon management in teams (add, remove, list)

Installation & Setup

Steps

  1. Clone the repository
git clone https://github.com/yourusername/pokedex-api.git
cd pokedex-api
  1. Install dependencies
go mod download
  1. Configure database
  • Create PostgreSQL database
  • Update database configuration in internal/configs/config.yaml
  1. Run the application
go run cmd/main.go

The server will start on port 9999 by default.

API Endpoints

Authentication

MethodEndpointDescription
POST/memberships/sign-upRegister new user
POST/memberships/loginLogin user

Pokemon

MethodEndpointDescription
GET/pokemon/:nameSearch pokemon by name

Team Management

MethodEndpointDescription
POST/team/create-teamCreate new pokemon team
GET/team/list-teamGet list of teams
GET/team/get-teamGet team details
POST/team/delete-teamDelete a team

Pokemon in Team

MethodEndpointDescription
GET/pokemon-team/list/:teamIDList pokemon in a team
POST/pokemon-team/addAdd pokemon to team
POST/pokemon-team/removeRemove pokemon from team

Usage Examples

Register New User

curl -X POST http://localhost:9999/memberships/sign-up \
-H "Content-Type: application/json" \
-d '{
    "email": "[email protected]",
    "username": "username",
    "password": "password123"
}'

Login

curl -X POST http://localhost:9999/memberships/login \
-H "Content-Type: application/json" \
-d '{
    "email": "[email protected]",
    "password": "password123"
}'

Search Pokemon

curl -X GET http://localhost:9999/pokemon/pikachu \
-H "Authorization: <access_token>"

Create Team

curl -X POST http://localhost:9999/team/create-team \
-H "Authorization: <access_token>" \
-H "Content-Type: application/json" \
-d '{
    "teamName": "My Team"
}'

Add Pokemon to Team

curl -X POST http://localhost:9999/pokemon-team/add \
-H "Authorization: <access_token>" \
-H "Content-Type: application/json" \
-d '{
    "teamID": 1,
    "pokemonName": "pikachu"
}'

Notes

  • Maximum 6 pokemon per team
  • Token expires in 10 minutes
  • All endpoints except signup/login require authentication token