OData Queries

Hayden McAfee edited this page May 14, 2017 · 2 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.

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

Example Queries


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'


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'))))


All Sections with more than 20 students enrolled and more than 5 seats available:
/odata/Sections?$filter=Type eq 'Lecture' and Enrolled gt 20 and RemainingSpace gt 5

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.