Git Product home page Git Product logo

ecommerce-rest-api's Introduction

Ecommerce REST API

RESTful HTTP API using Python Flask that allows users to manage their ecommerce platform.

Ability to create, read, update, and delete products, categories and subcategories. A category can have multiple subcategories and a subcategory can belong to multiple categories. Products can belong to multiple categories and subcategories.

Fetching a product fetches the details of categories and subcategories it belongs to. Provides the ability to search for products by name, category and subcategories.

Paginates result when products are fetched by categories or subcategories.

Requirements

pip install -r requirements.txt

Usage

Start the server:

python app.py (Starts the server on 127.0.0.1:5000)

This project is preloaded with a dummy sqlite database located in the instance directory. To start from a scratch db, delete the instance directory and start the server.

To test the API using Postman, install postman agent in your OS and call the API using Postman.

Endpoints

Fetch products using name, category, subcategory

  • [GET] /product/<name: string> - Get product with name: name

  • [GET] /subcategory/<subcategory_id: int>/products - Get product with within subcategory subcategory. Returns first page of the paginated results.

  • [GET] /subcategory/<subcategory_id: int>/products?page=<page_no> - Get product with within subcategory subcategory. Returns page_no of the paginated results.

  • [GET] /category/<category_id: int>/products - Get product with within category category. Returns first page of the paginated results.

  • [GET] /category/<category_id: int>/products?page=<page_no> - Get product with within category category. Returns page_no of the paginated results.



Category

  • [GET] /categories - Get all categories

  • [GET] /category/(int: category_id) - Get category with category_id

  • [DELETE] /category/(int: category_id) - Delete category with category_id

  • [POST] /category/create - Create a new category

{
  "name": "name",
  "subcategories": [<subcategory ids>] //optional
}
  • [PUT] /category/(int: category_id)/update - Update category with category_id
{
  "name": "name",
  "subcategories": [<subcategory ids>] //optional
}



Subcategory

  • [GET] /subcategories - Get all subcategories

  • [GET] /subcategory/(int: subcategory_id) - Get subcategory with subcategory_id

  • [DELETE] /subcategory/(int: subcategory_id) - Delete subcategory with subcategory_id

  • [POST] /subcategory/create - Create a new subcategory

{
  "name": "name",
  "categories": [(category ids)] //optional
  "products": [<subcategory ids>] // optional
}
  • [PUT] /subcategory/(int: subcategory_id)/update - Update subcategory with subcategory_id
{
  "name": "name",
  "categories": [<category ids>] //optional
  "products": [<subcategory ids>] // optional
}



Product

  • [GET] /products - Get all products

  • [GET] /product/(int: product_id) - Get product with product_id

  • [DELETE] /product/(int: product_id) - Delete product with product_id

  • [POST] /product/create - Create a new product

{
  "name": "name",
  "description": "description",
  "subcategories": [<subcategory ids>] //optional
}
  • [PUT] /product/(int: product_id)/update - Update product with product_id
{
  "name": "name",
  "description": "description",
  "subcategories": [<subcategory ids>] //optional
}

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.