GithubHelp home page GithubHelp logo

hngtask2's Introduction

HngTask2

API Documentation for [person_api]

Base URL

The base URL for all API endpoints is: https://person-api-hbt8.onrender.com/

Endpoints

Create a Person

  • Endpoint: /persons/
  • Method: POST
  • Description: Create a new person.
  • Request Body:
    {
        "name": "string",
        "age": integer
    }
  • Response:
    • Status Code: 201 (Created)
    • Response Body:
      {
          "id": integer,
          "name": "string",
          "age": integer
      }

Retrieve a Person

  • Endpoint: /persons/<int:id>/
  • Method: GET
  • Description: Retrieve a person by their ID.
  • Response:
    • Status Code: 200 (OK)
    • Response Body:
      {
          "id": integer,
          "name": "string",
          "age": integer
      }

Update a Person

  • Endpoint: /persons/<int:id>/
  • Method: PUT
  • Description: Update a person's details.
  • Request Body:
    {
        "name": "string",
        "age": integer
    }
  • Response:
    • Status Code: 200 (OK)
    • Response Body:
      {
          "id": integer,
          "name": "string",
          "age": integer
      }

Partially Update a Person

  • Endpoint: /persons/<int:id>/
  • Method: PATCH
  • Description: Partially update a person's details.
  • Request Body:
    {
        "name": "string" (optional),
        "age": integer (optional)
    }
  • Response:
    • Status Code: 200 (OK)
    • Response Body:
      {
          "id": integer,
          "name": "string",
          "age": integer
      }

Delete a Person

  • Endpoint: /persons/<int:id>/
  • Method: DELETE
  • Description: Delete a person by their ID.
  • Response:
    • Status Code: 204 (No Content)

Usage Examples

Create a Person

Request:

POST /persons/
Content-Type: application/json

{
    "name": "John Doe",
    "age": 30
}

Response:

{
    "id": 1,
    "name": "John Doe",
    "age": 30
}

Retrieve a Person

Request:

GET /persons/1

Response:

{
    "id": 1,
    "name": "John Doe",
    "age": 30
}

Update a Person

Request:

PUT /persons/1
Content-Type: application/json

{
    "name": "Updated John Doe",
    "age": 35
}

Response:

{
    "id": 1,
    "name": "Updated John Doe",
    "age": 35
}

Partially Update a Person

Request:

PATCH /persons/1
Content-Type: application/json

{
    "age": 40
}

Response:

{
    "id": 1,
    "name": "Updated John Doe",
    "age": 40
}

Delete a Person

Request:

DELETE /persons/1

Response:

HTTP/1.1 204 No Content

hngtask2's People

Contributors

salimmwatsefu 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.