Degrees Web Service

Delivering Degree information about CSUN Faculty

Introduction

The Degrees web service 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://www.csun.edu/web-dev/api/degrees/degrees?
Append a professor's email address as the value to the key 'person':
person=steven.fitzgerald@csun.edu
Use the generated URL as a query:
https://www.csun.edu/web-dev/api/degrees/degrees?person=steven.fitzgerald@csun.edu
Examples of ready to use URL's: Click to see JSON Object

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/degrees/degrees/degrees?person=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 + '<br>');
        });
    });
});
                        
                    

                        
//generate a url
$url = 'https://www.csun.edu/web-dev/api/degrees/degrees/degrees?person=steven.fitzgerald@csun.edu';

//add extra necessary options
$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
foreach($data['degrees'] as $degree){
    echo = $degree['degree'] . ' ' . $degree['institute'].'<br>';
}
                        
                    

                        
#python
import urllib2
import json

#generate a url
url = u'https://www.csun.edu/web-dev/api/degrees/degrees/degrees?person=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']
                        
                    

                        
require 'net/http'
require 'json'

#generate a url
source = 'https://www.csun.edu/web-dev/api/degrees/degrees/degrees?person=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']}"