Degrees Web Service

Delivering Degree information about CSUN Faculty

DOCUMENTATION

VERSION HISTORY

Introduction

The degrees API provides a web service as an interface for requesting information about a professor's degree and institutional background. This information is derived through CSUN's catalog. The data is generated through a RESTful API by simply appending a name value pair at the end of a URI. The web service uses HTTP requests to specific URL's and the service returns data in a form of JSON object that contains information including degree, year, and institution. An example of JSON object returned:
	
{
	appt_year: "1994",
	degrees: [
	{
		"degree": "Ph.D.",
		"year": "2008",
		"institute": "University of California Los Angeles",
	},
	{
		"degree": "M.S.",
		"year": "2003",
		"institute": "University of California Los Angeles",
	},
	{
		"degree": "B.S.",
		"year": "2000",
		"institute": "University of California Los Angeles",
	}
	]
}
	

How to use

  1. GENERATE A UNIQUE 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 constructed URI to send a query request - See the Usage Example section.
  3. SHOW THE RESULTSLoop through the returned JSON Object to display the information. - See the Usage Example section below.
Take this URI for example:
https://api.sandbox.csun.edu/metalab/degrees/api/degrees?
Append a professor's email address as the value to the key 'person':
person=nr_steven.fitzgerald@csun.edu
Use the generated URL as a query:
https://api.sandbox.csun.edu/metalab/degrees/api/degrees?person=nr_steven.fitzgerald@csun.edu
Now, take a look at the possible results of query:
Using your language of choice, you can now iterate over the JSON object and use as needed
Examples of ready to use URL's: Click to see JSON Object

Code Examples

JQuery
					        
//construct a function to get url and iterate over
$(document).ready(function() {
  //generate a url
  var url = 'https://api.sandbox.csun.edu/metalab/degrees/api/degrees/degrees?person=nr_steven.fitzgerald@csun.edu';
  //use the URL as a request
  $.ajax({
    url: url
  }).done(function(data) {
    // save the degree list
    var degreeList = data.degrees;
    //iterate over the degree list
    $(degreeList).each(function(index, degree) {
      //append each degree and institute
      $('#degree-results').append(degree.degree + ' ' + degree.institute + '
'); }); }); });
PHP
								
//generate a url
$url = 'https://api.sandbox.csun.edu/metalab/degrees/api/degrees/degrees?person=nr_steven.fitzgerald@csun.edu';

//perform the query
$data = file_get_contents($url);

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

//iterate over the list of data and print
foreach($data['degrees'] as $degree){
	echo = $degree['degree'] . ' ' . $degree['institute'].'
'; }
Python
								
#python
import urllib2
import json

#generate a url
url = u'https://api.sandbox.csun.edu/metalab/degrees/api/degrees/degrees?person=nr_steven.fitzgerald@csun.edu'

#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
for degree in data['degrees']:
  print degrees['degree'] + ' ' + degrees['institute']
								
							
Ruby
	  					        
require 'net/http'
require 'json'

#generate a url
source = 'https://api.sandbox.csun.edu/metalab/degrees/api/degrees/degrees?person=nr_steven.fitzgerald@csun.edu'

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

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

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

#print the json
degrees['degrees'].each do |degree|
  puts "#{degree['degree']} #{degree['institute']}"