Skip to content

Instantly share code, notes, and snippets.

@lomotech
Last active December 18, 2023 03:56
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save lomotech/b25cde7118adf5e7a1fea4ce6cfce259 to your computer and use it in GitHub Desktop.
Save lomotech/b25cde7118adf5e7a1fea4ce6cfce259 to your computer and use it in GitHub Desktop.
JAKIM eSolat API

URL

https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period=__PERIOD__&zone=__ZONE__

Request type

GET & POST can be used but POST is prefered. See Period / Duration note

Period

  • week
  • month
  • year
  • duration

note when using period = duration

  1. Use POST
  2. pass datestart and dateend as body value
  3. date format is yyyy-mm-dd. eg. 2023-07-03

Zone

  • JHR01 : Pulau Aur dan Pulau Pemanggil
  • JHR02 : Johor Bharu, Kota Tinggi, Mersing
  • JHR03 : Kluang, Pontian
  • JHR04 : Batu Pahat, Muar, Segamat, Gemas Johor
  • KDH01 : Kota Setar, Kubang Pasu, Pokok Sena (Daerah Kecil)
  • KDH02 : Kuala Muda, Yan, Pendang
  • KDH03 : Padang Terap, Sik
  • KDH04 : Baling
  • KDH05 : Bandar Baharu, Kulim
  • KDH06 : Langkawi
  • KDH07 : Gunung Jerai
  • KTN01 : Bachok, Kota Bharu, Machang, Pasir Mas, Pasir Puteh, Tanah Merah, Tumpat, Kuala Krai, Mukim Chiku
  • KTN03 : Gua Musang (Daerah Galas Dan Bertam), Jeli
  • MLK01 : SELURUH NEGERI MELAKA
  • NGS01 : Tampin, Jempol
  • NGS02 : Jelebu, Kuala Pilah, Port Dickson, Rembau, Seremban
  • PHG01 : Pulau Tioman
  • PHG02 : Kuantan, Pekan, Rompin, Muadzam Shah
  • PHG03 : Jerantut, Temerloh, Maran, Bera, Chenor, Jengka
  • PHG04 : Bentong, Lipis, Raub
  • PHG05 : Genting Sempah, Janda Baik, Bukit Tinggi
  • PHG06 : Cameron Highlands, Genting Higlands, Bukit Fraser
  • PLS01 : Kangar, Padang Besar, Arau
  • PNG01 : Seluruh Negeri Pulau Pinang
  • PRK01 : Tapah, Slim River, Tanjung Malim
  • PRK02 : Kuala Kangsar, Sg. Siput (Daerah Kecil), Ipoh, Batu Gajah, Kampar
  • PRK03 : Lenggong, Pengkalan Hulu, Grik
  • PRK04 : Temengor, Belum
  • PRK05 : Kg Gajah, Teluk Intan, Bagan Datuk, Seri Iskandar, Beruas, Parit, Lumut, Sitiawan, Pulau Pangkor
  • PRK06 : Selama, Taiping, Bagan Serai, Parit Buntar
  • PRK07 : Bukit Larut
  • SBH01 : Bahagian Sandakan (Timur), Bukit Garam, Semawang, Temanggong, Tambisan, Bandar Sandakan
  • SBH02 : Beluran, Telupid, Pinangah, Terusan, Kuamut, Bahagian Sandakan (Barat)
  • SBH03 : Lahad Datu, Silabukan, Kunak, Sahabat, Semporna, Tungku, Bahagian Tawau (Timur)
  • SBH04 : Bandar Tawau, Balong, Merotai, Kalabakan, Bahagian Tawau (Barat)
  • SBH05 : Kudat, Kota Marudu, Pitas, Pulau Banggi, Bahagian Kudat
  • SBH06 : Gunung Kinabalu
  • SBH07 : Kota Kinabalu, Ranau, Kota Belud, Tuaran, Penampang, Papar, Putatan, Bahagian Pantai Barat
  • SBH08 : Pensiangan, Keningau, Tambunan, Nabawan, Bahagian Pendalaman (Atas)
  • SBH09 : Beaufort, Kuala Penyu, Sipitang, Tenom, Long Pa Sia, Membakut, Weston, Bahagian Pendalaman (Bawah)
  • SGR01 : Gombak, Petaling, Sepang, Hulu Langat, Hulu Selangor, Rawang, S.Alam
  • SGR02 : Kuala Selangor, Sabak Bernam
  • SGR03 : Klang, Kuala Langat
  • SWK01 : Limbang, Lawas, Sundar, Trusan
  • SWK02 : Miri, Niah, Bekenu, Sibuti, Marudi
  • SWK03 : Pandan, Belaga, Suai, Tatau, Sebauh, Bintulu
  • SWK04 : Sibu, Mukah, Dalat, Song, Igan, Oya, Balingian, Kanowit, Kapit
  • SWK05 : Sarikei, Matu, Julau, Rajang, Daro, Bintangor, Belawai
  • SWK06 : Lubok Antu, Sri Aman, Roban, Debak, Kabong, Lingga, Engkelili, Betong, Spaoh, Pusa, Saratok
  • SWK07 : Serian, Simunjan, Samarahan, Sebuyau, Meludam
  • SWK08 : Kuching, Bau, Lundu, Sematan
  • SWK09 : Zon Khas (Kampung Patarikan)
  • TRG01 : Kuala Terengganu, Marang, Kuala Nerus
  • TRG02 : Besut, Setiu
  • TRG03 : Hulu Terengganu
  • TRG04 : Dungun, Kemaman
  • WLY01 : Kuala Lumpur, Putrajaya
  • WLY02 : Labuan

Output

{
    "prayerTime": [
        {
            "hijri": "1439-12-24",
            "date": "05-Sep-2018",
            "day": "Wednesday",
            "imsak": "05:30:00",
            "fajr": "05:40:00",
            "syuruk": "06:56:00",
            "dhuhr": "13:03:00",
            "asr": "16:10:00",
            "maghrib": "19:07:00",
            "isha": "20:16:00"
        },
        {...}
    ],
    "status": "OK!",
    "serverTime": "2018-09-05 14:15:55",
    "periodType": "week",
    "lang": "ms_my",
    "zone": "JHR01",
    "bearing": "292° 25′ 40″"
}
@arazi2021
Copy link

How to Query Period = Duration

@redbaroque90
Copy link

How to Query Period = Duration

You need to include post form data with the link

example:

POST
{
'datestart':'2023-06-01',
'dateend':'2023-06-01'
}

@muhammadnazreen
Copy link

How to Query Period = Duration

You need to include post form data with the link

example:

POST { 'datestart':'2023-06-01', 'dateend':'2023-06-01' }

can you provide me more explanation, I simply do not understand how to do it on a link. Give me full example of the link

@lomotech
Copy link
Author

lomotech commented Jul 1, 2023

How to Query Period = Duration

You need to include post form data with the link
example:
POST { 'datestart':'2023-06-01', 'dateend':'2023-06-01' }

can you provide me more explanation, I simply do not understand how to do it on a link. Give me full example of the link

if you want to use duration as period method, you need to use post request. and put datestart and dateend as body form data.
eg. in postman, datestart and dateend is set at body > form-data.

@arazi2021
Copy link

arazi2021 commented Jul 3, 2023

How to Query Period = Duration

You need to include post form data with the link
example:
POST { 'datestart':'2023-06-01', 'dateend':'2023-06-01' }

can you provide me more explanation, I simply do not understand how to do it on a link. Give me full example of the link

if you want to use duration as period method, you need to use post request. and put datestart and dateend as body form data. eg. in postman, datestart and dateend is set at body > form-data.

is it like this

https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period={'datestart':'2023-06-01','dateend':'2023-06-01'}&zone=MLK01

or

https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period='datestart':'2023-06-01','dateend':'2023-06-01'&zone=MLK01

@redbaroque90
Copy link

How to Query Period = Duration

You need to include post form data with the link
example:
POST { 'datestart':'2023-06-01', 'dateend':'2023-06-01' }

can you provide me more explanation, I simply do not understand how to do it on a link. Give me full example of the link

if you want to use duration as period method, you need to use post request. and put datestart and dateend as body form data. eg. in postman, datestart and dateend is set at body > form-data.

is it like this

https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period={'datestart':'2023-06-01','dateend':'2023-06-01'}&zone=MLK01

or

https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period='datestart':'2023-06-01','dateend':'2023-06-01'&zone=MLK01

Both link is not the right way. You can't use GET request for datestart and dateend. You need to use POST to send both data. Try to explore how to send post data using postman first

@arazi2021
Copy link

How to Query Period = Duration

You need to include post form data with the link
example:
POST { 'datestart':'2023-06-01', 'dateend':'2023-06-01' }

can you provide me more explanation, I simply do not understand how to do it on a link. Give me full example of the link

if you want to use duration as period method, you need to use post request. and put datestart and dateend as body form data. eg. in postman, datestart and dateend is set at body > form-data.

is it like this
https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period={'datestart':'2023-06-01','dateend':'2023-06-01'}&zone=MLK01
or
https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period='datestart':'2023-06-01','dateend':'2023-06-01'&zone=MLK01

Both link is not the right way. You can't use GET request for datestart and dateend. You need to use POST to send both data. Try to explore how to send post data using postman first

Can you gave me full exampl e how to query ..TQ

@redbaroque90
Copy link

How to Query Period = Duration

You need to include post form data with the link
example:
POST { 'datestart':'2023-06-01', 'dateend':'2023-06-01' }

can you provide me more explanation, I simply do not understand how to do it on a link. Give me full example of the link

if you want to use duration as period method, you need to use post request. and put datestart and dateend as body form data. eg. in postman, datestart and dateend is set at body > form-data.

is it like this
https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period={'datestart':'2023-06-01','dateend':'2023-06-01'}&zone=MLK01
or
https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period='datestart':'2023-06-01','dateend':'2023-06-01'&zone=MLK01

Both link is not the right way. You can't use GET request for datestart and dateend. You need to use POST to send both data. Try to explore how to send post data using postman first

Can you gave me full exampl e how to query ..TQ

https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period=duration&zone=PNG01

and then include datestart and dateend on body form data. Where do you want to link the waktu solat? App or website?

@arazi2021
Copy link

How to Query Period = Duration

You need to include post form data with the link
example:
POST { 'datestart':'2023-06-01', 'dateend':'2023-06-01' }

can you provide me more explanation, I simply do not understand how to do it on a link. Give me full example of the link

if you want to use duration as period method, you need to use post request. and put datestart and dateend as body form data. eg. in postman, datestart and dateend is set at body > form-data.

is it like this
https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period={'datestart':'2023-06-01','dateend':'2023-06-01'}&zone=MLK01
or
https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period='datestart':'2023-06-01','dateend':'2023-06-01'&zone=MLK01

Both link is not the right way. You can't use GET request for datestart and dateend. You need to use POST to send both data. Try to explore how to send post data using postman first

Can you gave me full exampl e how to query ..TQ

https://www.e-solat.gov.my/index.php?r=esolatApi/takwimsolat&period=duration&zone=PNG01

and then include datestart and dateend on body form data. Where do you want to link the waktu solat? App or website?

OK successfully got the result ..TQ..really appreciated

@muhdluqman
Copy link

How to get zone from gelocator and geocoding?

@zedpr0
Copy link

zedpr0 commented Oct 29, 2023

Did anyone find a way to get zone from coordinates? Is there any simple way of doing it beyond getting the city and trying to match the zones?

@lomotech
Copy link
Author

lomotech commented Oct 30, 2023

@muhdluqman @zedpr0 i dont think there is an easy way to get from coordinate. You need to have reverse geo to get district name and compare it with zone because of JAKIM only provide scheduled by zone in district name.

there is several method to get district name btw from geocode. easiest way is using third party API such Google geo API. but its not always be free.

@zedpr0
Copy link

zedpr0 commented Oct 30, 2023

yeah thats what I thought, I decided to go with geoserver and get the district from wfs feature. quite interesting. haha Ive listed the code ive used below if anyone else would like to use my method and geoserver.

const getDistrict = async () => {
    const body = new URLSearchParams();
    body.append('service', 'WFS');
    body.append('request', 'GetFeature');
    body.append('version', '1.0.0');
    body.append('typename', 'Malaysia:District');
    body.append('srsname', 'EPSG:4326');
    body.append('cql_filter', `INTERSECTS(the_geom, POINT (${location.longitude} ${location.latitude}))`)

    const response = await fetch('https://geo.zedpro.me/Malaysia/wfs', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        body: body
    })
    const xmlText = await response.text()
    const parser = new DOMParser();
    const xmlDoc = parser.parseFromString(xmlText,"text/xml");
    const features = xmlDoc.getElementsByTagName("gml:featureMember")
    if(features.length===0){
        return null
    }
    return features[0].getElementsByTagName('Malaysia:laa')[0].childNodes[0]
}

@lomotech
Copy link
Author

@zedpr0 watchout for certain zone that is exclusive eg gunung jerai, gunung kinabalu.

@zedpr0
Copy link

zedpr0 commented Oct 30, 2023

Thanks for the heads up, my districts layer does not have those. will need to take that into account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment