This is a RESTful API for performing CRUD operation of a person.
These instructions will guide you through setting up and running Your API Name on your local machine.
Before you begin, ensure you have met the following requirements:
- Python (version 3.6 or higher)
- Virtualenv (recommended for managing Python environments)
- Django (version 3.5 or higher)
- Django Rest Framework
-
Clone the repository to your local machine:
git clone https://github.com/CaptainVee/stage1
-
Navigate to the project directory:
cd stage1
-
Create and activate a virtual environment (optional but recommended):
virtualenv venv source venv/bin/activate
-
Install the required Python packages:
pip install -r requirements.txt
-
Apply migrations to create the database:
python manage.py migrate
Starting the API To run the API locally, use the following command:
python manage.py runserver
The API will be accessible at http://127.0.0.1:8000/
Create a Person (POST) Create a new person by sending a POST request to the following endpoint:
POST /api/
Example request body:
{
"name": "John Doe"
}
Note name must be unique
Retrieve a Person (GET) Retrieve information about a person by sending a GET request to the following endpoint:
GET /api/
Example request body:
{
"name": "John Doe"
}
or
{
"id": 5
}
Update a Person (PUT) Update a person's information by sending a PUT request to the following endpoint:
PUT /api/
Example request body:
{
"id": id,
"name": "Updated Name"
}
Delete a Person (DELETE) Delete a person by sending a DELETE request to the following endpoint:
DELETE /api/
{
"name": "John Doe"
}
or
{
"id": 5
}
Below is a simplified UML class diagram representing the structure and relationships of the PersonView
API class and the Person
model.
(url)[https://drawsql.app/teams/captain/diagrams/stage2]