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

Top comments (0)