Skip to main content

Overview

The --json flag enables JSON-only output to stdout, making ramadan-cli perfect for scripts, automation, and programmatic access. This mode skips all interactive prompts and outputs structured data.

Basic Usage

JSON mode automatically skips interactive setup and falls back to IP geolocation if no config exists.

Output Structure

The JSON output follows this structure:

Field Definitions

string
required
The display mode used:
  • "today" - Single day view (default)
  • "all" - Complete Ramadan month (30 days)
  • "number" - Specific roza number
string
required
The location address used for the query (city, country, or coordinates)
number
required
The Hijri year for the Ramadan timings
array
required
Array of Ramadan day objects, each containing:

Output Modes

Today Mode (Default)

Shows timings for the current Ramadan day or next upcoming Ramadan:

All Mode

Shows complete Ramadan month (30 days):

Specific Roza Mode

Shows timings for a specific roza day:

Error Handling

Error Format

When an error occurs with --json, the error payload is written to stderr (not stdout):

Error Codes

Handling Errors in Scripts

Parsing Examples

Extract Specific Fields

Complex Queries

Integration Examples

Shell Script Integration

API Wrapper

Command Combinations

With Location Override

With Custom First Roza Date

Combined with Config

Best Practices

Success output goes to stdout, errors to stderr:
jq is the recommended tool for parsing JSON output:
Check array lengths before accessing:
Prayer times don’t change frequently. Cache the JSON output:

See Also

Agent Usage

Learn about using ramadan-cli as an agent skill

Status Line Mode

Single-line output for status bars