Waldo Web Service

Delivering CSUN Room Location Information

Introduction

The information is derived from the Facilities Database maintained by Admin and Finance IT. The web service provides a gateway via a REST-ful API. The information is retrieved by creating a specific URI and giving values to filter the data. The information that is returned is a JSON object that contains room location information to a particular room; the format of the JSON object is as follows:

    
{
    "success": "true",
    "status": 200,
    "api": "waldo",
    "version": "1.0",
    "collection": "rooms",
    "count": "1",
    "rooms": [
      {
        "room_number": "JD2211",
        "building_name": "Jacaranda Hall",
        "latitude": 34.24141145,
        "longitude": -118.529299945
      }
    ]
}
    

Getting Started

  1. Generate the URI
    Find the usage that fits your need. Browse through subcollections, instances and query types to help you craft your URI.
  2. Provide the Data
    Use the URI to query your data. See the Usage Example session.
  3. Show the Results

Loop through the data to display its information. See the Usage Example session.


Collections

All Rooms Listing

Subcollections

Specific Room retrieval

Code Samples

                        
//construct a function to get url and iterate over
$(document).ready(function() {
    //generate a url
    var url = 'https://www.csun.edu/web-dev/api/waldo/1.0/rooms?room=JD2211';
    //use the URL as a request
    $.ajax({
        url: url
    }).done(function(data) {
        // print the building name
        console.log(data.rooms[0].building_name);
    });
});
                        
                    

                        
//generate a url
$url = 'https://www.csun.edu/web-dev/api/waldo/1.0/rooms?room=JD2211';

//add extra necessary
$arrContextOptions = [
    "ssl" => [
        "verify_peer"=>false,
        "verify_peer_name"=>false
    ]
];

//perform the query
$data = file_get_contents($url, false, stream_context_create($arrContextOptions));

//decode the json
$data = json_decode($data, true);

//iterate over the list of data and print
echo $data['rooms'][0]['building_name'];
                        
                    

                        
#python 2
import urllib2
import json

#generate a url
url = u'https://www.csun.edu/web-dev/api/waldo/1.0/rooms?room=JD2211'

#open the url
try:
    u = urllib2.urlopen(url)
    data = u.read()
except Exception as e:
    data = {}

#load data with json object
data = json.loads(data)

#iterate over the json object and print
print data['rooms'][0]['building_name']
                        
                    

                        
require 'net/http'
require 'json'

#generate a url
source = 'https://www.csun.edu/web-dev/api/waldo/1.0/rooms?room=JD2211'

#prepare the uri
uri = URI.parse(source)

#request the data
response = Net::HTTP.get(uri)

#parse the json
data = JSON.parse(response)

#print the value
puts "#{data['rooms'][0]['building_name']}"