This page will help you get started with API ONEROSTER.

OneRoster is a standard developed by the IMS Global Learning Consortium that aims to simplify the process of exchanging student enrollment, demographic, and course information between different educational systems. It defines a set of data elements and RESTful APIs that allow for seamless integration and data exchange between various learning management systems, student information systems, and other educational applications.

📘

Collection Postman

https://gitlab.com/hub-educacional-public/docs/oneroster-api

Authentication Overview

OAuth 2.0 authentication with Client Credentials is an authorization flow that allows applications to authenticate directly with the resource server, without the need for user interaction. In this flow, client credentials are used to obtain an access token that can be used to access protected resources.

Implementation phases using Python

  1. Implement OAuth 2.0 authentication with Client Credentials(Use the credentials sent to your email: 'Client ID' and 'Client Secret')

    1. Install the 'requests' library in your project.

      pip install requests
      
    2. Import the Requests library into your Python file.

    3. Define client information, including the client ID and secret key, as global variables.

      import requests
      
      CLIENT_ID = 'client_id'
      CLIENT_SECRET = 'client_secret'
      
    4. Create a function that obtains an access token using client information and the service provider's authorization endpoint.

      def get_access_token():
          token_url = 'https://example.com/oauth/token'
          headers = {'Content-Type': 'application/x-www-form-urlencoded'}
          data = {'grant_type': 'client_credentials', 'client_id': CLIENT_ID, 'client_secret': CLIENT_SECRET}
          response = requests.post(token_url, headers=headers, data=data)
          access_token = response.json().get('access_token')
          return access_token
      
    5. Use the access token to make requests to the protected API.

      def get_protected_resource():
          access_token = get_access_token()
          headers = {'Authorization': 'Bearer ' + access_token}
          response = requests.get('https://example.com/api/protected_resource', headers=headers)
          return response.json()
      

Generating a token using Postman.

  1. Use the credentials sent to your email: 'Client ID' and 'Client Secret'.
  2. In your request, go to the 'Authorization' tab and select 'OAuth 2.0' as the type.
  3. Fill in the following information: 'Access Token URL', 'Client ID', and 'Client Secret'.
  4. Select 'Get New Access Token'.
  5. Great, your token has been successfully generated and can now be used in your requests.
  6. (Optional) Specify the scopes to generate the tokens. (Leave it empty to get all scopes)

Pagination

Pagination using limit and offset in OneRoster IMS Global

Pagination is a technique used to divide large data sets into smaller chunks, making it easier to display that data in individual pages. The use of limit and offset is a common way to implement pagination in many systems, including the OneRoster standard from IMS Global.

The limit parameter is used to set the maximum number of records that will be returned in a single query. The offset parameter is used to determine the starting position of the records that will be returned. For example, if the offset is set to 0 and the limit is set to 10, the query will return the first 10 records. If the offset is set to 10 and the limit is set to 10, the query will return records 11-20.

These parameters can be used in combination to allow navigation through the records in a series of pages. For example, if the user is on page 3 and wants to see page 4, the query would be modified to set the offset to 30 (i.e. the first 30 records will be skipped) and the limit to 10.

The use of limit and offset is a very useful technique for systems that handle large volumes of data, as it allows data to be displayed efficiently and organized for the user. The OneRoster standard from IMS Global, in particular, uses this technique to enable learning data to be managed and displayed efficiently.

fieldvalue
limit30
offset0

📘

IMS Global Reference

https://www.imsglobal.org/oneroster-v11-final-specification#_Toc480451995

Sorting

IMS Global platform provides two ways to sort data: the "sort" function and the "orderBy" function.

The "sort" function is used to sort a set of data in alphabetical or numerical order based on a single field. This function is ideal for projects that require simple and straightforward sorting of data.

On the other hand, the "orderBy" function is used to sort data based on one or more specific columns and allows defining the sorting order as ascending or descending. However, it's important to note that the "orderBy" function only accepts the values "asc" and "desc" as parameters to define the sorting order.

Both sorting functions can be used in different types of projects and are important to ensure the proper organization of data. However, it's important to understand the differences between these functions to choose the best option for each situation. The "sort" function is more suitable for simple sorting, while the "orderBy" function is more suitable for projects that require a more complex sorting based on specific criteria.

fieldvalue
sortname
orderBydesc

📘

IMS Global Reference

https://www.imsglobal.org/oneroster-v11-final-specification#_Toc480451996