Marketplace RESTful API Documentation

Overview

The Marketplace API provides endpoints to interact with a virtual shopping mall where users can browse, buy, and sell products from various vendors. This API documentation outlines the available endpoints, request/response formats, authentication requirements, and other relevant details.

Base URL

The base URL for accessing the Marketplace API is:

https://marketplace-api.netrobase.com

Authentication

Authentication is required for certain endpoints to access user-specific data and perform privileged actions. The Marketplace API uses token-based authentication. Users must include their authentication token in the Authorization header of each request.

Authorization: Token <user_token>

Authentication Routes

Login

POST /auth/login/

Authenticate a user and receive an access token.

Request:

{
  "username": "example_user",
  "password": "secure_password"
}

Response:

{
    "access": "access_token",
    "refresh": "refresh_token",
    "user": {
        "pk": 1,
        "username": "username",
        "email": "email",
        "first_name": "first_name",
        "last_name": "last_name"
    }
}

Logout

POST /auth/logout/

Log out the authenticated user.

User Details

GET /auth/user/

Retrieve details of the authenticated user.

Password Change

POST /auth/password/change/

Change the password for the authenticated user.

Request:

{
  "old_password": "current_password",
  "new_password1": "new_secure_password",
  "new_password2": "new_secure_password"
}

Response:

{
  "detail": "Password has been successfully changed."
}

Token Verify

POST /auth/token/verify/

Verify the validity of an access token.

Request:

{
  "token": "your_access_token"
}

Response:

{
  "detail": "Token is valid"
}

Token Refresh

POST /auth/token/refresh/

Obtain a new access token using a refresh token.

Request:

{
  "refresh": "your_refresh_token"
}

Response:

{
  "access": "your_new_access_token"
}

Endpoints

Categories

GET /categories/

Retrieve a list of all product categories.

Example response:

{
    "count": 0,
    "next": null,
    "previous": null,
    "results": [
      // category(resource) objects
    ]
}

POST /categories/

Create a new product category.

GET /categories/{id}/

Retrieve details of a specific product category.

PUT /categories/{id}/

Update details of a specific product category.

DELETE /categories/{id}/

Delete a specific product category.

Tags

GET /tags/

Retrieve a list of all product tags.

POST /tags/

Create a new product tag.

GET /tags/{id}/

Retrieve details of a specific product tag.

PUT /tags/{id}/

Update details of a specific product tag.

DELETE /tags/{id}/

Delete a specific product tag.

Subcategories

GET /subcategories/

Retrieve a list of all product subcategories.

POST /subcategories/

Create a new product subcategory.

GET /subcategories/{id}/

Retrieve details of a specific product subcategory.

PUT /subcategories/{id}/

Update details of a specific product subcategory.

DELETE /subcategories/{id}/

Delete a specific product subcategory.

Vendors

GET /vendors/

Retrieve a list of all vendors.

POST /vendors/

Create a new vendor.

GET /vendors/{id}/

Retrieve details of a specific vendor.

PUT /vendors/{id}/

Update details of a specific vendor.

DELETE /vendors/{id}/

Delete a specific vendor.

Products

GET /products/

Retrieve a list of all products.

POST /products/

Create a new product.

GET /products/{id}/

Retrieve details of a specific product.

PUT /products/{id}/

Update details of a specific product.

DELETE /products/{id}/

Delete a specific product.

Inventory

GET /inventory/

Retrieve a list of all inventory items.

POST /inventory/

Add a new inventory item.

GET /inventory/{id}/

Retrieve details of a specific inventory item.

PUT /inventory/{id}/

Update details of a specific inventory item.

DELETE /inventory/{id}/

Delete a specific inventory item.

Sales

GET /sales/

Retrieve a list of all sales.

POST /sales/

Record a new sale.

GET /sales/{id}/

Retrieve details of a specific sale.

PUT /sales/{id}/

Update details of a specific sale.

DELETE /sales/{id}/

Delete a specific sale.

Marketplace

GET /marketplace/

Retrieve details of the marketplace.

PUT /marketplace/

Update details of the marketplace.

Customers

GET /customers/

Retrieve a list of all customers.

POST /customers/

Create a new customer.

GET /customers/{id}/

Retrieve details of a specific customer.

PUT /customers/{id}/

Update details of a specific customer.

DELETE /customers/{id}/

Delete a specific customer.

Orders

GET /orders/

Retrieve a list of all orders.

POST /orders/

Place a new order.

GET /orders/{id}/

Retrieve details of a specific order.

PUT /orders/{id}/

Update details of a specific order.

DELETE /orders/{id}/

Delete a specific order.

Reviews

GET /reviews/

Retrieve a list of all product reviews.

POST /reviews/

Submit a new product review.

GET /reviews/{id}/

Retrieve details of a specific product review.

PUT /reviews/{id}/

Update details of a specific product review.

DELETE /reviews/{id}/

Delete a specific product review.

Wishlists

GET /wishlists/

Retrieve a list of all wishlists.

POST /wishlists/

Create a new wishlist.

GET /wishlists/{id}/

Retrieve details of a specific wishlist.

PUT /wishlists/{id}/

Update details of a specific wishlist.

DELETE /wishlists/{id}/

Delete a specific wishlist.

Payment Transactions

GET /transactions/

Retrieve a list of all payment transactions.

POST /transactions/

Record a new payment transaction.

GET /transactions/{id}/

Retrieve details of a specific payment transaction.

PUT /transactions/{id}/

Update details of a specific payment transaction.

DELETE /transactions/{id}/

Delete a specific payment transaction.

Shipping

GET /shipping/

Retrieve a list of all shipping records.

POST /shipping/

Record a new shipping transaction.

GET /shipping/{id}/

Retrieve details of a specific shipping record.

PUT /shipping/{id}/

Update details of a specific shipping record.

DELETE /shipping/{id}/

Delete a specific shipping record.

Ordering, Pagination, and Page Size

Ordering

By default, resources are ordered alphabetically or by creation date, depending on the resource. The following endpoints support ordering:

  • Category: Ordered by name.

  • Tag: Ordered by name.

  • Subcategory: Ordered by name.

  • Vendor: Ordered by company_name.

  • Product: Ordered by name.

  • Inventory: Ordered by id.

  • Sale: Ordered by sale_date.

  • Marketplace: Ordered by name.

  • Customer: Ordered by user__username.

  • Order: Ordered by order_date.

  • OrderItem: Ordered by id.

  • Review: Ordered by date_added.

  • Wishlist: Ordered by id.

  • PaymentTransaction: Ordered by transaction_date.

  • Shipping: Ordered by shipping_date.

Pagination

All endpoints that return lists of resources support pagination. By default, 10 items per page are returned.

Page Size

Clients can specify the page size by including the page_size query parameter in the request URL. The maximum page size is 100 items.

Example:

GET /categories/?page_size=20

Adjust the page_size parameter to control the number of items returned per page.

Conclusion

The Marketplace API provides a comprehensive set of endpoints to manage products, vendors, customers, orders, payments, and more. By following the guidelines outlined in this documentation, frontend developers can effectively integrate and utilize the Marketplace API to build powerful e-commerce applications.

Last updated