RosterServer: Python


Exciting News!

Our transition to a new website is complete. Click here to seamlessly access the latest version of this article.

Kindly update any bookmarked URLs accordingly. The Development Center will no longer be accessible after April 1, 2024. Thank you for your attention to this matter.



Click here to go to GitHub


Insert into your project and install the requests module.


First, import OneRoster.

from oneroster import OneRoster

Then, create a new instance of the OneRoster object, which takes in two strings,
the client_id and client_secret.


You are now able to make requests to a specified URL. This is done using the method make_roster_request(url), which takes in the URL and returns a dictionary.

response = oneRoster.make_roster_request("")

The response is made up of "status_code", which contains the status code, and "response", which contains the JSON response as a string.

print(response["status_code"]); // The status code
print(response["response"]); // The JSON response




Print all students' names

import json

# Import OneRoster
from oneroster import OneRoster

def get_users(url):
    # Create new OneRoster with the client_id and client_secret

    # Make the request to the given url and store the dictionary with status_code and response
    response = oneRoster.make_roster_request(url)

    # Decode the response
    decoded = json.loads(response["response"])

    # If status_code is 200, create array of users from response, otherwise print message and return None
    if response["status_code"] == 200:
        return decoded["users"]
    elif response["status_code"] == 401:
        print("Unauthorized Request\n" + response["response"])
    elif response["status_code"] == 404:
        print("Not Found\n" + response["response"])
    elif response["status_code"] == 500:
        print("Server Error\n" + response["response"])
        print("Something Went Wrong, status code " + response["status_code"]
              + "\n" + response["response"])
    return None

users = get_users("'student'")
if users is not None:
    for user in users:
        print(user["givenName"] + " " + user["familyName"])