API

Free Product Mock REST API Documentation

Free Product Mock REST API Documentation
117 views
5 min read
#API

The MockX Products API allows developers to access and manipulate a wide array of product data, ranging from electronic devices to household items. This API facilitates operations such as fetching all products, searching for specific products, managing product categories, and modifying product details.

Endpoints Overview

The MockX Products API offers a variety of endpoints to suit different requirements for accessing and managing product information:

  • GET /: Retrieve all products in the database.
  • GET /search: Search for products based on query parameters.
  • GET /categories: Obtain a list of all product categories.
  • GET /:id: Fetch a specific product by its unique ID.
  • GET /category/:categoryName: Retrieve products by category name.
  • POST /add: Add a new product to the database.
  • PUT /:id: Update an entire product entry by ID.
  • PATCH /:id: Partially update a product entry by ID.
  • DELETE /:id: Remove a product entry by ID.

Get All Products

Fetch a comprehensive list of all products available.

GET https://api.mockx.net/products

Parameters:

limit: Limit the number of products returned. skip: Skip a specified number of products. select: Specify fields to include in the returned products.

Example Response:

{
"products": [
   {
            "id": 1,
            "title": "Cutting-Edge Fitness Tracker",
            "description": "Explore the skies with ease and capture breathtaking views.",
            "price": 549,
            "discountPercentage": 12.96,
            "rating": 4.69,
            "stock": 94,
            "brand": "Garmin",
            "category": "wearables",
            "thumbnail": "https://via.placeholder.com/150?text=Product1-Thumbnail",
            "images": [
                "https://via.placeholder.com/150?text=Product1-Image1",
                "https://via.placeholder.com/150?text=Product1-Image2"
            ]
    },
    ...
],
"total": 133,
"skip": 0,
"limit": 10
}

Search Products

Search for products using specific query parameters.

GET https://api.mockx.net/products/search?q=solar+charger

Example :

GET https://api.mockx.net/products/search?q=Fitness

Request body :

{
    "products": [
        {
            "id": 1,
            "title": "Cutting-Edge Fitness Tracker",
            "description": "Explore the skies with ease and capture breathtaking views.",
            "price": 549,
            "discountPercentage": 12.96,
            "rating": 4.69,
            "stock": 94,
            "brand": "Garmin",
            "category": "wearables",
            "thumbnail": "https://via.placeholder.com/150?text=Product1-Thumbnail",
            "images": [
                "https://via.placeholder.com/150?text=Product1-Image1",
                "https://via.placeholder.com/150?text=Product1-Image2"
            ]
        },
        ...
    ],
    "total": 3,
    "skip": 0,
    "limit": 3
}

Parameters:

q: Search query (e.g., "solar charger"). limit, skip, select: Similar to the "Get All Products" endpoint. Example Response:

{
"products": [
   {
            "id": 1,
            "title": "Cutting-Edge Fitness Tracker",
            "description": "Explore the skies with ease and capture breathtaking views.",
            "price": 549,
            "discountPercentage": 12.96,
            "rating": 4.69,
            "stock": 94,
            "brand": "Garmin",
            "category": "wearables",
            "thumbnail": "https://via.placeholder.com/150?text=Product1-Thumbnail",
            "images": [
                "https://via.placeholder.com/150?text=Product1-Image1",
                "https://via.placeholder.com/150?text=Product1-Image2"
            ]
        },
        ...
],
"total": 5,
"skip": 0,
"limit": 5
}

Get Product Categories

Retrieve a list of all unique product categories.

GET https://api.mockx.net/products/categories

Example Response:

{
"categories": ["laptops", "smartphones", ...]
}

Get Product by ID

Fetch detailed information about a specific product by its unique ID.

GET https://api.mockx.net/products/{id}

Parameters:

id: The unique identifier of the product. select: Specify fields to include in the returned product. Example Response:

{
    "id": 1,
    "title": "Cutting-Edge Fitness Tracker",
    "description": "Explore the skies with ease and capture breathtaking views.",
    "price": 549,
    "discountPercentage": 12.96,
    "rating": 4.69,
    "stock": 94,
    "brand": "Garmin",
    "category": "wearables",
    "thumbnail": "https://via.placeholder.com/150?text=Product1-Thumbnail",
    "images": [
        "https://via.placeholder.com/150?text=Product1-Image1",
        "https://via.placeholder.com/150?text=Product1-Image2"
    ]
}

Get Products by Category Name

Retrieve products belonging to a specific category.

GET https://api.mockx.net/products/category/{categoryName}

Parameters:

categoryName: The name of the product category. limit, skip, select: Same as above. Example Response:

{
    "products": [
        {
            "id": 1,
            "title": "Cutting-Edge Fitness Tracker",
            "description": "Explore the skies with ease and capture breathtaking views.",
            "price": 549,
            "discountPercentage": 12.96,
            "rating": 4.69,
            "stock": 94,
            "brand": "Garmin",
            "category": "wearables",
            "thumbnail": "https://via.placeholder.com/150?text=Product1-Thumbnail",
            "images": [
                "https://via.placeholder.com/150?text=Product1-Image1",
                "https://via.placeholder.com/150?text=Product1-Image2"
            ]
        },
        ...
    ],
    "total": 4,
    "skip": 0,
    "limit": 4
}

Add New Product

Add a new product to the database.

POST https://api.mockx.net/products/add

Body: Include all product details in the request body.

 {
            "title": "Cutting-Edge Fitness Tracker",
            "description": "Explore the skies with ease and capture breathtaking views.",
            "price": 549,
            "discountPercentage": 12.96,
            "rating": 4.69,
            "stock": 94,
            "brand": "Garmin",
            "category": "wearables",
            "thumbnail": "https://via.placeholder.com/150?text=Product1-Thumbnail",
            "images": [
                "https://via.placeholder.com/150?text=Product1-Image1",
                "https://via.placeholder.com/150?text=Product1-Image2"
            ]
        }

Example Response:

{
    "id": 101,
    "title": "Cutting-Edge Fitness Tracker",
    "price": 549,
    "stock": 94,
    "rating": 4.69,
    "images": [
        "https://via.placeholder.com/150?text=Product1-Image1",
        "https://via.placeholder.com/150?text=Product1-Image2"
    ],
    "thumbnail": "https://via.placeholder.com/150?text=Product1-Thumbnail",
    "description": "Explore the skies with ease and capture breathtaking views.",
    "brand": "Garmin",
    "category": "wearables"
}

Update Product by ID

Update the details of an existing product by its ID.

PUT https://api.mockx.net/products/{id}

Parameters:

id: The unique identifier of the product to be updated. Body: Include the updated product details in the request body. Example Response:

{
    "id": 100,
    "title": "Cutting-Edge Fitness Tracker",
    "price": 549,
    "stock": 94,
    "rating": 4.69,
    "images": [
        "https://via.placeholder.com/150?text=Product1-Image1",
        "https://via.placeholder.com/150?text=Product1-Image2"
    ],
    "thumbnail": "https://via.placeholder.com/150?text=Product1-Thumbnail",
    "description": "Explore the skies with ease and capture breathtaking views.",
    "brand": "Garmin",
    "category": "wearables"
}

Delete Product by ID

Remove a product from the database by its ID.

DELETE https://api.mockx.net/products/{id}

Parameters:

id: The unique identifier of the product to be deleted. Example Response:

{
  "message": "Product with id '{id}' successfully deleted."
}
MockX offers free, reliable mock APIs for easy testing and development, ideal for developers seeking to enhance their workflow without the complexities of setting up any server.
Copyright © 2024. Made with ♥ by MockX.net