Giter Site home page Giter Site logo

person-api's Introduction

Person API

The Person API is a simple RESTful API that allows you to perform CRUD (Create, Read, Update, Delete) operations on person records. This README provides instructions on setting up, running, and using the API.

Table of Contents

Prerequisites

Before you begin, ensure you have the following:

  • Python 3.10+
  • pip (Python package manager)
  • Flask
  • Flask-SQLAlchemy
  • [SQLite] (or an alternative database, based on your choice)

Getting Started

Installation

  1. Clone this repository to your local machine: git clone https://github.com/yourusername/person-api.git ------- Navigate to the project directory:

cd person-api ------- Install the required Python packages: pip install -r requirements.txt

Running the API

Ensure your database is set up and running.

Run the following command to create the database tables:

python app.py -------- The API should now be running locally at http://localhost:5000.

API Endpoints

Create a Person

Endpoint: POST /api

Description: Create a new person with the given name.

Request Body: JSON data containing person details (name, age, email).

Example Request: curl -X POST http://localhost:5000/api -H "Content-Type: application/json" -d

'{
"name": "Chisom Daniel"
}'

Retreive all persons

Endpoint: GET /api/

Description: Retrieve details of all persons in the database.

Example Request: curl http://localhost:5000/api/

Retreive a person

Endpoint: GET /api/int:user_id

Description: Retrieve details of a person with the given user id.

Example Request: curl http://localhost:5000/api/int:user_id

Update a person

Endpoint: PUT /api/int:user_id

Description: Update details of a person with the given name. Request Body: JSON data containing updated person details (age, id, email).

Example Request: curl -X PUT http://localhost:5000/api/int:user_id -H "Content-Type: application/json" -d

'{
    "name": "john doe",
    "id": <int:user_id>
 }'

Delete a person

Endpoint: DELETE /api/int:user_id

Description: Delete a person with the given name.

Example Request: curl -X DELETE http://localhost:5000/api/int:user_id,

Testing the API

You can use Postman or a testing framework (e.g., pytest) to test the API. Detailed instructions for testing the API can be found in the Testing the API section of the README.

Contributing

If you'd like to contribute to this project, please follow the guidelines in CONTRIBUTING.md.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

person-api's People

Contributors

chisomd90 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.