Skip to main content

The most developer-friendly way to explore the Constitution of India

Project description

IndianConstitution

A concise, high-performance Python toolkit for the Constitution of India.

indianconstitution is the definitive open-source Python library for accessing, searching, analyzing, and integrating the Constitution of India into software, legal research, AI systems, educational tools, and civic technology. Built with a focus on developer experience, it provides a pythonic API, an elegant CLI, advanced search capabilities (including semantic search), and robust data export features.

Why use indianconstitution?

  • Intuitive API: Chainable, type-hinted access to Articles, Parts, Schedules, and the Preamble.
  • High Performance: Uses an inverted index for sub-millisecond keyword searches.
  • AI & Data Science Ready: Native semantic search integration and seamless pandas DataFrame export.
  • Professional CLI: A beautiful, terminal-native experience powered by Typer and Rich.
  • Fully Offline: No API keys, no rate limits, and 100% local operation.

Project Status

Metric Status
PyPI PyPI - Version PyPI Downloads Monthly Downloads
Environment Python Versions License
Quality CI Codacy Typing Ruff
Security CodeQL OpenSSF Scorecard
Support Donate via UPI

Features Matrix

Capability Supported
Articles, Parts & Schedules
Preamble Access
CLI Interface
Fast Keyword Search
Semantic Search (AI)
CSV & JSON Export
Pandas Integration
Full Type Hints
Local Disk Caching

Visual Previews

CLI Preview

CLI Preview A look at the interactive terminal interface.

Python Example

Python Example Pythonic API usage with type hints.

Keyword Search

Search Example Blazing-fast inverted index search.

Semantic Search

Semantic Search Context-aware search for legal concepts without exact keyword matches.


Quick Start

Installation

# Standard installation
pip install indianconstitution

# With Data Science capabilities (pandas)
pip install "indianconstitution[data]"

# With AI/Semantic Search capabilities
pip install "indianconstitution[ai]"

Basic Usage

from indianconstitution import get_constitution, get_article

# Load the entire constitution
ic = get_constitution()
print(f"Preamble: {ic.preamble}")

# Get a specific article
article_21a = get_article("21A")
print(f"Article {article_21a.number}: {article_21a.title}")
print(article_21a.content)

Searching

from indianconstitution import search

# Fast keyword search
results = search("freedom of speech")
for article in results:
    print(f"Article {article.number}: {article.title}")

Semantic Search (AI)

from indianconstitution import Constitution

ic = Constitution()
# Find articles conceptually related to "protection of children"
results = ic.semantic_search("safeguarding minors and young people")
for article in results:
    print(f"Article {article.number}: {article.title}")

Exporting Data

from indianconstitution import get_constitution

ic = get_constitution()
ic.export(format="json", path="constitution.json")
ic.export(format="csv", path="constitution.csv")

Command Line Interface

# View an article
indianconstitution get 14

# Search the text
indianconstitution search "equality"

# View the preamble
indianconstitution preamble

# Show dataset statistics
indianconstitution stats

Real-world Use Cases

  • Legal Research: Quickly retrieve interrelated articles and build graphs of references.
  • Constitutional Law: Compare semantic nuances and analyze terminology distribution.
  • Universities & Education: Integrate interactive CLI tools into political science curriculums.
  • AI Agents & LLMs: Provide a clean, structured corpus for grounding agentic applications.
  • RAG (Retrieval-Augmented Generation): High-quality indexed embeddings for custom legal chatbots.
  • Civic Tech: Build open-source dashboards and apps for citizen awareness.
  • Data Analysis: Export directly to Pandas and NetworkX to study structural complexity.

Documentation

Full documentation is available at https://vikhram-s.github.io/IndianConstitution/.


Citation

If you use this software in your research or project, please cite it using the accompanying CITATION.cff file.

APA Format:

S, V. (2026). IndianConstitution (Version 1.2.0) [Computer software]. https://github.com/Vikhram-S/IndianConstitution


Contributing

We welcome contributions! Please see CONTRIBUTING.md for details on setting up your environment, running tests, and submitting PRs.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Copyright

Copyright (c) 2026 Vikhram S. All rights reserved.


Support the Project

If this project provides value to you or your organization, consider supporting its continued development and maintenance.

Support helps fund:

  • ongoing package maintenance and improvements
  • new features, datasets, and documentation
  • infrastructure, testing, and release automation
  • long-term open-source sustainability

Support via UPI (Unified Payments Interface)

UPI ID: vikhrams15@okhdfcbank

Support via UPI

Contributions, feature requests, issue reports, documentation improvements, and GitHub stars are also appreciated.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

indianconstitution-1.2.0.tar.gz (238.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

indianconstitution-1.2.0-py3-none-any.whl (231.7 kB view details)

Uploaded Python 3

File details

Details for the file indianconstitution-1.2.0.tar.gz.

File metadata

  • Download URL: indianconstitution-1.2.0.tar.gz
  • Upload date:
  • Size: 238.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for indianconstitution-1.2.0.tar.gz
Algorithm Hash digest
SHA256 e48434b72af233bd93087d3ba73af4d1cc2dc3f867bac0bda0530b581fc57ca4
MD5 a8c18fa56ebc4e4207993710c25c9e28
BLAKE2b-256 422d1fbd8c5531c290a49b93ea81c281b8711f533d0f9388397c3d87c779a87b

See more details on using hashes here.

File details

Details for the file indianconstitution-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for indianconstitution-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af6f0098f62eec216f905dc7e734c903f4622b11a681b5edcb03f78fc4a8aef4
MD5 b15ad6498191aa1c36e1da73f2f58eaa
BLAKE2b-256 7709e89d03b2b7f9fa1d47e1e73b02b6b5ba92105f9719abb4bf63f2acd06cec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page