Skill Level: 
Advanced

This API endpoint allows access for specific calendars.

Available Methods

Read

GET http://events.unl.edu/api/v2/calendar/{calendar_id}/

This endpoint is for getting a specific calendar based on its ID.

HTTP Method


GET

Authentication Requirements


None

Request Data


  • calendar_id number Required Path
    ID of the calendar to look up. This will go into the path of the request.

Response Data


  • Status number
    Status code for the request.
  • Message string
    Status message for the request.
  • Data Calendar Object | null
    The requested calendar's data or null on error.
    • id string
      The ID of the calendar.
    • name string
      The name of the calendar.
    • short-name string
      The short name of the calendar. This can be used in the URL of other events API v2 requests.
    • default-timezone string
      The default timezone of the calendar. This can be overridden by event's data times.
    • webpage string | null
      The webpage of the calendar or null if none is set.
    • email-list string | null
      The list of emails for the calendar or null if none is set. Emails will be separated by commas.
    • event-release-preference string
      The release process for events after they are created on the calendar.
    • recommendations-within-account bool
      Whether users on the same account can recommend events to this calendar.

Example Code


Javascript
async function eventsAPI() {
    const response = await fetch('https://events.unl.edu/api/v2/calendar/3809/');
    if (response.ok) {
        const response_json = await response.json();
        console.log(response_json.data);
    }
}
CURL
curl -X GET 'https://events.unl.edu/api/v2/calendar/3809/'
PHP
function eventsAPI() {
    $url = 'https://events.unl.edu/api/v2/calendar/3809/';

    // Make an HTTP GET request using file_get_contents
    $response = file_get_contents($url);

    if ($response !== false) {
        // Decode the JSON response
        $responseData = json_decode($response, true);

        // Check if JSON decoding was successful
        if ($responseData !== null) {
            // Access the 'data' field in the response JSON
            var_dump($responseData);
        } else {
            echo 'JSON decoding error';
        }
    } else {
        echo 'Error fetching data';
    }
}

Create

POST http://events.unl.edu/api/v2/calendar/

This endpoint is for creating a new calendar.

HTTP Method


Post

Authentication Requirements


You must add a header to the request with the header key being Authentication and the value being your API Token.

Request Data


  • name string Required
    The name of the calendar.
  • short-name string Required
    The short name of the calendar. This can be used in the URL of other events API v2 requests.
  • default-timezone string Required
    The default timezone of the calendar. This can be overridden by event's data times. The options for this are Eastern, Central, Mountain, Arizona, and Pacific.
  • webpage string | null
    The webpage of the calendar.
  • email-list string | null
    The list of emails for the calendar. Emails will be separated by commas.
  • event-release-preference string | null
    The release process for events after they are created on the calendar. Options are immediate or pending (default).
  • recommendations-within-account bool Required
    Whether users on the same account can recommend events to this calendar.

Response Data


  • Status number
    Status code for the request.
  • Message string
    Status message for the request.
  • Data Calendar Object | null
    The newly created calendar data or null on error.
    • id string
      The ID of the calendar.
    • name string
      The name of the calendar.
    • short-name string
      The short name of the calendar. This can be used in the URL of other events API v2 requests.
    • default-timezone string
      The default timezone of the calendar. This can be overridden by event's data times.
    • webpage string | null
      The webpage of the calendar or null if none is set.
    • email-list string | null
      The list of emails for the calendar or null if none is set. Emails will be separated by commas.
    • event-release-preference string
      The release process for events after they are created on the calendar.
    • recommendations-within-account bool
      Whether users on the same account can recommend events to this calendar.

Example Code


Javascript
async function eventsAPI() {

    // Sets up data
    const data = {
        'name': 'API Calendar',
        'short-name': 'API_CAL',
        'default-timezone': 'Central',
        'webpage': 'https://www.unl.edu/',
        'email-list': 'wdn@unl.edu,hhusker2@unl.edu',
        'event-release-preference': 'pending',
        'recommendations-within-account': true,
    }

    // Sends request with method, headers, and data
    const response = await fetch(
        'https://events.unl.edu/api/v2/calendar/',
        {
            method: 'POST',
            headers: {
                'content-type': 'application/json',
                'Authentication': MY_API_TOKEN,
            },
            body: JSON.stringify(data),
        }
    );

    // Checks response and throws error on error
    if (response.ok) {
        const response_json = await response.json();
        console.log(response_json.data);
    } else {
        response.text().then(text => {throw new Error(text)})
    }
}
CURL
curl -X POST https://events.unl.edu/api/v2/calendar/ \
-H "Content-Type: application/json" \
-H "Authentication: MY_API_TOKEN" \
-d '{
    "name": "API Calendar",
    "short-name": "API_CAL",
    "default-timezone": "Central",
    "webpage": "https://www.unl.edu/",
    "email-list": "wdn@unl.edu,hhusker2@unl.edu",
    "event-release-preference": "pending",
    "recommendations-within-account": true,
}'
PHP
function eventsAPI() {
    $data = array(
        'name' => 'API Calendar',
        'short-name' => 'API_CAL',
        'default-timezone' => 'Central',
        'webpage' => 'https://www.unl.edu/',
        'email-list' => 'wdn@unl.edu,hhusker2@unl.edu',
        'event-release-preference' => 'pending',
        'recommendations-within-account' => true,
    );

    $jsonData = json_encode($data);

    $apiToken = 'MY_API_TOKEN';

    $url = 'https://events.unl.edu/api/v2/calendar/';
    $headers = array(
        'Content-Type: application/json',
        'Authentication: ' . $apiToken,
    );

    // Initialize cURL session
    $ch = curl_init();

    // Set cURL options
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    // Execute cURL session and get the response
    $response = curl_exec($ch);

    // Check if cURL request was successful
    if ($response === false) {
        // Handle cURL error
        echo 'cURL Error: ' . curl_error($ch);
    } else {
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if ($httpCode === 200) {
            // Successful response
            $responseData = json_decode($response, true);
            var_dump($responseData);
        } else {
            // Error response
            echo 'API Error: ' . $response;
        }
    }

    // Close cURL session
    curl_close($ch);
}

Update

PUT http://events.unl.edu/api/v2/calendar/{calendar_id}/

This endpoint is for updating a specific virtual location based on its ID.

HTTP Method


PUT

Authentication Requirements


You must add a header to the request with the header key being Authentication and the value being your API Token.

Request Data


Even if the data hasn't changed, please re-enter any previously existing data to avoid unintentional null values.

  • calendar_id number Required Path
    ID of the calendar to look up. This will go into the path of the request.
  • name string Required
    The name of the calendar.
  • short-name string Required
    The short name of the calendar. This can be used in the URL of other events API v2 requests.
  • default-timezone string Required
    The default timezone of the calendar. This can be overridden by event's data times. The options for this are Eastern, Central, Mountain, Arizona, and Pacific.
  • webpage string | null
    The webpage of the calendar.
  • email-list string | null
    The list of emails for the calendar. Emails will be separated by commas.
  • event-release-preference string | null
    The release process for events after they are created on the calendar. Options are immediate or pending (default).
  • recommendations-within-account bool Required
    Whether users on the same account can recommend events to this calendar.

Response Data


  • Status number
    Status code for the request.
  • Message string
    Status message for the request.
  • Data Calendar Object | null
    The newly updated calendar data or null on error.
    • id string
      The ID of the calendar.
    • name string
      The name of the calendar.
    • short-name string
      The short name of the calendar. This can be used in the URL of other events API v2 requests.
    • default-timezone string
      The default timezone of the calendar. This can be overridden by event's data times.
    • webpage string | null
      The webpage of the calendar or null if none is set.
    • email-list string | null
      The list of emails for the calendar or null if none is set. Emails will be separated by commas.
    • event-release-preference string
      The release process for events after they are created on the calendar.
    • recommendations-within-account bool
      Whether users on the same account can recommend events to this calendar.

Example Code


Javascript
async function eventsAPI() {

    // Sets up data
    const data = {
        'name': 'API Calendar',
        'short-name': 'API_CAL',
        'default-timezone': 'Central',
        'webpage': 'https://www.unl.edu/',
        'email-list': 'wdn@unl.edu,hhusker2@unl.edu',
        'event-release-preference': 'pending',
        'recommendations-within-account': true,
    }

    // Sends request with method, headers, and data
    const response = await fetch(
        'https://events.unl.edu/api/v2/calendar/3809/',
        {
            method: 'PUT',
            headers: {
                'content-type': 'application/json',
                'Authentication': MY_API_TOKEN,
            },
            body: JSON.stringify(data),
        }
    );

    // Checks response and throws error on error
    if (response.ok) {
        const response_json = await response.json();
        console.log(response_json.data);
    } else {
        response.text().then(text => {throw new Error(text)})
    }
}
CURL
curl -X PUT https://events.unl.edu/api/v2/calendar/3809/ \
-H "Content-Type: application/json" \
-H "Authentication: MY_API_TOKEN" \
-d '{
    "name": "API Calendar",
    "short-name": "API_CAL",
    "default-timezone": "Central",
    "webpage": "https://www.unl.edu/",
    "email-list": "wdn@unl.edu,hhusker2@unl.edu",
    "event-release-preference": "pending",
    "recommendations-within-account": true,
}'
PHP
function eventsAPI() {
    $data = array(
        'name' => 'API Calendar',
        'short-name' => 'API_CAL',
        'default-timezone' => 'Central',
        'webpage' => 'https://www.unl.edu/',
        'email-list' => 'wdn@unl.edu,hhusker2@unl.edu',
        'event-release-preference' => 'pending',
        'recommendations-within-account' => true,
    );

    $jsonData = json_encode($data);

    $apiToken = 'MY_API_TOKEN';

    $url = 'https://events.unl.edu/api/v2/calendar/3809/';
    $headers = array(
        'Content-Type: application/json',
        'Authentication: ' . $apiToken,
    );

    // Initialize cURL session
    $ch = curl_init();

    // Set cURL options
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    // Execute cURL session and get the response
    $response = curl_exec($ch);

    // Check if cURL request was successful
    if ($response === false) {
        // Handle cURL error
        echo 'cURL Error: ' . curl_error($ch);
    } else {
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if ($httpCode === 200) {
            // Successful response
            $responseData = json_decode($response, true);
            var_dump($responseData);
        } else {
            // Error response
            echo 'API Error: ' . $response;
        }
    }

    // Close cURL session
    curl_close($ch);
}

Delete

DELETE http://events.unl.edu/api/v2/calendar/{calendar_id}/

This endpoint is for deleting a specific calendar based on its ID.

HTTP Method


DELETE

Authentication Requirements


You must add a header to the request with the header key being Authentication and the value being your API Token.

Request Data


Even if the data hasn't changed, please re-enter any previously existing data to avoid unintentional null values.

  • calendar_id string Required Path
    The id of the calendar to delete. This will go into the path of the request.

Response Data


  • Status number
    Status code for the request.
  • Message string
    Status message for the request.
  • Data null
    This will never have data to return.

Example Code


Javascript
async function eventsAPI() {
    // Sends request with method, headers, and data
    const response = await fetch(
        'https://events.unl.edu/api/v2/calendar/3809/',
        {
            method: 'DELETE',
            headers: {
                'Authentication': MY_API_TOKEN,
            }
        }
    );

    // Checks response and throws error on error
    if (response.ok) {
        const response_json = await response.json();
        console.log(response_json.data);
    } else {
        response.text().then(text => {throw new Error(text)})
    }
}
CURL
curl -X DELETE https://events.unl.edu/api/v2/calendar/3809/ \
-H "Authentication: MY_API_TOKEN"
PHP
function eventsAPI() {

    $apiToken = 'MY_API_TOKEN';

    $url = 'https://events.unl.edu/api/v2/calendar/3809/';
    $headers = array(
        'Authentication: ' . $apiToken,
    );

    // Initialize cURL session
    $ch = curl_init();

    // Set cURL options
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    // Execute cURL session and get the response
    $response = curl_exec($ch);

    // Check if cURL request was successful
    if ($response === false) {
        // Handle cURL error
        echo 'cURL Error: ' . curl_error($ch);
    } else {
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if ($httpCode === 200) {
            // Successful response
            $responseData = json_decode($response, true);
            var_dump($responseData);
        } else {
            // Error response
            echo 'API Error: ' . $response;
        }
    }

    // Close cURL session
    curl_close($ch);
}
Contributed By: 
DXG