Skip to content

NoistNT/Pokemon-API

Repository files navigation

PokeWiki Logo

RESTful API powering Pokewiki, a comprehensive Pokémon knowledge base

Live DemoReport BugRequest Feature

About The Project

This API provides comprehensive access to Pokémon data:

Features

  • Fetch Pokémon: List all, by ID, or by name
  • Manage Pokémon: Create, update, and delete Pokémon entries
  • Types: Query all Pokémon types
  • Seeding: Populate the database with types from PokeAPI

Endpoints

Method Endpoint Description
GET /pokemon List all Pokémon
GET /pokemon/:id Get Pokémon by ID
GET /pokemon/name/:name Get Pokémon by name
POST /pokemon Create a new Pokémon
PATCH /pokemon/:id Update a Pokémon
DELETE /pokemon/:id Delete a Pokémon
GET /type List all types
GET /type/:id Get type by ID
POST /seeder Seed types from PokeAPI

Tech Stack

TypeScript Node.js NestJS MongoDB Mongoose Zod

Getting Started

Prerequisites

  • Node.js 20+
  • MongoDB (local or Atlas)
  • pnpm (recommended) or npm/yarn

Installation

# Clone the repository
git clone https://github.com/NoistNT/Pokemon-API.git

# Navigate to the project
cd Pokemon-API

# Install dependencies
pnpm install

Environment Variables

Create a .env file:

MONGODB_URI=your_mongodb_connection_string
BASE_URL=https://pokeapi.co/api/v2
CORS_ORIGIN=https://your-frontend.vercel.app
SEEDER_API_KEY=your_secure_api_key
TOTAL_POKEMONS=1281
PORT=3000

Running the Server

# Development
pnpm start:dev

# Production
pnpm build && pnpm start:prod

Seeding the Database

Before using the API, seed the types:

curl -X POST https://your-api.com/seeder \
  -H "Content-Type: application/json" \
  -H "x-api-key: your_seeder_api_key"

Contributing

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contact