Skip to main content

REST API

Access recurring event data via the WordPress REST API.

Base URL

https://yoursite.com/wp-json/lre/v1/

Authentication

Public endpoints require no authentication. The API respects WordPress capabilities for any write operations.

Endpoints

GET /events

Retrieve events for a date range (used by the calendar).

GET /wp-json/lre/v1/events?start=2026-01-01&end=2026-01-31

Parameters

ParameterTypeDescriptionRequired
startstringStart date (ISO format)Yes
endstringEnd date (ISO format)Yes
post_typestringFilter by post type(s)No

Example Request

curl "https://yoursite.com/wp-json/lre/v1/events?start=2026-01-01&end=2026-01-31&post_type=event"

Example Response

[
{
"id": 123,
"title": "Weekly Yoga Class",
"start": "2026-01-07T09:00:00",
"end": "2026-01-07T10:00:00",
"url": "https://yoursite.com/event/weekly-yoga-class/?lre_date=2026-01-07",
"backgroundColor": "#3788d8",
"textColor": "#ffffff",
"extendedProps": {
"postId": 123,
"occurrenceDate": "2026-01-07",
"isRecurring": true,
"featuredImage": "https://yoursite.com/wp-content/uploads/yoga.jpg",
"excerpt": "Join us for a relaxing yoga session..."
}
},
{
"id": 123,
"title": "Weekly Yoga Class",
"start": "2026-01-14T09:00:00",
"end": "2026-01-14T10:00:00",
"url": "https://yoursite.com/event/weekly-yoga-class/?lre_date=2026-01-14",
"backgroundColor": "#3788d8",
"textColor": "#ffffff",
"extendedProps": {
"postId": 123,
"occurrenceDate": "2026-01-14",
"isRecurring": true,
"featuredImage": "https://yoursite.com/wp-content/uploads/yoga.jpg",
"excerpt": "Join us for a relaxing yoga session..."
}
}
]

GET /event/{id}

Retrieve details for a specific event occurrence.

GET /wp-json/lre/v1/event/123?date=2026-01-15

Parameters

ParameterTypeDescriptionRequired
idintEvent post IDYes (URL)
datestringOccurrence date (Y-m-d)No

Example Request

curl "https://yoursite.com/wp-json/lre/v1/event/123?date=2026-01-15"

Example Response

{
"id": 123,
"title": "Weekly Yoga Class",
"content": "<p>Full event description...</p>",
"excerpt": "Join us for a relaxing yoga session...",
"url": "https://yoursite.com/event/weekly-yoga-class/?lre_date=2026-01-15",
"featuredImage": {
"url": "https://yoursite.com/wp-content/uploads/yoga.jpg",
"alt": "Yoga class in session"
},
"date": "2026-01-15",
"time": "09:00",
"endTime": "10:00",
"location": "Downtown Studio",
"isRecurring": true,
"recurrencePattern": "Every Wednesday",
"addToCalendar": {
"google": "https://calendar.google.com/calendar/render?...",
"yahoo": "https://calendar.yahoo.com/?...",
"ics": "data:text/calendar;charset=utf-8,..."
}
}

Response Format

All responses are JSON. The API follows FullCalendar's event object format for calendar endpoints.

Event Object Properties

PropertyTypeDescription
idintPost ID
titlestringEvent title
startstringStart datetime (ISO 8601)
endstringEnd datetime (ISO 8601)
urlstringEvent permalink with date param
backgroundColorstringHex color
textColorstringHex color
extendedPropsobjectAdditional data

Extended Props

PropertyTypeDescription
postIdintWordPress post ID
occurrenceDatestringDate (Y-m-d)
isRecurringboolHas recurrence enabled
featuredImagestringImage URL
excerptstringEvent excerpt

Error Responses

Invalid Date Range

{
"code": "invalid_dates",
"message": "Both start and end dates are required",
"data": {
"status": 400
}
}

Event Not Found

{
"code": "not_found",
"message": "Event not found",
"data": {
"status": 404
}
}

Filtering Results

By Post Type

GET /events?start=...&end=...&post_type=workshop

Multiple types:

GET /events?start=...&end=...&post_type=event,workshop,class

By Taxonomy (via filter)

Use the lre_calendar_events_query_args filter:

add_filter('lre_calendar_events_query_args', function($args, $request) {
// Get category from request parameter
$category = $request->get_param('category');

if ($category) {
$args['tax_query'] = [
[
'taxonomy' => 'event_category',
'field' => 'slug',
'terms' => $category,
],
];
}

return $args;
}, 10, 2);

Then:

GET /events?start=...&end=...&category=workshops

Using with JavaScript

Fetch Events

async function fetchEvents(start, end) {
const response = await fetch(
`/wp-json/lre/v1/events?start=` + start + `&end=` + end
);
return response.json();
}

// Usage
const events = await fetchEvents('2026-01-01', '2026-01-31');
console.log(events);

Fetch Event Details

async function fetchEventDetails(eventId, date) {
const url = date
? `/wp-json/lre/v1/event/` + eventId + `?date=` + date
: `/wp-json/lre/v1/event/` + eventId;

const response = await fetch(url);
return response.json();
}

// Usage
const event = await fetchEventDetails(123, '2026-01-15');
console.log(event.title, event.location);

Rate Limiting

The API has no built-in rate limiting. For high-traffic sites, consider:

  • Caching responses at the server level
  • Using a CDN
  • Implementing application-level rate limiting

CORS

The API respects WordPress CORS settings. For cross-origin requests, ensure proper headers are configured.