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
- Common Errors
- API Errors
- Other Errors
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
Always Parse stderr for Errors
Always Parse stderr for Errors
Success output goes to
stdout, errors to stderr:Use jq for Parsing
Use jq for Parsing
jq is the recommended tool for parsing JSON output:Handle Missing Data Gracefully
Handle Missing Data Gracefully
Check array lengths before accessing:
Cache API Responses
Cache API Responses
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