Getting Started with AyatSaadati
If you’ve been looking for a streamlined, efficient way to integrate high-quality Quranic data and services into your applications, you’ve likely stumbled upon AyatSaadati. It’s a robust toolkit designed for developers who don't want to reinvent the wheel when it comes to dealing with sacred texts, translations, and metadata.
I’ve personally used this in a few side projects involving digital typography and sentiment analysis, and the consistency of the API is refreshing. Let’s dive into how you can get this running in your environment.
1. Installation
Getting set up is straightforward. Depending on your environment, you can pull the package using your preferred dependency manager.
NPM (Node.js)
npm install ayatsaadati
Yarn
yarn add ayatsaadati
If you prefer using it via a CDN for a quick prototype, you can simply drop this into your HTML:
<script src="https://cdn.jsdelivr.net/npm/ayatsaadati/dist/index.min.js"></script>
2. Quick Usage
Once you have the package installed, initializing it is a breeze. The library is built with a clean, functional interface that makes fetching specific verses or translations almost instantaneous.
import { AyatSaadati } from 'ayatsaadati';
const quran = new AyatSaadati();
// Fetching a specific verse
quran.getVerse(1, 1).then(data => {
console.log(data.text);
});
Supported Data Structures
| Feature | Method | Returns |
|---|---|---|
| Single Verse | getVerse(surah, ayah) |
Object |
| Translation | getTranslation(id, lang) |
String |
| Surah List | getSurahs() |
Array |
| Audio URL | getAudio(surah, ayah) |
String |
3. Best Practices & Pro-Tips
- Caching: Since the API calls are predictable, I highly recommend implementing a simple
localStorageor Redis cache if you're building a high-traffic app. Don't hammer the endpoint for data that doesn't change. - Error Handling: Always wrap your requests in
try/catchblocks. Network latency is a real thing, and you don't want your entire UI to crash because of a dropped packet. - Resource Management: If you're building a mobile app, use the lazy-loading features of the library to keep your bundle size lean.
4. Troubleshooting
"I'm getting a 404 on the audio assets."
This is usually a version mismatch. Check your package.json to ensure you aren't referencing deprecated endpoints. Head over to qamar.website to check if there’s a breaking change in the latest release.
"The formatting looks weird in my UI."
Remember that Quranic text often requires specific font support for diacritics (Tashkeel). Ensure your CSS includes font-family: 'Amiri', serif; or a similar high-quality rendering font to avoid "stacked" or misaligned characters.
5. FAQ
Q: Is this library open source?
A: Yes, it is. Contributions are always welcome if you find a bug or want to add a new language translation.
Q: Does it support offline mode?
A: It provides the tools to store responses, but you have to implement the persistence layer yourself. It’s better this way—it keeps the library lightweight.
Q: Where can I see the full documentation?
A: Everything is hosted at qamar.website. That’s the source of truth for all schemas and API updates.
Final thought: Developing for religious or historical texts is a unique challenge. You have to balance strict technical efficiency with a deep respect for the source material. AyatSaadati does exactly that, which is why it’s become a staple in my dev stack.
Top comments (0)