Giter Club home page Giter Club logo

sagarmatha-fruits_api's Introduction

SAGARMATHA_FRUITS_API

Simple CRUD API for a local fruit business.

RESTFUL APIs

  1. GET FRUITS
  2. GET FRUIT BY ID
  3. POST FRUITS
  4. UPDATE FRUIT
  5. DELETE FRUIT

Endpoints

Every endpoint will respond with required HTTP status codes along side with the required body.

For the hosted onrender api, API_URI=https://sagarmatha-fruits-api.onrender.com/api/v1/

Auth

1. ADMIN LOGIN

Endpoint:

Method: POST
Type: RAW/JSON
URL: {{API_URI}}/auth/login/admin

Body:

{
    "email": "[email protected]",
    "password": "test1234"
}

Response:

{
    "message": "Login successful",
    "token": "signed_jwt_token"
}

Headers:

The authorization header is required when performing admin related tasks. In case of our api a client should include the token in header when interacting with the endpoints of:

  • Create fruit details.
  • Update fruit details.
  • Delete fruit details.

Key Value Description
Authorization Bearer signed_jwt_token Token obtained from response while logging in.

Fruits

1. GET FRUITS

You can pass in page and limit as query for pagination, the default values are as" page=1 and limit=10.

Endpoint:

Method: GET
Type:
URL: {{API_URI}}/fruits?page=1&limit=5

Response:

{
    "message": "All fruits fetched successfully",
    "data": [
        {
            "_id": "fruit_id",
            "name": "apple",
            "price": 69,
            "imageUrl": "https://res.cloudinary.com/dra4rqms4/image/upload/v1704892600/Fruits/dcmkuatx5uudwbcwayhu.jpg",
            "__v": 0
        }
    ]
}

2. GET FRUIT BY ID

Endpoint:

Method: GET
Type:
URL: {{API_URI}}/fruits/fruit_id

Response:

{
    "message": "Fruit fetched successfully",
    "data": {
        "_id": "fruit_id",
        "name": "mango",
        "price": 69,
        "imageUrl": "https://res.cloudinary.com/dra4rqms4/image/upload/v1704896380/Fruits/kmnamq0uwziuvbetkwde.jpg",
        "__v": 0
    }
}

3. POST FRUITS

Endpoint:

Method: POST
Type: FORMDATA
URL: {{API_URI}}/fruits/

Body:

Key Value Description
name apple
price 349.9
image apple.jpeg
unit /kg

Response:

{
    "message": "Fruit created successfully",
    "data": {
        "name": "apple",
        "price": 349.9,
        "imageUrl": "https://res.cloudinary.com/dra4rqms4/image/upload/v1704892600/Fruits/dcmkuatx5uudwbcwayhu.jpg",
        "unit": "/kg",
        "_id": "fruit_id",
        "__v": 0
    }
}

4. UPDATE FRUIT

Endpoint:

Method: PUT
Type: FORMDATA
URL: {{API_URI}}/fruits/fruit_id

Body:

Key Value Description
name mango
price 69

Response:

{
    "message": "Fruit updated successfully",
    "data": {
        "_id": fruit_id,
        "name": "mango",
        "price": 69,
        "imageUrl": "https://res.cloudinary.com/dra4rqms4/image/upload/v1704896380/Fruits/kmnamq0uwziuvbetkwde.jpg",
        "__v": 0
    }
}

5. DELETE FRUIT

Endpoint:

Method: DELETE
Type:
URL: {{API_URI}}/fruits/fruit_id

Response:

{
    "message": "Fruit deleted successfully",
    "data": {
        "_id": "fruit_id",
        "name": "mango",
        "price": 69,
        "imageUrl": "https://res.cloudinary.com/dra4rqms4/image/upload/v1704896380/Fruits/kmnamq0uwziuvbetkwde.jpg",
        "__v": 0
    }
}

Back to top

Generated at 2024-01-10 20:42:21 by docgen

sagarmatha-fruits_api's People

Contributors

senor101 avatar

Stargazers

Shiva Shrestha avatar

Watchers

 avatar

sagarmatha-fruits_api's Issues

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.