Skill Level: 
Advanced

This API endpoint allows you read your own data.

Available Methods

Read

GET http://events.unl.edu/api/v2/me/

This endpoint is for validating you are logged in and in the events system.

HTTP Method


GET

Authentication Requirements


You must add a header to the request with the header key being Authentication and the value being your API Token. You can also pass along the cookies of the site you are on if you are on a UNL subdomain.

Request Data


None

Response Data


  • Status number
    Status code for the request.
  • Message string
    Status message for the request.
  • Data User Object | null
    The requested user or null on error.
    • uid string
      The UID of the authenticated user.

Example Code


Javascript
async function eventsAPI() {
    const response = await fetch('https://events.unl.edu/api/v2/me/', {
        'credentials': 'include'
    });
    //const response = await fetch('https://events.unl.edu/api/v2/me/', {
    //    headers: {
    //        'Authentication': MY_API_TOKEN,
    //    },
    //});
    if (response.ok) {
        const response_json = await response.json();
        console.log(response_json.data);
    }
}
CURL
curl -X GET 'https://events.unl.edu/api/v2/me/' \
-H 'Authentication: MY_API_TOKEN'
PHP
function eventsAPI() {
    $apiToken = 'MY_API_TOKEN';

    $url = 'https://events.unl.edu/api/v2/me/';
    $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_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);
}

Read (Locations)

GET http://events.unl.edu/api/v2/me/locations/

This endpoint is for getting your saved locations.

HTTP Method


GET

Authentication Requirements


You must add a header to the request with the header key being Authentication and the value being your API Token. You can also pass along the cookies of the site you are on if you are on a UNL subdomain.

Request Data


None

Response Data


  • Status number
    Status code for the request.
  • Message string
    Status message for the request.
  • Data Array of Location Objects | null
    The requested user's saved locations 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/me/locations/', {
        'credentials': 'include'
    });
    //const response = await fetch('https://events.unl.edu/api/v2/me/locations/', {
    //    headers: {
    //        'Authentication': MY_API_TOKEN,
    //    },
    //});
    if (response.ok) {
        const response_json = await response.json();
        console.log(response_json.data);
    }
}
CURL
curl -X GET 'https://events.unl.edu/api/v2/me/locations/' \
-H 'Authentication: MY_API_TOKEN'
PHP
function eventsAPI() {
    $apiToken = 'MY_API_TOKEN';

    $url = 'https://events.unl.edu/api/v2/me/locations/';
    $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_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);
}

Read (Virtual Locations)

GET http://events.unl.edu/api/v2/me/virtual-locations/

This endpoint is for getting your saved virtual locations.

HTTP Method


GET

Authentication Requirements


You must add a header to the request with the header key being Authentication and the value being your API Token. You can also pass along the cookies of the site you are on if you are on a UNL subdomain.

Request Data


None

Response Data


  • Status number
    Status code for the request.
  • Message string
    Status message for the request.
  • Data Array of Virtual Location Objects | null
    The requested user's saved virtual locations or null on error.
    • id string
      The ID of the virtual location.
    • name string
      The name of the virtual location.
    • url string
      The url of the virtual location.
    • default-additional-public-info string | null
      The additional public info of the virtual location or null if none is set. This will be overridden on events.unl.edu if the event has specific virtual location additional public info set.
    • user-id string | null
      The user UID that the virtual location is saved to or null if none is set.
    • calendar-id string | null
      The calendar ID that the virtual 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/me/virtual-locations/', {
        'credentials': 'include'
    });
    //const response = await fetch('https://events.unl.edu/api/v2/me/virtual-locations/', {
    //    headers: {
    //        'Authentication': MY_API_TOKEN,
    //    },
    //});
    if (response.ok) {
        const response_json = await response.json();
        console.log(response_json.data);
    }
}
CURL
curl -X GET 'https://events.unl.edu/api/v2/me/virtual-locations/' \
-H 'Authentication: MY_API_TOKEN'
PHP
function eventsAPI() {
    $apiToken = 'MY_API_TOKEN';

    $url = 'https://events.unl.edu/api/v2/me/virtual-locations/';
    $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_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