Skip to content
Hayden McAfee edited this page Oct 11, 2021 · 5 revisions

The OData protocol enables the creation and consumption of REST APIs, which allow resources, identified using URLs and defined in a data model, to be published and edited by Web clients using simple HTTP messages. It shares some similarity with JDBC and ODBC but OData is not limited to relational databases.

Put simply, OData allows one to write relational database-style queries in a RESTful manner. Purdue.io exposes its catalog data via an OData endpoint. It's recommended that you read up on the exposed OData Entities before continuing on this page.

Common OData Operations

$filter: Similar to an SQL where clause, this allows you to filter entities by the data contained in their properties.

$select: Similar to an SQL select clause, this allows you to perform a projection and only return a subset of the data selected.

$expand: Similar to an SQL join, this allows you to include related entities along with those you have queries.

$orderby: Similar to an SQL order by, this allows you to sort the resulting data.

OData Endpoints

There exists an OData endpoint for each OData Entity exposed by Purdue.io.

  • https://api.purdue.io/odata/Terms
  • https://api.purdue.io/odata/Subjects
  • https://api.purdue.io/odata/Courses
  • https://api.purdue.io/odata/Classes
  • https://api.purdue.io/odata/Sections
  • https://api.purdue.io/odata/Meetings
  • https://api.purdue.io/odata/Instructors
  • https://api.purdue.io/odata/Campuses
  • https://api.purdue.io/odata/Buildings
  • https://api.purdue.io/odata/Rooms

These endpoints can all be queried using the OData operations above.

Example Queries

Courses

Listing of all courses in the CS subject:
/odata/Courses?$filter=Subject/Abbreviation eq 'CS'&$orderby=Number asc

Listing of all 300 level SPAN courses:
/odata/Courses?$filter=Subject/Abbreviation eq 'SPAN' and Number ge '30000' and Number le '39999'&$orderby=Number asc

Listing of all courses with the word "Algebra" in the title:
/odata/Courses?$filter=contains(Title, 'Algebra'))

Course and all Classes, Sections, and Meetings of CS180:
/odata/Courses?$expand=Classes($expand=Sections($expand=Meetings))&$filter=Subject/Abbreviation eq 'CS' and Number eq '18000'

Classes

All classes, sections, meetings that meet in CL50 room 224:
/odata/Classes?$expand=Sections($expand=Meetings)&$filter=(Sections/any(s: s/Meetings/any(m: m/Room/Building/ShortCode eq 'CL50'))) and (Sections/any(s: s/Meetings/any(m: m/Room/Number eq '224'))))

Clone this wiki locally