Skip to content

mptwaktusolat/api-waktusolat

Repository files navigation

Vercel Next JS

Waktu Solat API | Malaysia Prayer Time API

Formally 'MPT Server'

A Malaysia Prayer Time REST API server, originally build for Malaysia Prayer Time app. Provide necessary data and procssing for the app features to work.

Getting Started

Prepare environment

Note

If you didn't plan to use /api/jadual_solat endpoint, you may skip this step and proceed to Start development server

Create .env.local at the root the project. Example environment vars are in the .env.example file. Or run:

cp .env.example .env.local

/api/jadual_solat will generate PDF based on the prayer data. To do so, it need to access Chrome. In development, you can use your local Chrome, but on Production, you need to setup the Chrome instance somewhere. I use https://www.browserless.io/ service.

Grab the API key and paste to BROWSERLESS_TOKEN key.

Start development server

First, install the dependencies:

yarn install

Run the development server:

yarn dev

Open http://localhost:3000 with your browser to see the result.

The pages/api directory is mapped to /api/*. Files in this directory are treated as API routes instead of React pages.

(Optional) Make your own Firestore database instance

/api/v2/solat endpoint will fetch the prayer data from Firestore datatabase. To prepare the data needed, see https://github.com/mptwaktusolat/waktusolat-fetcher.

Once setup, set FIREBASE_API_KEY to your own Firebase API key.

How are the prayer time data is updated every month? (Old method)

Note

This method is used to update the /solat endpoint. Now that the endpoint is deprecated, I'll stop the automatic workflow soon. For latest method on fetching the prayer time, see waktusolat-fetcher

The data is updated automatically every month using GitHub Action. The overall flow is depicted in the diagram below.

flowchart TD
    A{{JAKIM}}
    A <--> C
    C[[Fetch latest prayer data]] --- D[(db.json)] & E[(log.json)] --> F(Commit & push)
    F -->|Vercel build triggered| G[Deployed to Vercel]
Loading

View the fetcher implementation here.

Deployment status

deploy live website deploy preview website on branches

API endpoints

Public usage

See https://api.waktusolat.app/docs

Internal usage (MPT App)

  • POST /api/feedback