API Documentation

Welcome to the Parksons Stock Tracker API. This document provides all the information you need to interact with the API.

Back to Home UI

Overview

This API allows you to manage products and track stock movements in a warehouse. It provides endpoints for creating products, recording stock-in/stock-out transactions, and checking current inventory levels.

Base URL: https://kothasaikrishnas-parksons-internship.onrender.com

API Endpoints

Products

GET /api/products/

Retrieves a list of all products in the master list.


POST /api/products/

Creates a new product. The GTIN must be unique.

Request Body:

{
    "gtin": "8901234567890",
    "product_name": "Premium Quality Paper",
    "description": "A4 size, 90 GSM paper ream."
}

Example Request (curl):

curl -X POST https://kothasaikrishnas-parksons-internship.onrender.com/api/products/ \
-H "Content-Type: application/json" \
-d '{
    "gtin": "8901234567890",
    "product_name": "Premium Quality Paper",
    "description": "A4 size, 90 GSM paper ream."
}'

Example Success Response (201 Created):

{
    "id": 1,
    "gtin": "8901234567890",
    "product_name": "Premium Quality Paper",
    "description": "A4 size, 90 GSM paper ream."
}

Record Stock In

POST /api/stock/in/

Records an incoming stock transaction for one or more products.

Request Body:

{
    "items": [
        {
            "product_gtin": "8901234567890",
            "quantity": 100
        }
    ]
}

Example Success Response (201 Created):

{
    "message": "Transaction successful",
    "transaction_id": 1
}

Record Stock Out

POST /api/stock/out/

Records an outgoing stock transaction. The API will validate if there is enough stock available.

Request Body:

{
    "items": [
        {
            "product_gtin": "8901234567890",
            "quantity": 10
        }
    ]
}

Example Error Response (400 Bad Request):

{
    "error": "Not enough stock for 'Premium Quality Paper' (GTIN: 8901234567890). Available: 5, Requested: 10"
}

Get Stock Level

GET /api/stock/level/{gtin}/

Retrieves the current calculated stock level for a single product using its GTIN.

Example Request (curl):

curl https://kothasaikrishnas-parksons-internship.onrender.com/api/stock/level/8901234567890/

Example Success Response (200 OK):

{
    "product_gtin": "8901234567890",
    "product_name": "Premium Quality Paper",
    "quantity": 90
}