The "Islam Companion Web API" project is a RESTFul API (Application Programming Interface) that allows users to add Holy Quran and Hadith data to their applications. It provides Holy Quran translation in 42 languages. Following languages are supported: Amharic, Arabic, Bosnian, Bengali, Bulgarian, Amazigh, Czech, German, Divehi, Spanish, English, Persian, French, Hindi, Hausa, Indonesian, Italian, Japanese, Korean, Kurdish, Malayalam, Malay, Dutch, Norwegian, Portuguese, Polish, Russian, Romanian, Swedish, Somali, Sindhi, Albanian, Swahili, Turkish, Tajik, Tamil, Tatar, Thai, Uzbek, Urdu, Uyghur and Chinese. Hadith translation is provided in Urdu, English and Arabic languages
The goal of the Islam Companion Web API is to help users developed applications that promote knowledge about Islam.
The Islam Companion Web API has the following features:
- It provides translations of Holy Quran in 42 languages
- It provides translations of Hadith in Urdu, English and Arabic languages
- It provides 8 API functions for fetching Quranic data
- It provides 7 API functions for fetching Hadith data
- The source code is available under GPL License
- The source code is well commented and easy to update
The Islam Companion Web API requires Php >= 7.2. It also requires MySQL server >= 5.6.
The following steps can be used to install the "Islam Companion Web API" project on your own server:
- Download the source code from GitHub
- Move the source code to the document root of a virtual host
- Download the contents of the database from: here
- Extract the downloaded file
- Create a database and import the contents of the sql file to the database. Note down the credentials used for connecting to the database
- Enter the database credentials in the file api/config/RequiredObjects.php
- In the file: api/Config.php, on line 37 enter the domain names that will be used to access the api
- Customize the following variables in the file: api/config/General.php. $config['app_name'], $config['dev_mode'] and $config['site_url']
Click here to download the Hadith database in .sql format for MySQL server. Click here to download the Hadith database in .db format for SQLite3
Click here to download the Quranic database in .db format for SQLite3
- What is the Islam Companion Web API. It is a RESTFul API for accessing Holy Quran and Hadith data
- What can I do with the Islam Companion Web API. You can develop web based applications that present Holy Quran and Hadith data to the user. The Islam Companion Api can work as the backend of your application.
- Which languages are supported by the Islam Companion Web API. Click Here
- What functions are provided by the Islam Companion Api. Please read the documentation.
- From where does the API get its data. The Islam Companion API uses Holy Quran translations from http://tanzil.net/trans/. It uses Hadith data from http://hadithcollection.com/ and https://www.quranurdu.com/Ahadith/.
- How do I use the API. To use the API, you have to make HTTP POST request to your web server. Please see following sample code in Php language.
<?php
$data = array(
'language' => 'English',
'narrator' => 'Mohammed Marmaduke William Pickthall'
);
// Prepare new cURL resource
$ch = curl_init('[your-website-name]/api/get_random_verses');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Submit the POST request
$result = curl_exec($ch);
// Close cURL session handle
curl_close($ch);
// json decode the response
$result = json_decode($result, true);
// Print the result
print_r($result);
?>
The Islam Companion Web API supports the following functions. All function response values are in JSON format.
To test the API, use the following url: [your-server]/api/ for making API requests. All API requests must be of type HTTP POST and should include the required API parameters.
Name | Description | Url | Parameters | Response |
---|---|---|---|---|
Get Suras In Division | Returns the list of suras for the given division and division number | /api/get_suras_in_division |
|
The names of all the suras that are in the given division:
|
Get Ruku List | It provides the start and end ruku numbers for the given division, division number and sura | /api/get_ruku_list |
|
The start and end ruku numbers
|
Get Verses | It returns the arabic text and translation for the given verses | /api/get_verses |
|
The list of required ayas
|
Get Random Verses | It returns the text for a random ruku along with meta data | /api/get_random_verses |
|
The verse data
|
Get Holy Quran Navigator Configuration | It generates the navigator configuration data for the given action | /api/get_quran_nav_config |
|
The updated Navigator configuration data
|
Get Languages | It returns the list of all supported languages | /api/get_languages | None | The list of all supported languages |
Get Narrators | It returns the list of all supported narrators for the given language | /api/get_narrators |
|
The list of all supported narrators |
Search Ayat | It returns list of ayas that contain the given text | /api/search_ayat |
|
Contains the search results and total result count
|
Name | Description | Url | Parameters | Response | |
---|---|---|---|---|---|
Get Hadith Books | It returns the list of Hadith books for the given Hadith source | /api/get_hadith_books |
|
The list of Hadith books
|
|
Get Hadith Titles | It fetches list of Hadith book titles for the given Hadith book and source | /api/get_hadith_titles |
|
The list of hadith book titles
|
|
Get Hadith | It fetches list of Hadith text for the given Hadith title and book id | /api/get_hadith |
|
The list of Hadith
|
|
Get Random Hadith | It fetches list of random hadith text | /api/get_random_hadith |
|
The hadith text
| |
Get Hadith Sources | It fetches list of hadith sources for the given language | /api/get_hadith_sources |
|
The list of hadith sources
|
|
Get Hadith Navigator Configuration | It returns the navigator configuration for given navigator action | /api/get_hadith_nav_config |
|
The updated Navigator configuration data
|
|
Search Hadith | It returns list of hadith that contain the given text | /api/search_hadith |
|
Contains the search results and total result count
|