API Documentation

Overview

The IsLeapYear API provides a simple and reliable way to determine if a given year is a leap year. Our sophisticated algorithms take into account all nuances of the Gregorian calendar system.

Base URL: https://isleapyear.app/api

Authentication

No authentication is required for public API endpoints.

Endpoints

GET /check

Returns information about the current year's leap year status.

Example Request

curl -X GET "https://isleapyear.app/api/check"

Example Response

{
  "isLeapYear": false,
  "daysInFebruary": 28,
  "nextLeapYear": 2028,
  "yearChecked": 2025,
}

GET /check/{year}

Returns information about a specific year's leap year status.

Parameters

Path Parameters
yearRequired - The year to check (1582-9999)

Example Request

curl -X GET "https://isleapyear.app/api/check/2024"

Example Response

{
  "isLeapYear": true,
  "daysInFebruary": 29,
  "nextLeapYear": 2028,
  "yearChecked": 2024,
}

POST /check/batch

Checks multiple years at once for more efficient processing.

Request Body

yearsRequired - Array of years to check (max 100 years per request)

Example Request

curl -X POST "https://isleapyear.app/api/check/batch" \
  -H "Content-Type: application/json" \
  -d '{"years": [2023, 2024, 2025, 2100]}'

Example Response

{
  "results": [
    {
      "yearChecked": 2023,
      "isLeapYear": false,
      "daysInFebruary": 28,
      "nextLeapYear": 2024
    },
    {
      "yearChecked": 2024,
      "isLeapYear": true,
      "daysInFebruary": 29,
      "nextLeapYear": 2028
    },
    {
      "yearChecked": 2025,
      "isLeapYear": false,
      "daysInFebruary": 28,
      "nextLeapYear": 2028
    },
    {
      "yearChecked": 2100,
      "isLeapYear": false,
      "daysInFebruary": 28,
      "nextLeapYear": 2104
    }
  ],
  "count": 4,
}

GET /stats/range

Returns statistics about leap years within a specified date range.

Query Parameters

startRequired - Start year for the range (min: 1582)
endRequired - End year for the range (max: 9999)

Example Request

curl -X GET "https://isleapyear.app/api/stats/range?start=2000&end=2050"

Example Response

{
  "startYear": 2000,
  "endYear": 2050,
  "totalYears": 51,
  "leapYearCount": 13,
  "leapYearPercentage": 25.49,
  "leapYears": [2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, 2044, 2048],
}

GET /stats/distribution

Returns detailed statistics about leap years by decade within a specified date range.

Query Parameters

startOptional - Start year for the range (min: 1582, default: 1900)
endOptional - End year for the range (max: 9999, default: 2100)

Example Request

curl -X GET "https://isleapyear.app/api/stats/distribution?start=2000&end=2050"

Example Response

{
  "startYear": 2000,
  "endYear": 2050,
  "totalYears": 51,
  "totalLeapYears": 13,
  "overallLeapYearPercentage": 25.49,
  "distribution": [
    {
      "decade": "2000s",
      "totalYears": 10,
      "leapYears": 3,
      "leapYearPercentage": 30.0,
      "leapYearsList": [2000, 2004, 2008]
    },
    {
      "decade": "2010s",
      "totalYears": 10,
      "leapYears": 2,
      "leapYearPercentage": 20.0,
      "leapYearsList": [2012, 2016]
    },
    {
      "decade": "2020s",
      "totalYears": 10,
      "leapYears": 3,
      "leapYearPercentage": 30.0,
      "leapYearsList": [2020, 2024, 2028]
    },
    {
      "decade": "2030s",
      "totalYears": 10,
      "leapYears": 2,
      "leapYearPercentage": 20.0,
      "leapYearsList": [2032, 2036]
    },
    {
      "decade": "2040s",
      "totalYears": 10,
      "leapYears": 3,
      "leapYearPercentage": 30.0,
      "leapYearsList": [2040, 2044, 2048]
    },
    {
      "decade": "2050s",
      "totalYears": 1,
      "leapYears": 0,
      "leapYearPercentage": 0.0,
      "leapYearsList": []
    }
  ],
}

GET /calendar/{type}/check/{year}

Returns information about a specific year's leap year status in different calendar systems.

Parameters

Path Parameters
typeRequired - Calendar type (gregorian, julian, hebrew, chinese)
yearRequired - The year to check

Example Request

curl -X GET "https://isleapyear.app/api/calendar/julian/check/2024"

Response Format

FieldTypeDescription
isLeapYearBooleanWhether the specified year is a leap year
daysInFebruaryIntegerNumber of days in February for the specified year
nextLeapYearIntegerThe next leap year after the specified year
yearCheckedIntegerThe year that was checked

Rate Limits

To ensure service stability, the API has a default rate limit of 100 requests per day with a burst limit of 5 requests per second.

Error Codes

Status CodeErrorDescription
400Bad RequestInvalid request parameters
429Too Many RequestsRate limit exceeded
500Internal Server ErrorOur quantum computer is overheating

Client Libraries

JavaScript

Usage
import { IsLeapYearClient } from 'is-leap-year-client'; 

// Initialize the client
const client = new IsLeapYearClient();

// Check current year
const result = await client.check();
console.log(result.isLeapYear);

// Check specific year
const result2024 = await client.check(2024);
console.log(result2024.isLeapYear); // true