SDK Examples
Madeenan works with plain HTTP. Start with fetch or requests, then wrap it in your app's own client.
Chat with Node.js
const response = await fetch("https://api.madeenan.com/v1/chat", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Madeenan-API-Key": process.env.MADEENAN_API_KEY
},
body: JSON.stringify({
message: "Explain Ayat al-Kursi with sources"
})
});
const data = await response.json();
console.log(data.answer);
console.log(data.citations);
Search with Node.js
const params = new URLSearchParams({
q: "actions are by intentions",
indexes: "quran,hadith",
limit_per_source: "5"
});
const response = await fetch(`https://api.madeenan.com/v1/search?${params}`, {
headers: {
"X-Madeenan-API-Key": process.env.MADEENAN_API_KEY
}
});
const data = await response.json();
console.log(data.results.hadith);
console.log(data.results.quran);
Chat with Python
import os
import requests
response = requests.post(
"https://api.madeenan.com/v1/chat",
headers={
"X-Madeenan-API-Key": os.environ["MADEENAN_API_KEY"],
"Content-Type": "application/json",
},
json={
"message": "Explain the Dua of Yunus with sources",
},
)
data = response.json()
print(data["answer"])
print(data["citations"])
Common Mistakes
- Hardcoding keys in source files.
- Calling Madeenan directly from the browser.
- Rendering answers without citations and attribution.
Security note
Store Madeenan API keys in server-side environment variables. If your production app calls an LLM provider, keep that model key in your own backend too.