<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Yash Ingawale</title>
    <description>The latest articles on Forem by Yash Ingawale (@yash_json).</description>
    <link>https://forem.com/yash_json</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3533607%2Fc4da8008-5c64-4276-b94a-ef0013e0b6b3.jpg</url>
      <title>Forem: Yash Ingawale</title>
      <link>https://forem.com/yash_json</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/yash_json"/>
    <language>en</language>
    <item>
      <title>How to Build a Simple 'Indian Festival API' with Python and a JSON Dataset</title>
      <dc:creator>Yash Ingawale</dc:creator>
      <pubDate>Sat, 27 Sep 2025 14:11:34 +0000</pubDate>
      <link>https://forem.com/yash_json/how-to-build-a-simple-indian-festival-api-with-python-and-a-json-dataset-11de</link>
      <guid>https://forem.com/yash_json/how-to-build-a-simple-indian-festival-api-with-python-and-a-json-dataset-11de</guid>
      <description>&lt;p&gt;Introduction&lt;/p&gt;

&lt;p&gt;As a developer working with the Indian market, I often need to plan features or campaigns around our incredibly diverse festival calendar. I recently needed a simple way to query festivals by region and date, but I was surprised by the lack of good options. Most free datasets were outdated or incomplete, and the big commercial APIs were expensive subscription services.&lt;/p&gt;

&lt;p&gt;So, I decided to build my own solution.&lt;/p&gt;

&lt;p&gt;In this tutorial, I'll walk you through the simple, practical approach I took to create a queryable festival calendar using a JSON dataset and a bit of Python with the pandas library.&lt;/p&gt;

&lt;p&gt;What We'll Build&lt;br&gt;
We'll write a simple Python script that can:&lt;/p&gt;

&lt;p&gt;Load a list of festivals from a local JSON file.&lt;/p&gt;

&lt;p&gt;Filter those festivals based on a specific region (e.g., "Kerala").&lt;/p&gt;

&lt;p&gt;Print the results.&lt;/p&gt;

&lt;p&gt;Prerequisites&lt;br&gt;
All you'll need is Python 3.8+ and the pandas library. You can install pandas by running:&lt;/p&gt;

&lt;p&gt;Bash&lt;/p&gt;

&lt;p&gt;pip install pandas&lt;br&gt;
Step 1: The Data (Our JSON Snippet)&lt;br&gt;
First, we need some data. For this tutorial, we'll use a small sample. Create a file named my_festivals.json and paste this into it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  {
    "festival": "Holi",
    "date": "2025-03-14",
    "region": ["All India"],
    "is_holiday": true,
    "category": "Hindu",
    "notes": "Festival of colors; 15% retail spike (Amazon India 2024)."
  },
  {
    "festival": "Vishu",
    "date": "2025-04-14",
    "region": ["Kerala"],
    "is_holiday": true,
    "category": "Cultural",
    "notes": "Kerala New Year; gold, apparel e-commerce spikes."
  },
  {
    "festival": "Onam",
    "date": "2025-08-25",
    "region": ["Kerala"],
    "is_holiday": true,
    "category": "Cultural",
    "notes": "Harvest festival; regional retail, hospitality surge."
  },
  {
    "festival": "Diwali",
    "date": "2025-10-21",
    "region": ["All India"],
    "is_holiday": true,
    "category": "Hindu",
    "notes": "Festival of lights; 20% e-commerce surge."
  },
  {
    "festival": "Durga Puja",
    "date": "2025-09-28",
    "region": ["West Bengal", "Assam", "Odisha"],
    "is_holiday": true,
    "category": "Hindu",
    "notes": "Goddess worship; 15% apparel sales boost."
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 2: The Python Script&lt;br&gt;
Now, let's write the Python code. Create a file named run_query.py in the same folder. This script is a simplified version of the one in my full toolkit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json
import pandas as pd

def load_festivals(file_path='my_festivals.json'):
    """Loads festival data from a JSON file."""
    try:
        with open(file_path, 'r') as f:
            return json.load(f)
    except FileNotFoundError:
        print(f"Error: The file {file_path} was not found.")
        return []

def query_festivals_by_region(region_name):
    """Filters festivals for a specific region."""
    all_festivals = load_festivals()
    if not all_festivals:
        return

    df = pd.DataFrame(all_festivals)

    # Filter the DataFrame
    # The 'apply' method checks if the region_name is in the list of regions for each festival
    regional_festivals = df[df['region'].apply(lambda regions: region_name in regions)]

    print(f"--- Festivals in {region_name} ---")
    # Convert the filtered DataFrame to a nicely formatted JSON string for printing
    print(regional_festivals.to_json(orient='records', indent=2))

# --- Main execution block ---
if __name__ == "__main__":
    # Let's find all festivals celebrated in Kerala from our sample data
    query_festivals_by_region("Kerala")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: Running the Script and Seeing the Result&lt;br&gt;
Now, run the script from your terminal:&lt;/p&gt;

&lt;p&gt;Bash&lt;/p&gt;

&lt;p&gt;python run_query.py&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;--- Festivals in Kerala ---
[
  {
    "festival":"Vishu",
    "date":"2025-04-14",
    "region":["Kerala"],
    "is_holiday":true,
    "category":"Cultural",
    "notes":"Kerala New Year; gold, apparel e-commerce spikes."
  },
  {
    "festival":"Onam",
    "date":"2025-08-25",
    "region":["Kerala"],
    "is_holiday":true,
    "category":"Cultural",
    "notes":"Harvest festival; regional retail, hospitality surge."
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Success! We've just built a basic, functioning query tool for our festival data.&lt;/p&gt;

&lt;p&gt;The Shortcut: The Complete Toolkit&lt;br&gt;
This tutorial gives you the basic framework to build your own tool.&lt;/p&gt;

&lt;p&gt;However, if you want to save yourself the 20+ hours it takes to collect, clean, and verify the data for all 100+ festivals, I've made the complete toolkit available on Gumroad.&lt;/p&gt;

&lt;p&gt;The full version includes:&lt;/p&gt;

&lt;p&gt;The complete dataset for 2025-26 with 100+ festivals.&lt;/p&gt;

&lt;p&gt;Actionable e-commerce and business notes for every major festival .&lt;/p&gt;

&lt;p&gt;The full Python script with advanced filtering (by date range) and CSV export functionality.&lt;/p&gt;

&lt;p&gt;You can grab the full toolkit here: [ &lt;a href="https://yashingawale.gumroad.com/l/indianfestivalapi/LAUNCH40" rel="noopener noreferrer"&gt;https://yashingawale.gumroad.com/l/indianfestivalapi/LAUNCH40&lt;/a&gt; ]&lt;/p&gt;

&lt;p&gt;Thanks for reading, and happy coding!&lt;/p&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>india</category>
      <category>api</category>
    </item>
  </channel>
</rss>
