DEV Community

Cover image for Introducing GitaVerse: Access Bhagavad Gita Verses Programmatically ๐Ÿš€
Ravi Kishan
Ravi Kishan

Posted on

Introducing GitaVerse: Access Bhagavad Gita Verses Programmatically ๐Ÿš€

In the world of modern development, spiritual and literary texts can be made more accessible to developers through clean APIs and libraries. GitaVerse is a modern TypeScript library that enables you to access, explore, and retrieve shlokas (verses) from the Bhagavad Gita with ease.


๐ŸŒŸ What is GitaVerse?

GitaVerse is a TypeScript-based NPM library that allows developers to programmatically fetch the Bhagavad Gita's verses (shlokas), including translations, synonyms, and original Devanagari text.

The Bhagavad Gita is a profound Hindu scripture consisting of 700 verses across 18 chapters. With GitaVerse, you can:

  • Retrieve individual verses based on Chapter and Verse number.
  • Fetch all shlokas in a specific chapter.
  • Access translations, synonyms, and meanings in a structured format.
  • Build spiritual apps, educational tools, or study tools effortlessly.

๐Ÿš€ Features of GitaVerse

  • โœ… Fetch Any Shloka: Get verses from any chapter with full details.
  • โœ… Detailed Information: Includes Devanagari text, verse translations, synonyms, and multiple meanings.
  • โœ… Organized Data: All data is structured and typed with TypeScript interfaces for ease of use.
  • โœ… Easy-to-Use API: Clean class-based methods for developers.
  • โœ… Lightweight: Minimal dependencies for faster integration.
  • โœ… TypeScript Support: Full type safety for robust development.

๐Ÿ“ฅ Installation

You can install GitaVerse using npm or yarn:

npm install gitaverse
Enter fullscreen mode Exit fullscreen mode

or

yarn add gitaverse
Enter fullscreen mode Exit fullscreen mode

๐Ÿ”ง How to Use GitaVerse

Hereโ€™s a quick guide on how you can use the GitaVerse library.

1. Import GitaVerse and Initialize

Start by importing the GitaLibrary class and initializing it:

import { GitaLibrary } from "gitaverse";

const gita = new GitaLibrary();
Enter fullscreen mode Exit fullscreen mode

2. Fetch Metadata About the Bhagavad Gita

Get an overview of the Bhagavad Gita, such as the total chapters and verses:

const metadata = gita.getDescription();
console.log(metadata);

/*
Output:
{
  title: "Bhagavad Gita",
  description: "The Bhagavad Gita, often referred to as the Gita, is a 700-verse Hindu scripture that is part of the Indian epic Mahabharata.",
  totalChapters: 18,
  totalVerses: 700
}
*/
Enter fullscreen mode Exit fullscreen mode

3. Fetch All Shlokas in a Chapter

To retrieve all the verses from a specific chapter, use getChapter():

const chapter1Shlokas = gita.getChapter(1);

chapter1Shlokas.forEach((shloka) => {
  console.log(shloka.getSummary());
});
Enter fullscreen mode Exit fullscreen mode

4. Fetch a Specific Shloka

Fetch a specific shloka using chapter number and verse number:

const shloka = gita.getShloka(1, 1);

console.log(shloka.getSummary());

/*
Output:
{
  chapter: "1",
  verse: "1",
  devanagari: "เคงเฅƒเคคเคฐเคพเคทเฅเคŸเฅเคฐ เค‰เคตเคพเคš...",
  verseText: "Dhritarashtra said...",
  synonyms: "Dhritarashtra - King Dhritarashtra...",
  translation: "King Dhritarashtra inquired...",
  meaning: ["Literal meaning of the verse...", "Spiritual significance..."]
}
*/
Enter fullscreen mode Exit fullscreen mode

5. Fetch All Shlokas Grouped by Chapters

If you want to get all verses organized by chapters, use getAllVerses():

const allVerses = gita.getAllVerses();

allVerses.forEach((chapter) => {
  console.log(
    `Chapter ${chapter.getShlokas().length} Shlokas available`
  );
});
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“š API Methods Overview

Hereโ€™s a quick overview of the available methods:

GitaLibrary Methods:

Method Description
getDescription() Get metadata about the Gita.
getChapter(chapter) Fetch all shlokas in a specific chapter.
getShloka(chapter, verse) Retrieve a specific shloka by chapter & verse.
getAllVerses() Fetch all shlokas grouped by chapters.

GitaShloka Methods:

Method Description
getSummary() Retrieve a summary of the shloka details.
getDevanagari() Get the Devanagari text of the verse.
getTranslation() Get the verse translation.
getMeaning() Get multiple meanings of the verse.

๐Ÿ›  Use Cases

Here are a few ideas for integrating GitaVerse into your projects:

  1. Spiritual Apps: Build apps to display Gita shlokas with translations and explanations.
  2. Study Tools: Develop tools for students to explore and understand the Bhagavad Gita.
  3. APIs: Serve Gita data through REST APIs for web or mobile apps.
  4. Personal Projects: Use it for personal study and exploration of the Gita.

๐ŸŒ Links


๐Ÿค Contributing

We welcome contributions! If you'd like to add features or fix issues:

  1. Fork the repository from GitHub.
  2. Create a feature branch.
  3. Submit a pull request.

For any suggestions or bugs, feel free to raise an issue.


๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for more details.


โœจ Final Thoughts

With GitaVerse, exploring the timeless wisdom of the Bhagavad Gita becomes simple and developer-friendly. Whether you're building spiritual apps, study tools, or personal projects, GitaVerse provides everything you need to programmatically access and share the Gita's teachings.

"You have the right to work, but never to the fruit of work."

โ€” Bhagavad Gita (Chapter 2, Verse 47)


Start Exploring the Gita Today with GitaVerse! ๐ŸŒŸ

Install Now

Image of Timescale

๐Ÿš€ pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applicationsโ€”without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Image of Docusign

๐Ÿ› ๏ธ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more