http://localhost:3000
This API uses JWT (JSON Web Tokens) for authentication. Protected endpoints require an Authorization header with the format:
Authorization: Bearer <jwt_token>
- Authentication Endpoints
- Pokemon Endpoints
- Team Management Endpoints
- Move Endpoints
- Error Handling
- Data Models
POST /auth/register
Create a new user account.
Request Body:
{
"username": "string",
"email": "string",
"password": "string"
}Response:
{
"id": 1,
"username": "john_doe",
"email": "john@example.com"
}Status Codes:
201- User created successfully400- Validation error500- Server error
POST /auth/login
Authenticate user with email and password.
Request Body:
{
"email": "string",
"password": "string"
}Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": 1,
"username": "john_doe",
"email": "john@example.com"
}
}Status Codes:
200- Login successful401- Invalid credentials500- Server error
POST /auth/google
Authenticate user with Google OAuth token.
Request Body:
{
"token": "google_id_token_string"
}Response:
{
"success": true,
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": 1,
"username": "John Doe",
"email": "john@gmail.com"
}
}Status Codes:
200- Google login successful400- Google authentication failed500- Server error
GET /pokemon
Retrieve all Pokemon with optional filtering and searching.
Query Parameters:
generation(optional) - Filter by generation (e.g., "generation-i")search(optional) - Search by name or Pokemon ID
Examples:
GET /pokemon
GET /pokemon?generation=generation-i
GET /pokemon?search=pikachu
GET /pokemon?search=25
GET /pokemon?generation=generation-i&search=char
Response:
[
{
"id": 1,
"name": "bulbasaur",
"pokeApiId": 1,
"types": ["grass", "poison"],
"sprite": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/1.png",
"height": 7,
"weight": 69,
"baseStats": {
"hp": 45,
"attack": 49,
"defense": 49,
"special-attack": 65,
"special-defense": 65,
"speed": 45
},
"abilities": ["overgrow", "chlorophyll"],
"generation": "generation-i"
}
]Status Codes:
200- Success500- Server error
GET /pokemon/:id
Retrieve a specific Pokemon by its database ID.
Parameters:
id- Pokemon database ID
Response:
{
"id": 1,
"name": "bulbasaur",
"pokeApiId": 1,
"types": ["grass", "poison"],
"sprite": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/1.png",
"height": 7,
"weight": 69,
"baseStats": {
"hp": 45,
"attack": 49,
"defense": 49,
"special-attack": 65,
"special-defense": 65,
"speed": 45
},
"abilities": ["overgrow", "chlorophyll"],
"moves": ["tackle", "growl", "vine-whip"],
"generation": "generation-i"
}Status Codes:
200- Success404- Pokemon not found500- Server error
🔒 All team endpoints require authentication
POST /teams
Create a new Pokemon team.
Request Body:
{
"name": "My Dream Team"
}Response:
{
"id": 1,
"name": "My Dream Team",
"userId": 1,
"createdAt": "2025-08-22T10:00:00.000Z",
"updatedAt": "2025-08-22T10:00:00.000Z",
"Pokemons": []
}Status Codes:
201- Team created successfully400- Request body required401- Unauthorized500- Server error
GET /teams
Retrieve all teams for the authenticated user.
Response:
[
{
"id": 1,
"name": "My Dream Team",
"userId": 1,
"createdAt": "2025-08-22T10:00:00.000Z",
"updatedAt": "2025-08-22T10:00:00.000Z",
"Pokemons": [
{
"id": 1,
"name": "bulbasaur",
"pokeApiId": 1,
"types": ["grass", "poison"],
"sprite": "https://...",
"TeamPokemon": {
"slot": 1,
"moves": ["tackle", "growl"],
"ability": "overgrow",
"nature": "modest"
}
}
]
}
]Status Codes:
200- Success401- Unauthorized500- Server error
GET /teams/:id
Retrieve a specific team with all Pokemon details.
Parameters:
id- Team ID
Response:
{
"id": 1,
"name": "My Dream Team",
"Pokemons": [
{
"id": 1,
"Pokemon": {
"id": 1,
"name": "bulbasaur",
"pokeApiId": 1,
"types": ["grass", "poison"],
"sprite": "https://...",
"baseStats": { ... }
},
"moves": ["tackle", "growl", "vine-whip", "razor-leaf"],
"ability": "overgrow",
"nature": "modest",
"slot": 1
}
]
}Status Codes:
200- Success401- Unauthorized404- Team not found500- Server error
PUT /teams/:id
Update team name and/or Pokemon composition.
Parameters:
id- Team ID
Request Body:
{
"name": "Updated Team Name",
"pokemonIds": [1, 2, 3, 4, 5, 6]
}Response:
{
"id": 1,
"name": "Updated Team Name",
"userId": 1,
"Pokemons": [ ... ]
}Status Codes:
200- Team updated successfully400- Bad request (max 6 Pokemon, body required)401- Unauthorized404- Team not found500- Server error
DELETE /teams/:id
Delete a team and all associated Pokemon.
Parameters:
id- Team ID
Response:
{
"message": "Team deleted"
}Status Codes:
200- Team deleted successfully401- Unauthorized404- Team not found500- Server error
POST /teams/:id/pokemon
Add a Pokemon to a team.
Parameters:
id- Team ID
Request Body:
{
"pokemonId": 1
}Response:
{
"team": {
"id": 1,
"name": "My Dream Team"
},
"pokemon": {
"name": "bulbasaur",
"teamId": 1,
"pokemonId": 1,
"slot": 1
}
}Status Codes:
201- Pokemon added successfully400- Bad request (pokemonId required, team full)401- Unauthorized404- Team not found500- Server error
DELETE /teams/:id/pokemon/:pokemonId
Remove a Pokemon from a team.
Parameters:
id- Team IDpokemonId- Pokemon ID to remove
Response:
{
"id": 1,
"name": "My Dream Team",
"Pokemons": [ ... ]
}Status Codes:
200- Pokemon removed successfully401- Unauthorized404- Team or Pokemon not found500- Server error
PATCH /teams/:teamId/pokemon/:pokemonId
Update Pokemon moves, ability, and nature within a team.
Parameters:
teamId- Team IDpokemonId- Pokemon ID
Request Body:
{
"moves": "tackle, growl, vine-whip, razor-leaf",
"ability": "overgrow",
"nature": "modest"
}Alternative moves format:
{
"moves": ["tackle", "growl", "vine-whip", "razor-leaf"],
"ability": "overgrow",
"nature": "modest"
}Response:
{
"message": "Pokemon details updated successfully"
}Status Codes:
200- Pokemon details updated successfully400- Bad request (missing parameters)401- Unauthorized404- Pokemon not found in team500- Server error
GET /api/moves/:name
Retrieve move details by name. Supports multiple name formats.
Parameters:
name- Move name (supports hyphens, spaces, different cases)
Examples:
GET /api/moves/thunderbolt
GET /api/moves/thunder-bolt
GET /api/moves/Thunder%20Bolt
Response:
{
"id": 1,
"name": "thunderbolt",
"type": "electric",
"category": "special",
"power": 90,
"accuracy": 100,
"pp": 15,
"description": "A strong electric blast that may paralyze the target."
}Status Codes:
200- Move found404- Move not found500- Server error
{
"message": "Error description"
}- Missing required fields
- Invalid data format
- Team exceeds 6 Pokemon limit
- No token provided
- Invalid token
- Token expired
- Access denied
- Resource not found
- Pokemon not found
- Team not found
- Database errors
- Server configuration issues
{
"id": "integer",
"username": "string",
"email": "string",
"password": "string (hashed)",
"googleId": "string (optional)",
"role": "string",
"createdAt": "datetime",
"updatedAt": "datetime"
}{
"id": "integer",
"name": "string",
"pokeApiId": "integer",
"types": "array",
"sprite": "string",
"height": "integer",
"weight": "integer",
"baseStats": "object",
"abilities": "array",
"moves": "array",
"generation": "string",
"createdAt": "datetime",
"updatedAt": "datetime"
}{
"id": "integer",
"name": "string",
"userId": "integer",
"createdAt": "datetime",
"updatedAt": "datetime"
}{
"teamId": "integer",
"pokemonId": "integer",
"slot": "integer (1-6)",
"moves": "array (optional)",
"ability": "string (optional)",
"nature": "string (optional)",
"createdAt": "datetime",
"updatedAt": "datetime"
}{
"id": "integer",
"name": "string",
"type": "string",
"category": "string",
"power": "integer",
"accuracy": "integer",
"pp": "integer",
"description": "string",
"createdAt": "datetime",
"updatedAt": "datetime"
}Currently, no rate limiting is implemented. Consider implementing rate limiting for production use.
CORS is enabled for all origins. Configure appropriately for production.
Required environment variables:
JWT_SECRET- Secret key for JWT token signingGOOGLE_CLIENT_ID- Google OAuth client IDDB_NAME- Database nameDB_USER- Database usernameDB_PASS- Database passwordDB_HOST- Database hostDB_PORT- Database port
The API includes comprehensive test coverage (93.51%) using Jest and Supertest. Run tests with:
npm test
npm run test:coverageAPI Version: 1.0.0 Last Updated: August 22, 2025