Getting All with One Request [Recommended]

Fetchs the quran data, quran list, recitor list, language list, user country, user country language list and user country default language. This method we use on GlobalQuran.com 3.0.

Use this method only on first time call, on next call use quran data for pages, surah, juz or ayah only.

Url: http://api.globalquran.com/all/getBy/getByNumber/quranID/langCode?key=api_key

attribute Value Description
getBy page, ayah, surah or juz how do you want your data to be fetch.
getByNumber page number, surah number, juz number or surah:ayah number Identify number for the getBy attribute
quranID quran id (optional) list of quran id seperated by | (pipe)
langCode language code (optional) define what language pack do you want to fetch for your user
key api key your site / app api key here


Url Examples By:



JSON Response: http://api.globalquran.com/all/page/604/quran-simple?key=api_key

{
    "languageCountryList": {
        "ur": {
            "country_english_name": "Pakistan",
            "country_native_name": "پاکستان"
        },
        "en": {
            "country_english_name": "Pakistan",
            "country_native_name": ""
        }
    },
    "languageList": {
        "el": {
            "english_name": "Greek",
            "native_name": "Ελληνικά",
            "dir": "",
            "is_pack": "1"
        },
        "ar": {
            "english_name": "Arabic",
            "native_name": "العربية",
            "dir": "right",
            "is_pack": "1"
        },
        "en": {
            "english_name": "English",
            "native_name": "",
            "dir": "left",
            "is_pack": "1"
        },
        "ur": {
            "english_name": "Urdu",
            "native_name": "اردو",
            "dir": "right",
            "is_pack": "1"
        },
       ....... json object was trimmed
    },
    "ur": "",
    "languageSelected": "ur",
    "quranList": {
        "quran-simple": {
            "language_code": "ar",
            "english_name": "simple",
            "native_name": "",
            "format": "text",
            "type": "quran",
            "source": "Tanzil.info",
            "default": null,
            "last_update": "2010-06-04"
        },
        "quran-uthmani": {
            "language_code": "ar",
            "english_name": "uthmani",
            "native_name": "",
            "format": "text",
            "type": "quran",
            "source": "Tanzil.info",
            "default": null,
            "last_update": "1969-12-31"
        },
        "bs.korkut": {
            "language_code": "ar",
            "english_name": "Korkut",
            "native_name": "Besim Korkut",
            "format": "text",
            "type": "translation",
            "source": "Tanzil.net",
            "default": null,
            "last_update": "1969-12-31"
        },
        "ar.jalalayn": {
            "language_code": "ar",
            "english_name": "Jalal ad-Din al-Mahalli and Jalal ad-Din as-Suyuti",
            "native_name": "تفسير الجلالين",
            "format": "text",
            "type": "tafsir",
            "source": "Tanzil.net",
            "default": null,
            "last_update": "1969-12-31"
        },
        "en.sahih": {
            "language_code": "en",
            "english_name": "Sahih International",
            "native_name": "",
            "format": "text",
            "type": "translation",
            "source": "Tanzil.info",
            "default": null,
            "last_update": "1969-12-31"
        },
        "en.pickthall": {
            "language_code": "en",
            "english_name": "Mohammed Marmaduke William Pickthall",
            "native_name": "",
            "format": "text",
            "type": "translation",
            "source": "Tanzil.info",
            "default": null,
            "last_update": "1969-12-31"
        },
        ....... json object was trimmed

    },
    "quran": {
        "quran-simple": {
            "6222": {
                "surah": 112,
                "ayah": 1,
                "verse": "بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ قُلْ هُوَ اللَّهُ أَحَدٌ"
            },
            "6223": {
                "surah": 112,
                "ayah": 2,
                "verse": "اللَّهُ الصَّمَدُ"
            },
            "6224": {
                "surah": 112,
                "ayah": 3,
                "verse": "لَمْ يَلِدْ وَلَمْ يُولَدْ"
            },
            "6225": {
                "surah": 112,
                "ayah": 4,
                "verse": "وَلَمْ يَكُنْ لَهُ كُفُوًا أَحَدٌ"
            },
            "6226": {
                "surah": 113,
                "ayah": 1,
                "verse": "بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ قُلْ أَعُوذُ بِرَبِّ الْفَلَقِ"
            },
            "6227": {
                "surah": 113,
                "ayah": 2,
                "verse": "مِنْ شَرِّ مَا خَلَقَ"
            },
            "6228": {
                "surah": 113,
                "ayah": 3,
                "verse": "وَمِنْ شَرِّ غَاسِقٍ إِذَا وَقَبَ"
            },
            "6229": {
                "surah": 113,
                "ayah": 4,
                "verse": "وَمِنْ شَرِّ النَّفَّاثَاتِ فِي الْعُقَدِ"
            },
            "6230": {
                "surah": 113,
                "ayah": 5,
                "verse": "وَمِنْ شَرِّ حَاسِدٍ إِذَا حَسَدَ"
            },
            "6231": {
                "surah": 114,
                "ayah": 1,
                "verse": "بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ قُلْ أَعُوذُ بِرَبِّ النَّاسِ"
            },
            "6232": {
                "surah": 114,
                "ayah": 2,
                "verse": "مَلِكِ النَّاسِ"
            },
            "6233": {
                "surah": 114,
                "ayah": 3,
                "verse": "إِلَٰهِ النَّاسِ"
            },
            "6234": {
                "surah": 114,
                "ayah": 4,
                "verse": "مِنْ شَرِّ الْوَسْوَاسِ الْخَنَّاسِ"
            },
            "6235": {
                "surah": 114,
                "ayah": 5,
                "verse": "الَّذِي يُوَسْوِسُ فِي صُدُورِ النَّاسِ"
            },
            "6236": {
                "surah": 114,
                "ayah": 6,
                "verse": "مِنَ الْجِنَّةِ وَالنَّاسِ"
            }
        }
    }
}



Examples:

Example: Loads the last quran page 604 with all the extra data list.

<!DOCTYPE html>
<html>
<head>
  <style>#demo-1{ color:lightBlue; }</style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <div id="demo-1">

</div>
<script>
$.ajaxSetup({ cache: true, jsonpCallback: 'quranData' }); // define ajax setup
$.getJSON("http://api.globalquran.com/all/page/604/quran-simple?key=api_key&jsoncallback=?", {
    format: "jsonp"
}, function(data) {
    
    /* user country */
    if (data.languageCountryList)
    {
        $.each(data.languageCountryList, function(langCode, lang)
        {
            $("<h4>").html('You are from: '+lang.country_english_name+' '+lang.country_native_name+' and your default language is '+data.languageList[data.languageSelected].english_name).appendTo("#demo-1");
	    return false;
	});
    }
	
    /* language list */
    $('#demo-1').append('Select Language: ');
    $("<select>").attr('id', 'langList').appendTo("#demo-1");
    $("<option>").attr('selected', 'selected').html('Select Language').appendTo('#langList');
    $.each(data.languageList, function(langCode, lang)
    {
        $("<option>").val(langCode).html(lang.english_name+' '+lang.native_name).appendTo('#langList');
    });
	
    /* Quran List */
    $('#demo-1').append('<br />Select Quran: ');
    $("<select>").attr('id', 'quranList').appendTo("#demo-1");
    $("<option>").attr('selected', 'selected').html('Select Quran').appendTo('#quranList');
    $.each(data.quranList, function(quranID, by)
    {
        if (by.format == 'text' && by.type == 'quran')
	$("<option>").val(quranID).html(by.english_name+' '+by.native_name).appendTo('#quranList');
    });
	
	
    /* Translation List */
    $('#demo-1').append('<br />Select Translation: ');
    $("<select>").attr('id', 'transList').appendTo("#demo-1");
    $("<option>").attr('selected', 'selected').html('Select Translation').appendTo('#transList');
    $.each(data.quranList, function(quranID, by)
    {
	if (by.format == 'text' && by.type == 'translation')
	$("<option>").val(quranID).html(by.english_name+' '+by.native_name).appendTo('#transList');
    });
	
    /* Recitor List */
    $('#demo-1').append('<br />Select Recitor: ');
    $("<select>").attr('id', 'recitorList').appendTo("#demo-1");
    $("<option>").attr('selected', 'selected').html('Select Translation').appendTo('#recitorList');
    $.each(data.quranList, function(quranID, by)
    {
        if (by.format == 'audio')
	$("<option>").val(quranID).html(by.english_name+' '+by.native_name).appendTo('#recitorList');
    });
	
    /* quran data */
    $.each(data.quran, function(i, by)
    {
        $.each(by, function (verseNo, line) {
	    $("<p>").html(line.surah+':'+line.ayah+' '+line.verse).appendTo("#demo-1");
	});
    });
});
</script>
</body>
</html>


Demo:

Comments


blog comments powered by Disqus

.