OData, the Open Data Protocol, is an OASIS and ISO/IEC standard that defines how to build and consume queryable RESTful APIs over HTTP using uniform URL conventions, a machine-readable metadata document and a fixed set of query options. In the landscape of APIs, it sits between free-form REST design and a full query language, giving clients a predictable way to filter, sort, page and shape data from any compliant service.
Originally developed by Microsoft and standardized as OData Version 4.0 in 2014, the protocol is widely used in enterprise software, including ERP, CRM and reporting platforms, where many clients need flexible access to large business data models without custom endpoints for every question.
How OData structures resources and requests
OData models a service as an entity data model: a set of typed entity sets, entities with keys, properties, and navigation properties that link related entities. Every entity is addressable by URL, so /Customers('ALFKI')/Orders retrieves the orders of one customer without a dedicated endpoint.
Each service publishes a service document at its root and a metadata document at /$metadata. The metadata is written in CSDL, the Common Schema Definition Language, available as XML or JSON. It describes every type, key, relationship and operation, which lets tools generate client code and lets generic clients such as spreadsheets or BI tools browse a service they have never seen before.
The following table lists the building blocks that an OData service exposes.
| Element | Purpose | Example |
|---|---|---|
| Entity set | Addressable collection of entities | /Products |
| Entity key | Identifies a single entity | /Products(42) |
| Navigation property | Follows a relationship | /Products(42)/Supplier |
| Function | Side-effect-free operation returning data | /GetTopSellers(year=2024) |
| Action | Operation that may change state | POST /Orders(7)/Cancel |
| Metadata document | Describes the full data model | /$metadata |
Standard HTTP verbs carry the usual meaning: GET reads, POST creates, PATCH updates partially, PUT replaces and DELETE removes. Responses use the JSON format defined by OData, which adds control information such as @odata.context, @odata.etag and @odata.nextLink to ordinary JSON payloads.
System query options
The defining feature of OData is its set of system query options, URL parameters prefixed with a dollar sign that let the client describe exactly which data it needs. The server translates these options into database queries, so a single entity set endpoint can answer a very wide range of questions.
| Option | Effect | Example |
|---|---|---|
| $filter | Restricts results by a boolean expression | $filter=Price lt 20 and Category eq 'Books' |
| $select | Returns only listed properties | $select=Name,Price |
| $expand | Includes related entities inline | $expand=Supplier |
| $orderby | Sorts the result | $orderby=Price desc |
| $top and $skip | Limit and offset for paging | $top=50&$skip=100 |
| $count | Adds the total number of matches | $count=true |
| $search | Free-text search where supported | $search=wireless |
| $apply | Aggregation and grouping extension | $apply=groupby((Region),aggregate(Sales with sum as Total)) |
Filter expressions support comparison operators such as eq, ne, gt and lt, logical operators, arithmetic and built-in functions like contains, startswith and year. Lambda operators any and all test conditions on collections, for example orders that contain at least one discounted line.
Paging works through server-driven paging: when a result exceeds the server limit, the response includes an @odata.nextLink URL that the client follows. This protects the service from unbounded queries even when the client does not request a page size.
OData compared with other API styles
OData is a standardized flavor of REST rather than a competitor to it, but it overlaps in purpose with GraphQL and differs sharply from RPC-style protocols. The comparison below shows where each approach fits.
| Approach | Query flexibility | Schema description | Typical fit |
|---|---|---|---|
| OData | High, through URL query options | CSDL metadata document | Enterprise data services and reporting |
| Plain REST API | Defined per endpoint by the designer | Often OpenAPI | Public APIs with fixed use cases |
| GraphQL | High, through a query document | GraphQL schema with introspection | Front ends combining many data sources |
| gRPC | Low, fixed procedures | Protocol Buffers | Internal service-to-service calls |
| JSON:API | Moderate filtering and inclusion | Conventions, no formal schema language | Consistent REST payload formats |
Compared with GraphQL, OData keeps HTTP caching and standard URLs intact and offers built-in conventions for writes, concurrency and batching. GraphQL gives front-end teams finer control over nested shapes and is more common in consumer applications, whereas OData dominates where generic tooling and interoperability across vendors matter.
Designing and consuming OData services
Most teams do not implement OData by hand. Server libraries for .NET, Java, Node.js and other platforms map the entity model to a database or ORM and translate query options into efficient SQL. Clients range from generated typed proxies to tools such as Excel and Power BI that connect directly to an OData feed.
- Publish a carefully curated entity model instead of exposing raw database tables, because the metadata becomes a public contract.
- Set server-side limits on page size,
$expanddepth and filter complexity to prevent expensive queries. - Use ETags with If-Match headers for optimistic concurrency so simultaneous updates do not overwrite each other silently.
- Group related operations with $batch requests, which bundle several calls into one HTTP round trip and can form atomic change sets.
The table below matches common integration needs with the OData feature that addresses them.
| Need | OData feature | Benefit |
|---|---|---|
| Generic reporting access | Metadata plus query options | BI tools connect without custom code |
| Incremental synchronization | Delta links and change tracking | Clients fetch only changed entities |
| Safe concurrent edits | ETags and conditional requests | Prevents lost updates |
| Fewer network round trips | $batch with change sets | Groups calls and supports atomicity |
| Business operations | Bound actions and functions | Expresses logic beyond CRUD |
Limitations and common pitfalls
The flexibility of OData carries a performance and security cost. Because clients compose arbitrary filters and expansions, a careless service can let one request trigger a full table scan or a deep join across many tables. Query validation, indexing aligned with common filters and strict limits are therefore essential.
Other pitfalls are practical. Many services implement only a subset of the specification, so a client written for one server may fail on another; checking the declared conformance level helps. Version differences also cause confusion, since OData v2 and v4 use different payload formats and some query syntax changed. Finally, exposing internal names through metadata can leak implementation details and make later refactoring a breaking change.
In plain words
OData is a shared set of rules for asking a server for data. Without it, every system invents its own way to say things like show me only cheap products or give me the next page. With OData, these requests look the same everywhere.
It works like a well-organized library catalog. You can filter, sort and pick only the details you need, and the catalog also explains how it is arranged. Because of that, many programs can read the data without special setup.
A real-world example
A mid-sized manufacturer runs its orders, inventory and invoices in an ERP system that exposes an OData v4 service. The finance team wants a weekly dashboard of overdue invoices by region, and the sales team wants open orders for its key accounts.
Instead of commissioning two custom APIs, an analyst connects a BI tool to the service URL. The tool reads $metadata, lists the available entity sets and lets the analyst build queries such as /Invoices?$filter=DueDate lt 2024-06-01 and Status eq 'Open'&$expand=Customer&$select=Number,Amount. Sales uses the same service with a different filter on customer accounts.
Both reports go live within a few days with no new backend code. The IT team only adds a page-size limit and an index on the due date column after monitoring shows that the invoice filter is the most frequent query.