Skill Level: 
Advanced

This API endpoint allows you to get lists of events from a specific calendar.

Available Endpoints

Read (By ID)

GET http://events.unl.edu/api/v2/location/{location_id}/

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

HTTP Method


GET

Authentication Requirements


None

Request Data


  • location_id number Required Path
    ID of the location 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 Location Object | null
    The requested location data or null on error.
    • id string
      The ID of the location.
    • name string | null
      The name of the location or null if none is set.
    • address-1 string | null
      The street address of the location or null if none is set.
    • address-2 string | null
      The additional address of the location or null if none is set.
    • city string | null
      The city of the location or null if none is set.
    • state string | null
      The state of the location or null if none is set. This will always be the 2 letter abbreviation of the state.
    • zip string | null
      The zip of the location or null if none is set. This will always be ≤ 10 characters long.
    • map-url string | null
      The url of the map graphical interface of the location or null if none is set. This will always be a URL.
    • webpage string | null
      The web page of the location or null if none is set. This will always be a URL.
    • hours string | null
      The hours of the location or null if none is set.
    • phone string | null
      The phone number of the location or null if none is set.
    • default-room string | null
      The room of the location or null if none is set. This will be overridden on events.unl.edu if the event has a room set.
    • default-directions string | null
      The directions of the location or null if none is set. This will be overridden on events.unl.edu if the event has a directions set.
    • default-additional-public-info string | null
      The additional public info of the location or null if none is set. This will be overridden on events.unl.edu if the event has specific location additional public info set.
    • user-id string | null
      The user UID that the location is saved to or null if none is set.
    • calendar-id string | null
      The calendar ID that the location is saved to or null if none is set.

Example Code


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

    // 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';
    }
}

Read (Standard)

GET http://events.unl.edu/api/v2/location/standard/

This endpoint is for getting a list of all the standard UNL campus locations and extension locations.

HTTP Method


GET

Authentication Requirements


None

Request Data


None

Response Data


  • Status number
    Status code for the request.
  • Message string
    Status message for the request.
  • Data Object | null
    The requested data or null on error.
    • Main Array of Location Objects
      UNL campus locations.
      • id string
        The ID of the location.
      • name string | null
        The name of the location or null if none is set.
      • address-1 string | null
        The street address of the location or null if none is set.
      • address-2 string | null
        The additional address of the location or null if none is set.
      • city string | null
        The city of the location or null if none is set.
      • state string | null
        The state of the location or null if none is set. This will always be the 2 letter abbreviation of the state.
      • zip string | null
        The zip of the location or null if none is set. This will always be ≤ 10 characters long.
      • map-url string | null
        The url of the map graphical interface of the location or null if none is set. This will always be a URL.
      • webpage string | null
        The web page of the location or null if none is set. This will always be a URL.
      • hours string | null
        The hours of the location or null if none is set.
      • phone string | null
        The phone number of the location or null if none is set.
      • default-room string | null
        The room of the location or null if none is set. This will be overridden on events.unl.edu if the event has a room set.
      • default-directions string | null
        The directions of the location or null if none is set. This will be overridden on events.unl.edu if the event has a directions set.
      • default-additional-public-info string | null
        The additional public info of the location or null if none is set. This will be overridden on events.unl.edu if the event has specific location additional public info set.
      • user-id string | null
        The user UID that the location is saved to or null if none is set.
      • calendar-id string | null
        The calendar ID that the location is saved to or null if none is set.
    • Extension Array of Location Objects
      Extension locations.
      • id string
        The ID of the location.
      • name string | null
        The name of the location or null if none is set.
      • address-1 string | null
        The street address of the location or null if none is set.
      • address-2 string | null
        The additional address of the location or null if none is set.
      • city string | null
        The city of the location or null if none is set.
      • state string | null
        The state of the location or null if none is set. This will always be the 2 letter abbreviation of the state.
      • zip string | null
        The zip of the location or null if none is set. This will always be ≤ 10 characters long.
      • map-url string | null
        The url of the map graphical interface of the location or null if none is set. This will always be a URL.
      • webpage string | null
        The web page of the location or null if none is set. This will always be a URL.
      • hours string | null
        The hours of the location or null if none is set.
      • phone string | null
        The phone number of the location or null if none is set.
      • default-room string | null
        The room of the location or null if none is set. This will be overridden on events.unl.edu if the event has a room set.
      • default-directions string | null
        The directions of the location or null if none is set. This will be overridden on events.unl.edu if the event has a directions set.
      • default-additional-public-info string | null
        The additional public info of the location or null if none is set. This will be overridden on events.unl.edu if the event has specific location additional public info set.
      • user-id string | null
        The user UID that the location is saved to or null if none is set.
      • calendar-id string | null
        The calendar ID that the location is saved to or null if none is set.

Example Code


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

    // 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/location/

This endpoint is for creating a new custom location.

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 location.
  • address-1 string Required
    The street address of the location.
  • address-2 string | null
    The additional address of the location or null if none is set.
  • city string Required
    The city of the location.
  • state string Required
    The state of the location. This will always be the 2 letter abbreviation of the state.
  • zip string Required
    The zip of the location. This will always be ≤ 10 characters long.
  • map-url string | null
    The url of the map graphical interface of the location or null if none is set. This will always be a URL.
  • webpage string | null
    The web page of the location or null if none is set. This will always be a URL.
  • hours string | null
    The hours of the location or null if none is set.
  • phone string | null
    The phone number of the location or null if none is set.
  • default-room string | null
    The room of the location or null if none is set. This will be overridden on events.unl.edu if the event has a room set.
  • default-directions string | null
    The directions of the location or null if none is set. This will be overridden on events.unl.edu if the event has a directions set.
  • default-additional-public-info string | null
    The additional public info of the location or null if none is set. This will be overridden on events.unl.edu if the event has specific location additional public info set.
  • save-user bool
    If you want this saved to your user then set this to true, otherwise it will default to false. If you do not save it to yourself or one of your calendars you will not be able to edit it in the future.
  • save-calendar bool
    If you want this saved to a calendar then set this to true, otherwise it will default to false. If you do not save it to yourself or one of your calendars you will not be able to edit it in the future.
  • calendar-id string | null
    The calendar ID that the location is saved to if the save-calendar is set.

Response Data


  • Status number
    Status code for the request.
  • Message string
    Status message for the request.
  • Data Location Object | null
    The newly created location data or null on error.
    • id string
      The ID of the location.
    • name string | null
      The name of the location or null if none is set.
    • address-1 string | null
      The street address of the location or null if none is set.
    • address-2 string | null
      The additional address of the location or null if none is set.
    • city string | null
      The city of the location or null if none is set.
    • state string | null
      The state of the location or null if none is set. This will always be the 2 letter abbreviation of the state.
    • zip string | null
      The zip of the location or null if none is set. This will always be ≤ 10 characters long.
    • map-url string | null
      The url of the map graphical interface of the location or null if none is set. This will always be a URL.
    • webpage string | null
      The web page of the location or null if none is set. This will always be a URL.
    • hours string | null
      The hours of the location or null if none is set.
    • phone string | null
      The phone number of the location or null if none is set.
    • default-room string | null
      The room of the location or null if none is set. This will be overridden on events.unl.edu if the event has a room set.
    • default-directions string | null
      The directions of the location or null if none is set. This will be overridden on events.unl.edu if the event has a directions set.
    • default-additional-public-info string | null
      The additional public info of the location or null if none is set. This will be overridden on events.unl.edu if the event has specific location additional public info set.
    • user-id string | null
      The user UID that the location is saved to or null if none is set.
    • calendar-id string | null
      The calendar ID that the location is saved to or null if none is set.

Example Code


Javascript
async function eventsAPI() {

    // Sets up data
    const data = {
        'name': 'Meeting room 1 at 1217',
        'address-1': '1217 Q St',
        'address-2': null,
        'city': 'Lincoln',
        'state': 'NE',
        'zip': '68508',
        'map-url': 'https://maps.unl.edu/L055',
        'webpage': null,
        'hours': null,
        'phone': null,
        'default-room': null,
        'default-directions': 'Head upstairs and make a right: it should be right there.',
        'default-additional-public-info': 'L055',
        'save-user': true,
        'save-calendar': true,
        'calendar-id': '3809',
    }

    // Sends request with method, headers, and data
    const response = await fetch(
        'https://events.unl.edu/api/v2/location/',
        {
            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/location/ \
-H "Content-Type: application/json" \
-H "Authentication: MY_API_TOKEN" \
-d '{
    "name": "Meeting room 1 at 1217",
    "address-1": "1217 Q St",
    "address-2": null,
    "city": "Lincoln",
    "state": "NE",
    "zip": "68508",
    "map-url": "https://maps.unl.edu/L055",
    "webpage": null,
    "hours": null,
    "phone": null,
    "default-room": null,
    "default-directions": "Head upstairs and make a right: it should be right there.",
    "default-additional-public-info": "L055",
    "save-user": true,
    "save-calendar": true,
    "calendar-id": "3809",
}'
PHP
function eventsAPI() {
    $data = array(
        'name' => 'Meeting room 1 at 1217',
        'address-1' => '1217 Q St',
        'address-2' => null,
        'city' => 'Lincoln',
        'state' => 'NE',
        'zip' => '68508',
        'map-url' => 'https://maps.unl.edu/L055',
        'webpage' => null,
        'hours' => null,
        'phone' => null,
        'default-room' => null,
        'default-directions' => 'Head upstairs and make a right: it should be right there.',
        'default-additional-public-info' => 'L055',
        'save-user' => true,
        'save-calendar' => true,
        'calendar-id' => '3809',
    );

    $jsonData = json_encode($data);

    $apiToken = 'MY_API_TOKEN';

    $url = 'https://events.unl.edu/api/v2/location/';
    $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/location/{location_id}/

This endpoint is for updating a specific 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.

  • location_id string Required Path
    The id of the location to update. This will go into the path of the request.
  • name string Required
    The name of the location.
  • address-1 string Required
    The street address of the location.
  • address-2 string | null
    The additional address of the location or null if none is set.
  • city string Required
    The city of the location.
  • state string Required
    The state of the location. This will always be the 2 letter abbreviation of the state.
  • zip string Required
    The zip of the location. This will always be ≤ 10 characters long.
  • map-url string | null
    The url of the map graphical interface of the location or null if none is set. This will always be a URL.
  • webpage string | null
    The web page of the location or null if none is set. This will always be a URL.
  • hours string | null
    The hours of the location or null if none is set.
  • phone string | null
    The phone number of the location or null if none is set.
  • default-room string | null
    The room of the location or null if none is set. This will be overridden on events.unl.edu if the event has a room set.
  • default-directions string | null
    The directions of the location or null if none is set. This will be overridden on events.unl.edu if the event has a directions set.
  • default-additional-public-info string | null
    The additional public info of the location or null if none is set. This will be overridden on events.unl.edu if the event has specific location additional public info set.
  • save-user bool
    If you want this saved to your user then set this to true, otherwise it will default to false. If this is set to false or omitted it will cause the location to be un-saved to you. If another user has the location saved to them this will do nothing.
  • save-calendar bool
    If you want this saved to a calendar then set this to true, otherwise it will default to false. If this is set to false or omitted it will cause the location to be un-saved to your calendar. If you do not have access to the calendar it is saved to this will do nothing.
  • calendar-id string | null
    The calendar ID that the location is saved to if the save-calendar is set.

Response Data


  • Status number
    Status code for the request.
  • Message string
    Status message for the request.
  • Data Location Object | null
    The newly updated location data or null on error.
    • id string
      The ID of the location.
    • name string | null
      The name of the location or null if none is set.
    • address-1 string | null
      The street address of the location or null if none is set.
    • address-2 string | null
      The additional address of the location or null if none is set.
    • city string | null
      The city of the location or null if none is set.
    • state string | null
      The state of the location or null if none is set. This will always be the 2 letter abbreviation of the state.
    • zip string | null
      The zip of the location or null if none is set. This will always be ≤ 10 characters long.
    • map-url string | null
      The url of the map graphical interface of the location or null if none is set. This will always be a URL.
    • webpage string | null
      The web page of the location or null if none is set. This will always be a URL.
    • hours string | null
      The hours of the location or null if none is set.
    • phone string | null
      The phone number of the location or null if none is set.
    • default-room string | null
      The room of the location or null if none is set. This will be overridden on events.unl.edu if the event has a room set.
    • default-directions string | null
      The directions of the location or null if none is set. This will be overridden on events.unl.edu if the event has a directions set.
    • default-additional-public-info string | null
      The additional public info of the location or null if none is set. This will be overridden on events.unl.edu if the event has specific location additional public info set.
    • user-id string | null
      The user UID that the location is saved to or null if none is set.
    • calendar-id string | null
      The calendar ID that the location is saved to or null if none is set.

Example Code


Javascript
async function eventsAPI() {

    // Sets up data
    const data = {
        'name': 'Meeting room 1 at 1217',
        'address-1': '1217 Q St',
        'address-2': null,
        'city': 'Lincoln',
        'state': 'NE',
        'zip': '68508',
        'map-url': 'https://maps.unl.edu/L055',
        'webpage': null,
        'hours': null,
        'phone': null,
        'default-room': null,
        'default-directions': 'Head upstairs and make a right: it should be right there.',
        'default-additional-public-info': 'L055',
        'save-user': true,
        'save-calendar': true,
        'calendar-id': '3809',
    }

    // Sends request with method, headers, and data
    const response = await fetch(
        'https://events.unl.edu/api/v2/location/27217/',
        {
            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/location/ \
-H "Content-Type: application/json" \
-H "Authentication: MY_API_TOKEN" \
-d '{
    "name": "Meeting room 1 at 1217",
    "address-1": "1217 Q St",
    "address-2": null,
    "city": "Lincoln",
    "state": "NE",
    "zip": "68508",
    "map-url": "https://maps.unl.edu/L055",
    "webpage": null,
    "hours": null,
    "phone": null,
    "default-room": null,
    "default-directions": "Head upstairs and make a right: it should be right there.",
    "default-additional-public-info": "L055",
    "save-user": true,
    "save-calendar": true,
    "calendar-id": "3809",
}'
PHP
function eventsAPI() {
    $data = array(
        'name' => 'Meeting room 1 at 1217',
        'address-1' => '1217 Q St',
        'address-2' => null,
        'city' => 'Lincoln',
        'state' => 'NE',
        'zip' => '68508',
        'map-url' => 'https://maps.unl.edu/L055',
        'webpage' => null,
        'hours' => null,
        'phone' => null,
        'default-room' => null,
        'default-directions' => 'Head upstairs and make a right: it should be right there.',
        'default-additional-public-info' => 'L055',
        'save-user' => true,
        'save-calendar' => false,
        'calendar-id' => '3809',
    );

    $jsonData = json_encode($data);

    $apiToken = 'MY_API_TOKEN';

    $url = 'https://events.unl.edu/api/v2/location/27217/';
    $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);
}
Contributed By: 
DXG