All API requests require the appropriate headers:
const axios = require('axios');
const config = {
method: 'GET',
url: 'https://hadith-api.onrender.com/api/v1/hadith/en-sahihbukhari/1',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
}
};
axios(config)
.then(response => console.log(JSON.stringify(response.data)))
.catch(error => console.log(error));
"text-[#569CD6]">const axios = "text-[#569CD6]">require('axios');
"text-[#569CD6]">const config = {
method: 'get',
url: 'https://hadith-api.onrender.com/api/v1/hadith/eng-bukhari/1',
headers: {
'Content-Type': 'application/json'
}
};
axios(config)
."text-[#DCDCAA]">then(response => "text-[#4EC9B0]">console."text-[#DCDCAA]">log(JSON."text-[#DCDCAA]">stringify(response.data)))
."text-[#DCDCAA]">catch(error => "text-[#4EC9B0]">console."text-[#DCDCAA]">log(error));
Headers: Content-Type: application/json
Example Request: GET /api/v1/hadith/eng-bukhari/1
{
"id": 1,
"text": "Hadith text here",
"edition": "eng-bukhari"
}
Headers: Content-Type: application/json
Example Request: GET /api/v1/hadith/editions
[
{
"language": "eng",
"name": "bukhari",
"id": "eng-bukhari"
},
{
"language": "ara",
"name": "muslim",
"id": "ara-muslim"
}
]
Headers: Content-Type: application/json
Example Request: GET /api/v1/hadith/eng-bukhari/sections/1
{
"section": 1,
"title": "Section Title",
"hadiths": [
{
"id": 1,
"text": "Hadith text here"
},
{
"id": 2,
"text": "Another Hadith text here"
}
]
}
Headers: Content-Type: application/json
Example Request: GET /api/v1/hadith/info
{
"version": "1.0",
"description": "Hadith API Information",
"source": "https://cdn.jsdelivr.net/gh/fawazahmed0/hadith-api"
}
Headers: Content-Type: application/json
Query Parameters: ?bookName={bookName}
Example Request: GET /api/v1/hadith/random?bookName=bukhari
{
"id": 1,
"text": "Random Hadith text here",
"book": "bukhari"
}