A mirror from Github (https://github.com/dragfyre/bahai-date-api). Unchanged.

dragfyre 806fe2ad59 Merge pull request #47 from dragfyre/dependabot/npm_and_yarn/body-parser-2.2.1 1 month ago
api c7fd464922 chore: update deps. and devDeps. 2 months ago
bin 4703470036 fix: supply `command-line-basics` with notifier info 4 months ago
images ba1d326534 chore: rename bahai-date-rest-api -> bahai-date-api 3 years ago
.editorconfig 11c0fc84ba - Docs: Use syntax highlighting for JSON samples; use diacritics 6 years ago
.gitignore c7dcab448c initial commit 8 years ago
.npmignore c7fd464922 chore: update deps. and devDeps. 2 months ago
LICENSE-ISC.txt a691aba25c Update LICENSE-ISC.txt 2 months ago
README.md bde444e16c - Enhancement: Add timezone properties to `today` 4 years ago
createServer.js 34d122b05b feat: Make rate limit optional and configurable 3 years ago
eslint.config.js c7fd464922 chore: update deps. and devDeps. 2 months ago
package.json f31ba1d619 chore: update badidate, express-rate-limits, devDeps. 2 months ago
pnpm-lock.yaml 8ecc0ebe48 build(deps): Bump body-parser from 2.2.0 to 2.2.1 1 month ago
pnpm-workspace.yaml c7fd464922 chore: update deps. and devDeps. 2 months ago
server.js 8bdc301fac refactor: switch to ESM in process of updating deps. (body-parser, command-line-basics, express, express-rate-limit, luxon) 3 years ago

README.md

Baháʼí Date RESTful API

So far, there are three endpoints for this API:

POST /today

Returns today's date according to the Baháʼí/Badí' calendar via POST request.

GET /today

Returns today's date according to the Baháʼí/Badí' calendar via GET request (as HTML).

GET /date

Given a date from the Gregorian calendar defined via GET data, returns the corresponding date in the Baháʼí calendar (as JSON).

Public endpoints

Public endpoints are now available on bahai-browser.org:

/today - https://bahai-browser.org/today

/date - https://bahai-browser.org/date

Running

To launch the API server, simply navigate to the main folder and type npm start.

Examples

From either endpoint, the output is returned in a similar format: a JSON object containing a message, a Baháʼí calendar date, and a Gregorian date/time.

Today

URL: localhost:1844/today

{
    "message": "Today is 13 Masá’il 174",
    "badi_date": {
        "year": 174,
        "month": 14,
        "day": 13,
        "month_name": "Masá’il",
        "timezone_id": "Asia/Jerusalem"
    },
    "greg_date": {
        "year": 2017,
        "month": 12,
        "day": 5,
        "hour": 23,
        "minute": 19,
        "second": 12,
        "timezoneOffset": 0
    }
}

date

Available parameters include:

  • year
  • month
  • day
  • hour
  • minute
  • second
  • latitude
  • longitude
  • timezoneId

May 23, 1844

URL: localhost:1844/date?year=1844&month=5&day=23&hour=20&minute=45

Output:

{
    "message": "The date is: 8 ‘Aẓamat (Grandeur) 1 B.E.",
    "badi_date": {
        "year": 1,
        "month": 3,
        "day": 8,
        "month_name": "‘Aẓamat (Grandeur)",
        "timezone_id": "Asia/Jerusalem"
    },
    "greg_date": {
        "year": 1844,
        "month": 5,
        "day": 23,
        "hour": 20,
        "minute": 45,
        "second": 0,
        "timezoneOffset": -480
    }
}

February 15, 2014

URL: localhost:1844/date?year=2014&month=2&day=15&hour=13&minute=45

Output:

{
    "message": "The date is: 9 Mulk (Dominion) 170 B.E.",
    "badi_date": {
        "year": 170,
        "month": 18,
        "day": 9,
        "month_name": "Mulk (Dominion)",
        "timezone_id": "Asia/Jerusalem"
    },
    "greg_date": {
        "year": 2014,
        "month": 2,
        "day": 15,
        "hour": 13,
        "minute": 45,
        "second": 0,
        "timezoneOffset": -485
    }
}

CLI usage

cli.svg