People-Base API is a RESTful web service for managing and retrieving information about individuals. It provides CRUD (Create, Read, Update, Delete) operations for people, along with filtering options based on name, age, gender, and nationality.
Before running the People-Base API, make sure you have the following prerequisites installed:
- Go (Programming language): Installation Guide
- SQLite3 (Database): Installation Guide
- Goose (Database migration tool): Installation Guide
- Swagger (API documentation tool): Installation Guide
-
Clone the repository:
git clone https://github.com/ilkhom19/task_peopler.git
-
Change to the project directory:
cd task_peopler
-
Build and run the API:
swag init --pd -g cmd/main.go source .env && go build -o app main.go && ./app
The API will be accessible at
http://localhost:8080/docs/index.html
The API provides endpoints for managing people. You can use tools like curl
or Postman to interact with the API. Here are some example requests:
-
Create a new person:
curl -X POST -H "Content-Type: application/json" -d '{"name": "John", "surname": "Doe"}' http://localhost:8080/person
-
Retrieve a person by ID:
curl http://localhost:8080/person/1
-
Delete a person by ID:
curl -X DELETE http://localhost:8080/person/1
-
Get people by name:
curl http://localhost:8080/people/name?name=John&page=1&pageSize=10
-
Get people by age:
curl http://localhost:8080/people/age?age=30&page=1&pageSize=10
-
Get people by gender:
curl http://localhost:8080/people/gender?gender=male&page=1&pageSize=10
-
Get people by nationality:
curl http://localhost:8080/people/nationality?nationality=UZ&page=1&pageSize=10