OData

Also known as: Open Data Protocol

On this page 7

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.

ElementPurposeExample
Entity setAddressable collection of entities/Products
Entity keyIdentifies a single entity/Products(42)
Navigation propertyFollows a relationship/Products(42)/Supplier
FunctionSide-effect-free operation returning data/GetTopSellers(year=2024)
ActionOperation that may change statePOST /Orders(7)/Cancel
Metadata documentDescribes the full data model/$metadata
Main elements of an OData service

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.

OptionEffectExample
$filterRestricts results by a boolean expression$filter=Price lt 20 and Category eq 'Books'
$selectReturns only listed properties$select=Name,Price
$expandIncludes related entities inline$expand=Supplier
$orderbySorts the result$orderby=Price desc
$top and $skipLimit and offset for paging$top=50&$skip=100
$countAdds the total number of matches$count=true
$searchFree-text search where supported$search=wireless
$applyAggregation and grouping extension$apply=groupby((Region),aggregate(Sales with sum as Total))
Common OData system query options

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.

ApproachQuery flexibilitySchema descriptionTypical fit
ODataHigh, through URL query optionsCSDL metadata documentEnterprise data services and reporting
Plain REST APIDefined per endpoint by the designerOften OpenAPIPublic APIs with fixed use cases
GraphQLHigh, through a query documentGraphQL schema with introspectionFront ends combining many data sources
gRPCLow, fixed proceduresProtocol BuffersInternal service-to-service calls
JSON:APIModerate filtering and inclusionConventions, no formal schema languageConsistent REST payload formats
OData and related API approaches

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, $expand depth 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.

NeedOData featureBenefit
Generic reporting accessMetadata plus query optionsBI tools connect without custom code
Incremental synchronizationDelta links and change trackingClients fetch only changed entities
Safe concurrent editsETags and conditional requestsPrevents lost updates
Fewer network round trips$batch with change setsGroups calls and supports atomicity
Business operationsBound actions and functionsExpresses logic beyond CRUD
OData features for typical integration needs

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.