Directory Web Service

Delivering contact information about CSUN entities

Introduction

The Directory web service provides contact information about CSUN entities. The web service provides a gateway to access the information via a REST-ful API. The information is retrieved by creating a specific URI and giving values to filter the data. The data is provided by CSUN Central IT. The information that is returned is a JSON object that contains contact information about a particular person, center, college, department, etc; the format of the JSON object is as follows:

		
{
  "status": "200",
  "success": "true",
  "type": "department",
  "department": {
    "department_id": "academic_departments:189",
    "college_id": "academic_groups:52",
    "entity_type": "Academic Department",
    "name": "Computer Science",
    "description": "Welcome to the fascinating world of Computer Science, boys and girls.",
    "record_status": "Active",
    "contacts": [
      {
        "contact_id": 6247,
        "entities_id": "academic_departments:189",
        "parent_entities_id": "academic_groups:52",
        "role_position": "department",
        "precedence": 0,
        "is_displayed": 1,
        "title": "Computer Science",
        "email": "compsci@csun.edu",
        "telephone": "8186773398",
        "facsimile_telephone": "8186777208",
        "website": "https://www.csun.edu/engineering-computer-science/computer-science",
        "location": "Jacaranda Hall",
        "office": "JD 4503",
        "mail_drop": "91330-8281"
      }
    ]
  }
}	      	
		
	

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 section.
  3. SHOW THE RESULTS

Collections

Examples

Retrieves information of a single entity (phasing out soon) Retrieves information of Departments Retrieves information of Colleges Retrieves Faculty Listings

Subcollections

Examples

Retrieves information of a single entity

Usage Example

						
// this example assumes jQuery integration for ease of use
// and a <div> element with the ID of "directory-results"

// query the information for computer science
var url = 'https://www.csun.edu/web-dev/api/directory/departments/189';
$(document).ready(function() {

	// perform a shorthand AJAX call to grab the information
	$.get(url, function(data) {

		// get the department information
		var department = data.department;
		$(department).each(function(index, info) {

			// append each course to the content of the element
			$('#directory-results').append('<p>' + info.name + ' ' + info.description + '</p>');

		});
		
	});

});
						
					

						
// query all the information for Computer Science
$url = ''https://www.csun.edu/web-dev/api/directory/departments/189'';

//add extra necessary options
$arrContextOptions=array(
    "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),
);

$data = file_get_contents($url, false, stream_context_create($arrContextOptions));

// encode into an array
$data = json_decode($data, true);

// print the results
print_r($data['department']['name']);
						
					

						
#python
import urllib2
import json

#query all the information for Computer Science
url = u'https://www.csun.edu/web-dev/api/directory/departments/189'

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

#decode into an array
data = json.loads(data)

#setup a blank array
directory_list = []

#loop through results and add department name
#and description subject to direcotyr_list
for info in data['department']:
	directory_list.append(info['name'] + ' ' + info['description'])

print directory_list
						
					

						
require 'net/http'
require 'json'

#query all the information for Computer Science
source = 'https://www.csun.edu/web-dev/api/directory/departments/189'

#call data
response = Net::HTTP.get_response(URI.parse(source))

#get body of the response
data = response.body

#put the parsed data
puts JSON.parse(data)