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
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
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
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
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
Example Request
curl -X GET "https://isleapyear.app/api/calendar/julian/check/2024"
Response Format
Field | Type | Description |
---|---|---|
isLeapYear | Boolean | Whether the specified year is a leap year |
daysInFebruary | Integer | Number of days in February for the specified year |
nextLeapYear | Integer | The next leap year after the specified year |
yearChecked | Integer | The 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 Code | Error | Description |
---|---|---|
400 | Bad Request | Invalid request parameters |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Our quantum computer is overheating |
Client Libraries
JavaScript
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