1. Home
  2. Docs
  3. Eventer
  4. REST API

REST API

The Eventer Plugin is a comprehensive solution for managing events on your WordPress website. Whether you’re hosting concerts, conferences, or community gatherings, Eventer makes it easy to create, manage, and display events with rich features like ticketing, scheduling, and taxonomy-based categorization.

To enhance flexibility and automation, the Eventer Plugin includes a robust REST API. This API allows developers to programmatically interact with the plugin, enabling seamless integration with third-party systems, custom workflows, and external applications.

REST API Overview

The Eventer Plugin’s REST API is designed to extend the plugin’s functionality for developers. It provides endpoints to:

  • Create or update events: Add all necessary details like titles, descriptions, and custom metadata.
  • Manage tickets: Add regular or WooCommerce tickets with quantity and pricing.
  • Organize events: Assign events to categories, tags, venues, or organizers.
  • Set time slots: Define time-based sections for detailed event scheduling.

The API uses WordPress’s standard REST architecture, ensuring compatibility with other WordPress APIs and making it easy to implement in various environments.

Example Use Cases

  • Sync with External Systems
    Automatically import or update events from external platforms or applications into your WordPress site.
  • Custom Front-End Applications
    Build custom event submission forms or ticketing portals on your front end by leveraging the API.
  • Integrate WooCommerce
    Seamlessly manage WooCommerce products as tickets, allowing users to buy tickets directly from your site.
  • Programmatic Event Management
    Use the API to update events dynamically based on external triggers or data feeds.

Authenticating API Requests with WordPress Application Passwords

The Eventer Plugin REST API supports authentication via WordPress Application Passwords, a secure and user-friendly way to connect external applications or scripts to your WordPress website. This method ensures that API requests are authenticated and authorized without exposing your WordPress login credentials.

What Are WordPress Application Passwords?

WordPress Application Passwords allow users to generate unique credentials for external applications to access specific parts of the site, such as the REST API. These passwords are tied to individual user accounts and can be revoked at any time, providing an additional layer of security.

How to Generate an Application Password

  1. Log into WordPress: Go to your WordPress Admin Dashboard.
  2. Access Profile Settings: Navigate to Users > Profile (or Profile in the top-right dropdown).
  3. Find Application Passwords Section: Scroll to the “Application Passwords” section.
  4. Create a New Password: Enter a name for the application (e.g., “Eventer API Access”) and click Add New Application Password.
  5. Copy the Password: Copy the generated password and store it securely. This password will not be shown again.

Using Application Passwords for API Requests

To authenticate requests with an application password, include the credentials in the request’s Authorization header. The format is:

Authorization: Basic base64_encode(username:application_password)

Example Request

Here’s an example of how to use an application password in a cURL request:

curl -X POST https://example.com/wp-json/eventer/v1/create-update-event \
-H "Authorization: Basic dXNlcm5hbWU6YXBwbGljYXRpb25fcGFzc3dvcmQ=" \
-H "Content-Type: application/json" \
-d '{
  "title": "Summer Music Festival",
  "description": "A grand festival featuring live music performances.",
  "event_start_dt": "2025-07-01 10:00",
  "event_end_dt": "2025-07-01 22:00",
  "eventer-category": ["Music", "Festivals"]
}'
  • Replace username with the WordPress username.
  • Replace application_password with the generated application password.
  • The Authorization header value is a Base64-encoded string of username:application_password.

PHP Example

If you are using PHP to make the API call, here’s an example:

$username = 'your_username';
$password = 'your_application_password';

$api_url = 'https://example.com/wp-json/eventer/v1/create-update-event';
$data = [
    'title' => 'Summer Music Festival',
    'description' => 'A grand festival featuring live music performances.',
    'event_start_dt' => '2025-07-01 10:00',
    'event_end_dt' => '2025-07-01 22:00',
    'eventer-category' => ['Music', 'Festivals']
];

$options = [
    'http' => [
        'header' => "Authorization: Basic " . base64_encode("$username:$password") . "\r\n" .
                    "Content-Type: application/json\r\n",
        'method' => 'POST',
        'content' => json_encode($data),
    ],
];

$context = stream_context_create($options);
$response = file_get_contents($api_url, false, $context);

if ($response === FALSE) {
    die('Error occurred while making the API request.');
}

echo $response;

Key Points to Remember

  1. User Permissions: The API request will use the permissions of the user associated with the application password. Ensure that the user has sufficient permissions (e.g., edit_posts for creating or updating events).
  2. Security: Always use HTTPS to ensure that credentials and data are transmitted securely.
  3. Revoking Access: You can revoke an application password anytime in the user profile settings if access is no longer needed.
  4. Avoid Hardcoding Passwords: Store credentials securely (e.g., in environment variables) and avoid hardcoding them in your scripts.

Articles

How can we help?