My Store

PAID
REST
By bp | Updated 3 months ago | other
Followers: 2
API Creator:
Rapid account: Bp
bp
bp
Log In to Rate API
Rating: 4.5 - Votes: 2

README

My Store API Documentation

This is the API documentation for My Store API, which allows you to manage product catalogs and orders. This API is open for demonstration and testing purposes, and data will be wiped periodically.

Download:

  • OpenAPI 3.0 Spec: [/-json] (Assuming the spec is served on the same domain)
  • Paw Project: [/My-Store-API.paw] (Assuming the Paw Project file is served on the same domain)

Base URL: https://mystoreapi.com

Authentication:

Several endpoints require a JWT token for authorization. You can obtain a JWT token by logging in via the /auth/login endpoint. Include the JWT token in the Authorization header using the Bearer scheme (e.g., Authorization: Bearer YOUR_JWT_TOKEN).

API Endpoints

Catalog

  • Get Categories (GET /catalog/categories)

    • This endpoint retrieves all available product categories.
    • Tags: Catalog
    • Responses:
      • 200: Success. Returns an array of category objects.
  • Get Products (GET /catalog/products)

    • This endpoint retrieves a paginated list of all products in the store.
    • Parameters:
      • limit (required, query): The maximum number of products to return (integer).
      • skip (required, query): The number of products to skip before starting to collect results (integer for pagination).
    • Tags: Catalog
    • Responses:
      • 200: Success. Returns an array of product objects.
  • Get Products in Category (GET /catalog/category/{category}/products)

    • This endpoint retrieves a paginated list of all products in a specific category.
    • Parameters:
      • limit (required, query): The maximum number of products to return (integer).
      • skip (required, query): The number of products to skip before starting to collect results (integer for pagination).
      • category (required, path): The category slug (string).
    • Tags: Catalog
    • Responses:
      • 200: Success. Returns an array of product objects.
  • Get Product (GET /catalog/product/{id})

    • This endpoint retrieves a single product by its ID.
    • Parameters:
      • id (required, path): The product ID (integer).
    • Tags: Catalog
    • Responses:
      • 200: Success. Returns a single product object.
  • Create Product (POST /catalog/product)

    • This endpoint creates a new product in the store. Requires user authentication.
    • Request Body:
      • A JSON object following the CreateProductDto schema (see components section).
    • Tags: Catalog
    • Responses:
      • 201: Created. Returns the newly created product object.
  • Delete Product (DELETE /catalog/product/{id})

    • This endpoint deletes a product from the store. Requires user authentication.
    • Parameters:
      • id (required, path): The product ID (integer).
    • Tags: Catalog
    • Responses:
      • 200: Success.

Order

  • Create Order (POST /order/new)

    • This endpoint creates a new order. Requires user authentication.
    • Request Body:
      • A JSON object following the CreateOrderDto schema (see components section).
    • Tags: Order
    • Responses:
      • 201: Created. Returns the newly created order object.
  • Add Product to Order (POST /order/{id}/product)

    • This endpoint adds a product to an existing order. Requires user authentication.
    • Parameters:
      • id (required, path): The order ID (string).
    • Request Body:
      • A JSON object following the AddProductToOrderDto schema (see components section).
    • Tags: Order
    • Responses:
      • 201: Created. Returns the updated order object.
  • Get Order (GET /order/{id})

    • This endpoint retrieves a single order by its ID. Requires user authentication.
    • Parameters:
      • id (required, path): The order ID (string).
    • Tags: Order
    • Responses:
      • 200: Success. Returns the order object.
  • Cancel Order (DELETE /order/{id})

  • Cancel Order (DELETE /order/{id})

    • This endpoint cancels an existing order. Requires user authentication.
    • Parameters:
      • id (required, path): The order ID (string).
    • Tags: Order
    • Responses:
      • 200: Success.
  • Delete Product from Order (DELETE /order/{id}/product/{productId})

    • This endpoint deletes a specific product from an existing order. Requires user authentication.
    • Parameters:
      • id (required, path): The order ID (string).
      • productId (required, path): The product ID to remove (integer).
    • Tags: Order
    • Responses:
      • 200: Success. Returns the updated order object.
  • Get User Orders (GET /order/my)

    • This endpoint retrieves all orders placed by the authenticated user. Requires user authentication.
    • Authorization: Include a JWT token in the Authorization header using the Bearer scheme.
    • Tags: Order
    • Responses:
      • 200: Success. Returns an array of order objects.
  • Place Order (POST /order/{id}/place)

    • This endpoint finalizes and places an existing order. Requires user authentication.
    • Parameters:
      • id (required, path): The order ID (string).
    • Authorization: Include a JWT token in the Authorization header using the Bearer scheme.
    • Tags: Order
    • Responses:
      • 201: Created. Returns the finalized order object.

Authentication

  • Login (POST /auth/login)

    • This endpoint allows users to log in and obtain a JWT token for authentication.
    • Request Body:
      • A JSON object following the CreateUserDto schema (see components section).
    • Tags: Authentication
    • Responses:
      • 201: Created. Returns a JSON object containing the JWT token.
  • Create User (Sign Up) (POST /auth/user)

    • This endpoint creates a new user account.
    • Request Body:
      • A JSON object following the CreateUserDto schema (see components section).
    • Tags: Authentication
    • Responses:
      • 201: Created. Returns a success message.
  • Me (GET /auth/me)

    • This endpoint retrieves basic information about the currently authenticated user. Requires user authentication.
    • Authorization: Include a JWT token in the Authorization header using the Bearer scheme.
    • Tags: Authentication
    • Responses:
      • 200: Success. Returns a JSON object containing basic user information.

Components

This section describes the data structures used in some API requests and responses.

  • CreateProductDto

    • This object represents a new product to be created.
    • Properties:
      • name (required, string): The name of the product.
      • price (required, number): The price of the product.
      • manufacturer (required, string): The manufacturer of the product.
      • category (required, string): The category of the product (matches a category slug).
      • description (required, string): A description of the product.
      • tags (required, string): Comma-separated tags associated with the product (optional).
  • CreateOrderDto

    • This object represents a new order to be created.
    • Properties:
      • customer (required, string): The customer placing the order.
      • address (required, string): The customerโ€™s address for order fulfillment.
  • AddProductToOrderDto

    • This object represents a product to be added to an existing order.
    • Properties:
      • productId (required, string): The ID of the product to add (matches a product ID).
      • amount (required, number): The quantity of the product to add.
  • CreateUserDto

    • This object represents a new user to be created.
    • Properties:
      • username (required, string): The username for the new user.
      • password (required, string): The password for the new user.

This concludes the API documentation for My Store API. Please refer to the specific details of each endpoint for proper usage and expected responses. Remember that this API is for demonstration purposes only.