Daily-Market-Price-API

Kerala Vegetable Market Price API

This repository provides live and historical vegetable market prices for various markets across Kerala, India. The data is scraped from the VFPCK (Vegetable and Fruit Promotion Council Keralam) website and stored in structured JSON files.


Overview


Features


Data Structure

Live Data (live.json)

The live.json now stores each item under a normalized key (lowercase with underscores), along with its original name, market-wise prices, and last updated date.

{
  "data": {
    "amaranthus_green": {
      "name": "Amaranthus Green",
      "data": {
        "ALUVA": {
          "KERALA": { "wp": "30", "rp": "40" },
          "OUT_OF_STATE": { "wp": "0", "rp": "0" }
        },
        "CHALAI": {
          "KERALA": { "wp": "40", "rp": "45" },
          "OUT_OF_STATE": { "wp": "0", "rp": "0" }
        }
      },
      "lastUpdated": "September 29, 2025"
    }
  },
  "date": "September 29, 2025"
}

Explanation of Terms


⚙️ API

Base Path: /api

1. List Markets

GET /veg/markets

Response:

{
  "data": [
    { "title": "Aluva", "id": "123" },
    { "title": "Chalai", "id": "456" }
  ],
  "date": "September 29, 2025",
  "message": "Markets listed successfully"
}

2. List Items (Vegetables & Fruits)

GET /veg/items

Response:

{
  "data": [
    { "title": "Amaranthus Green", "id": "101" },
    { "title": "Ash Gourd", "id": "102" }
  ],
  "date": "September 29, 2025",
  "message": "Vegetables and Fruits listed successfully"
}

3. Get Prices of a Specific Item

GET /items/:name?place=<marketName>

Example:

GET /items/Amaranthus Green?place=ALUVA

Response:

{
  "data": {
    "ALUVA": {
      "KERALA": { "wp": "30", "rp": "40" },
      "OUT_OF_STATE": { "wp": "0", "rp": "0" }
    }
  },
  "date": "September 29, 2025",
  "name": "Amaranthus Green",
  "message": "Item details fetched successfully"
}

Notes:


Workflow

  1. Scraper fetches market and item lists from VFPCK website.

  2. Data is saved into:

    • items.json → List of vegetables & fruits.
    • markets.json → List of Kerala markets.
    • live.json → Daily updated prices.
    • historic_data/<item>.json → Daily historical prices for each item.
  3. API serves the data via Express.js routes.


Project Structure

data/
 ├── items.json             # List of all items
 ├── markets.json           # List of Kerala markets
 ├── live.json              # Latest prices
 └── historic_data/         # Historical price data for each item
src/
 ├── routes/                # Express API routes
 ├── utils/scraper.js       # Scraper logic
 ├── utils/data-fetcher.js  # Local JSON data fetcher
 ├── index.ts               # Server entrypoint
scripts/
 └── live.ts                # Daily price update and historic generation

Contributing


License

MIT License


Disclaimer

This project scrapes data from VFPCK. The data is provided as-is and may contain parsing errors. For official and verified information, refer to the original source.