SDKs overview
The GurbaniNow platform provides programmatic access to Sikh scriptures, including the Sri Guru Granth Sahib, via its Gurbani API. To simplify integration for developers, GurbaniNow offers an official Software Development Kit (SDK) specifically for JavaScript environments. This SDK abstracts the complexities of direct HTTP requests, authentication, and data parsing, allowing developers to focus on building applications that utilize Gurbani content. The SDK is designed to streamline common API interactions, such as retrieving shabads (hymns), angs (pages), and pangtis (lines of text), along with their associated translations and transliterations.
SDKs are essential tools for developers as they provide pre-built components and functions that interact with an API, reducing the need to write boilerplate code. This approach enhances developer productivity and helps maintain consistency in how the API is consumed across different applications. For example, instead of manually constructing a RESTful API call to fetch a specific shabad, a developer can use a method provided by the GurbaniNow JavaScript SDK, such as getShabadById(), which handles the underlying network request and data deserialization. This promotes efficient development practices and allows for quicker deployment of applications that integrate Gurbani content.
Official SDKs by language
GurbaniNow officially supports a JavaScript SDK, which is the primary method recommended for integrating the Gurbani API into web and Node.js applications. This SDK is maintained by the GurbaniNow team and is designed to provide a robust and up-to-date interface to the API's functionalities. The SDK is available through standard package managers, ensuring easy installation and dependency management.
The official JavaScript SDK encapsulates various API endpoints, providing methods for accessing different types of Gurbani content. This includes functions for searching scriptures, retrieving specific shabads by ID, accessing angs, and obtaining pangtis. The SDK also handles API key management and request formatting, simplifying the development process for integrating religious texts into digital platforms. Developers can refer to the GurbaniNow API documentation for detailed usage instructions and available methods within the SDK.
Official SDKs
| Language | Package Name | Install Command | Maturity |
|---|---|---|---|
| JavaScript | @gurbaninow/api-client |
npm install @gurbaninow/api-client |
Stable |
Installation
The GurbaniNow JavaScript SDK can be installed using npm (Node Package Manager) or Yarn, which are common package managers for JavaScript development. Before installation, ensure you have Node.js and npm (or Yarn) installed on your system. You can check your Node.js installation by running node -v in your terminal. For information on installing Node.js, refer to the official npm documentation.
Prerequisites
- Node.js (LTS version recommended)
- npm or Yarn
- A GurbaniNow API key (obtained from the GurbaniNow website)
Installation with npm
To install the GurbaniNow API client using npm, navigate to your project directory in the terminal and execute the following command:
npm install @gurbaninow/api-client
Installation with Yarn
If you prefer using Yarn, execute the following command in your project directory:
yarn add @gurbaninow/api-client
After successful installation, the SDK will be available for import and use within your JavaScript or TypeScript projects.
Quickstart example
This quickstart guide demonstrates how to initialize the GurbaniNow JavaScript SDK and fetch a shabad by its ID. Ensure you have installed the @gurbaninow/api-client package as described in the Installation section and have a valid GurbaniNow API key.
Step 1: Obtain your API key
Register on the GurbaniNow platform and obtain your API key. This key is necessary for authenticating your requests to the GurbaniNow API. The GurbaniNow API documentation provides details on API key management.
Step 2: Initialize the SDK
Import the GurbaniNowClient and initialize it with your API key. It is recommended to store your API key securely, for example, using environment variables, rather than hardcoding it directly in your application's source code, especially in production environments. For best practices on securing API keys, consult resources like Google Cloud's API key security guidelines.
import { GurbaniNowClient } from '@gurbaninow/api-client';
// Replace 'YOUR_API_KEY' with your actual GurbaniNow API key.
// For production, consider using environment variables (e.g., process.env.GURBANINOW_API_KEY)
const apiKey = 'YOUR_API_KEY';
const client = new GurbaniNowClient(apiKey);
async function fetchShabadExample() {
try {
// Example: Fetch Shabad with ID 1
const shabadId = 1;
const shabad = await client.getShabadById(shabadId);
if (shabad) {
console.log(`Shabad Title: ${shabad.title.english}`);
console.log('Pangtis:');
shabad.pangtis.forEach(pangti => {
console.log(` ${pangti.gurmukhi.unicode} - ${pangti.translation.english}`);
});
} else {
console.log(`Shabad with ID ${shabadId} not found.`);
}
} catch (error) {
console.error('Error fetching shabad:', error.message);
}
}
fetchShabadExample();
Explanation of the quickstart code
import { GurbaniNowClient } from '@gurbaninow/api-client';: This line imports the necessary client class from the installed SDK package.const apiKey = 'YOUR_API_KEY';: You must replace'YOUR_API_KEY'with your actual API key obtained from GurbaniNow.const client = new GurbaniNowClient(apiKey);: An instance of the GurbaniNow client is created, initializing it with your API key. This client instance is then used to make API calls.await client.getShabadById(shabadId);: This asynchronous call uses the client instance to fetch a shabad by its unique identifier. Theawaitkeyword pauses execution until the API call returns a response.- Error Handling: The
try...catchblock is used to gracefully handle any errors that might occur during the API request, such as network issues or invalid API keys. - Output: If the shabad is successfully retrieved, its English title and each pangti (line) with its Gurmukhi and English translation are logged to the console.
This example provides a foundational understanding of how to use the GurbaniNow JavaScript SDK. For more advanced features and different API endpoints, refer to the comprehensive GurbaniNow API documentation.
Community libraries
While GurbaniNow provides an official JavaScript SDK, the open-source community may develop and maintain additional libraries or wrappers in various programming languages. These community-contributed libraries often extend functionality, provide integrations with specific frameworks, or offer alternative interfaces based on developer preferences. Community libraries are not officially supported or maintained by GurbaniNow, and their quality, documentation, and ongoing support can vary.
As of the current information, the primary recommended method for integrating with the GurbaniNow API is through its official JavaScript SDK. Developers interested in contributing to or finding community-developed tools are encouraged to search public code repositories like GitHub or explore developer forums related to GurbaniNow. When using community libraries, it is advisable to review their source code, check for active maintenance, and understand their licensing terms. The GurbaniNow team focuses on maintaining the official API and its core JavaScript SDK to ensure stability and compatibility.