The return value has the following information
about the user:

displayname (Full name of the user)
universityid (PUID number)
mail (user's email address)
pustatus (is the user a graduate, undergraduate, or faculty?)
department (which department the user belongs to)
eduPersonPrimaryAffiliation (whether the user is a student or faculty)
streetAddress (office number and location if it is a faculty member)
telephoneNumber (phone number if it is a faculty member)
title (name of position at Princeton if it is a faculty member)

eduPersonAffiliation (an array that shows all types of affiliation with 
the university. For example, faculty, employee, and student)

departmentNumber (number of the department in which the user belongs)

memberOf (all groups on campus that the user is a part of. For example,
Computer Science FacStaff, DuoEnabledAutomatically, or 
Office365ExchangeStandardEnabled, etc.)
'''
if __name__ == "__main__":
    req_lib = ReqLib()

    req = req_lib.getJSON(
        req_lib.configs.USERS_FULL,
        uid="rdondero",
    )
    print(req)
Пример #2
0
#!/usr/bin/env python3
from req_lib import ReqLib

if __name__ == "__main__":
    req_lib = ReqLib()
    open_places = req_lib.getJSON(
        req_lib.configs.PLACES_OPEN,
        fmt="json",
    )
    print(open_places)
    for place in open_places:
        # This will print out the information
        # of the place. Each place has the
        # following parameters:

        # name (name of the place)
        # id (unique id number of the place)
        # open (indicates whether or not the place is open. Not a boolean, is a text "yes" or "no")
        print(place)
from req_lib import ReqLib
'''
This API is pretty straightforward. This is 
the only endpoint that is within the API. It
returns a list of all of the departments within
Princeton University. Each item in the list 
is a dictionary with key "dept" whose value
is the name of the actual department.

This endpoint does not take any parameters.
'''

if __name__ == "__main__":
    req_lib = ReqLib()
    req = req_lib.getJSON(req_lib.configs.DEPARTMENT)
    print(req)
#!/usr/bin/env python3
from req_lib import ReqLib

if __name__ == "__main__":
    req_lib = ReqLib()
    term = req_lib.getJSON(
        req_lib.configs.COURSE_TERMS,
        # We want the results as a JSON
        # object, so this is necessary
        fmt="json",
    )

    # This will print the information of the
    # current term. Each term has the following
    # parameters:

    # code (The id number of the term according to the Registrar)
    # suffix (Formatted version of the term as such: TermYear [e.g. S2020, F2019, F2018, etc.])
    # name (Formatted term as such: [e.g. S19-20, F19-20, F18-19, etc.])
    # cal_name (Formatted term as such: Term Year [e.g. Spring 2020, Fall 2019, Fall 2018, etc.])
    # reg_name (Formatted term as such: Years Term [e.g. 19-20 Spr, 19-20 Fall, 18-19 Fall, etc.])
    # start_date (start date formatted YYYY-MM-DD)
    # end_date (end date formatted YYYY-MM-DD)
    print(term)
Пример #5
0
from req_lib import ReqLib
'''
This endpoint on the MobileApp API returns 
an iCal stream of dining venue open hours.
The iCal stream really is just a plain 
text stream.

Parameter: placeID


Experiment with different placeID values
to learn which placeID correspond to which
places on campus
'''

if __name__ == "__main__":
    req_lib = ReqLib()
    req = req_lib.getXMLorTXT(
        req_lib.configs.DINING_EVENTS,
        placeID=1,
    )
    print(req)
If you provide only the search parameter,
the endpoint will query all courses in the Registrar
and return all courses which match the search query.
For example, a search value of 'intro' would return 
all courses with the string 'intro' in either the
Course Title, Course Description, Professor Name,
or the Course Department Code.

If both the subject and search are provided, then 
the endpoint will return an OR of the two. That is,
a course will be returned if EITHER it matches the 
subject parameter OR the search parameter.
'''
if __name__ == "__main__":
    req_lib = ReqLib()
    spring_2020_term_code = "1204"
    subj = "COS"

    # Returns all courses in COS
    term_info = req_lib.getJSON(
        req_lib.configs.COURSE_COURSES,
        # To return a json version of the return value
        fmt="json",
        term=spring_2020_term_code,
        subject=subj,
    )
    print(term_info)

    for term in term_info["term"]:
        for subject in term["subjects"]:
Пример #7
0
This endpoint on the MobileApp API returns 
an iCal stream of dining venue open hours.
The iCal stream really is just a plain 
text stream.

Parameters: from, to

The from and to parameters are dates formatted
in the following way:

YYYYMMDD

'''

if __name__ == "__main__":
    req_lib = ReqLib()
    # Keep in mind that because "from" is a
    # keyword in the python language, we
    # can't put "from" as a parameter in
    # the following function

    # Get today's date
    today = datetime.datetime.today()
    year = str(today.year)

    # Pad the number with zeros so that
    # there are always exactly two digits
    month = str(today.month).zfill(2)
    day = str(today.day).zfill(2)

    # Get the date 2 days from now
Пример #8
0
This route returns dining locations along with 
its latitude/longitude information, payment options,
building name, etc.

some categories:

2: dining halls
3: cafes
4: vending machines
6: shows amenities of each hall on campus. 
   Printers, Mac clusters, scanners, and wheelchair
   accessibility.

Please explore the rest of the category ids in order to see
which ones may fit your application needs.

Parameter: categoryID
'''
if __name__ == "__main__":
    req_lib = ReqLib()
    # category 2 refers to all of the dining halls
    # on campus. A different number will return
    # different types of  dining locations. For
    # example, category 3 returns all of the
    # cafes on campus
    categoryID = 2
    locations = req_lib.getXMLorTXT(
        req_lib.configs.DINING_LOCATIONS,
        categoryID=categoryID,
    )
    print(locations)
Пример #9
0
from req_lib import ReqLib
import datetime
'''
This endpoint returns all users that belong
to a particular group on campus. By using
the endpoint in the file users_full.py,
you can see which groups a particular user
is a part of. The correct name of the group
will be necessary when using this endpoint.
The only parameter of this endpoint is the 
following:

name (name of the group)

In this example, we will return everyone in
the current year's undergraduate class.
'''
if __name__ == "__main__":
    req_lib = ReqLib()
    today = datetime.datetime.today()
    year = str(today.year)

    req = req_lib.getJSON(
        req_lib.configs.GROUPS,
        name="Undergraduate Class of " + year,
    )
    print(req)
#!/usr/bin/env python3
from req_lib import ReqLib
import datetime
'''
Parameters: locationID, menuID
'''
if __name__ == "__main__":
    req_lib = ReqLib()
    # Get today's date
    today = datetime.datetime.today()
    year = str(today.year)

    # Pad the number with zeros so that
    # there are always exactly two digits
    month = str(today.month).zfill(2)
    day = str(today.day).zfill(2)

    possible_meals = ["Breakfast", "Lunch", "Dinner"]

    # Let's choose Lunch
    meal = possible_meals[1]

    menu = req_lib.getJSON(
        req_lib.configs.DINING_MENU,
        locationID=2,
        menuID=year + "-" + month + "-" + day + "-" + meal,
    )
    print(menu)

    for t in menu:
        for menu_item in menu[t]: