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
Response Data
Example Code
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 -X GET 'https://events.unl.edu/api/v2/calendar/3809/'
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
Response Data
Example Code
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 -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, }'
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.
Response Data
Example Code
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 -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, }'
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.
Response Data
Example Code
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 -X DELETE https://events.unl.edu/api/v2/calendar/3809/ \ -H "Authentication: MY_API_TOKEN"
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); }
- Printer-friendly version
- Log in to post comments