Click here to Skip to main content
15,845,436 members
Articles / Programming Languages / XML

An overview of Open Data Protocol (OData)

Rate me:
Please Sign up or sign in to vote.
4.35/5 (18 votes)
28 Jun 2010Ms-PL4 min read 85.6K   27   10
Overview of the OData protocol: what it is, how it works, and where it makes sense to use it.


In this article, I want to give an overview of the OData protocol: what it is, how it works, where it make sense to use it.


Open Data Protocol (or OData, is an open protocol for sharing data. It is built upon AtomPub (RFC 5023), itself an extension of Atom Publishing Protocol (RFC 4287). OData is a REST (Representational State Transfer) protocol; therefore a simple web browser can view the data exposed through an OData service. OData specs are under Microsoft Open Specification Promise (OSP).

The basic idea behind OData is to use a well known data format (Atom feed) to expose a list of entities. AtomPub extends the basic Atom Protocol by allowing not only read but the whole set of CRUD operations. OData extends AtomPub by enabling simple queries over feeds. OData also typically exposes a collection of entity sets with a higher-level grouping feed where you see all the feeds available.


To illustrate those concepts, let's look at the OData website ( It exposes its data with an OData service: You can simply browse that page and it will return you an XML document listing the different entity sets available:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<service xml:base="" 
  <collection href="ODataConsumers">
  <collection href="ODataProducerApplications">
  <collection href="ODataProducerLiveServices">

This list of entity sets (or feeds) is called a workspace in OData.

Now, let's look at one of those feeds, for instance, the data consumers (ODataConsumers). The collection has an href XML attribute indicating how to build the URL to get to it: This URL also returns an XML document, an Atom feed.

Now, if you look at it in Internet Explorer, you'll view it in a feed reader view. To be able to view the raw XML, you must go to your Internet Options, in the Content tab:


At the bottom, press the Settings button under the Feeds and Web Slices section. In the Settings screen, make sure to turn off feed reading view.


You'll probably need to re-open the browser or at least the tab to view the raw XML.

Now, if we look at the XML, it's a standard Atom feed: it has a title, an ID, a time when it was updated, and a bunch of entries. The entries are the actual data. If we look at an entry:

  <title type="text">OData Explorer</title>
  <summary type="text">A Silverlight application that can browse OData Services. 
     It is available as part of the OData SDK Code Samples, and is available 
     online at</summary>
    <name />
  <link rel="edit" title="ODataConsumer" href="ODataConsumers(2)" />
  <category term="ODataServices.ODataConsumer" 
    scheme="" />
  <content type="application/xml">
      <d:Id m:type="Edm.Int32">2</d:Id>
      <d:Name>OData Explorer</d:Name>
      <d:Description>A Silverlight application 
        that can browse OData Services. It is available as part 
        of the OData SDK Code Samples, and is available online 

The entry contains an ID and a few other properties, most importantly, content. Now the content contains standard EDM data (Entity Data Model). Typically, the content properties are the same for each entry so you can display the data in a tabular format.


Now an entity set feed gives you access to the entire entity set. OData allows you to query the entity set through the feed, by manipulating the URL.

For instance, let's say we would just like to retrieve the first three entries of the feed; we would query the following URL:$top=3. We basically apply a top operator on the data consumers URL. Here is a non-comprehensive list of things we could do to query the feed differently:

Query StringDescriptionExample
$skip=<n>Skips the n first elements of the feed.Browse...
$orderby=<property-name>Orders the results by a given property.Browse...
$filter=<filter expression>Filters the feed given a filter expression.Browse...

For a comprehensive list of the different query string options, see The OData query system is quite powerful, although not as powerful as SQL.

A good tool to get familiar with the different ways to query an OData service is available at It is a free Silverlight application allowing you to query an OData service and showing the results in a tabular format.


OData isn't only about querying. It enables CRUD operations. Those are performed by using different HTTP verbs (GET for reading, PUT for creating, POST for updating, and DELETE for deleting).


By default, an OData service returns Atom XML format. It also supports JSON. In order to receive a JSON representation, this must be encoded in the HTTP header. See operations#RepresentationFormatsAndContentTypeNegotiation for more details.

When to use OData

Why would you want to use OData instead of your own XML format (e.g., SOAP based)? In general, OData is a standard, it is therefore understood by an increasing number of clients. Specifically, it is understood by the .NET Framework: you can do LINQ queries to an OData service from client code. It is also understood by Microsoft Excel 2010 (for Pivot Table).

OData therefore acts as an ubiquitous data format for lists. It is less ubiquitous than a SQL or ODBC source, but it allows more flexibility in how the data is stored and presented.

An especially useful scenario for me is a replacement of the classic Get<EntityName>By<Criteria> Web Services. We've all seen those GetAllEmployees, GetEmployeeByID, GetEmployeesByDepartment, and so forth. The implementation of those services is boring, and you eventually need to add new web methods for new criteria (this means a lot of code duplication, hence maintenance problems). OData would allow the client to dictate the criteria. You write the service once and many clients can use it differently.


This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Written By
Architect CGI
Canada Canada
Vincent-Philippe is a Senior Solution Architect working in Montreal (Quebec, Canada).

His main interests are Windows Azure, .NET Enterprise suite (e.g. SharePoint 2013, Biztalk Server 2010) & the new .NET 4.5 platforms.

Comments and Discussions

QuestionODATA vs ODBC - which one performs better? Pin
Krishna G13-Jul-16 18:24
Krishna G13-Jul-16 18:24 
GeneralThanks Pin
Dishant Verma2-May-15 19:42
Dishant Verma2-May-15 19:42 
QuestionMy Vote of 5..!! Pin
Harsh Gandhi14-May-13 4:41
Harsh Gandhi14-May-13 4:41 
GeneralMy vote of 2 Pin
Mister_Mitbewohner28-Nov-12 22:35
Mister_Mitbewohner28-Nov-12 22:35 
GeneralMy vote of 3 Pin
eferreyra28-Nov-12 7:19
eferreyra28-Nov-12 7:19 
GeneralMy vote of 5 Pin
dev0927-Jun-12 5:24
dev0927-Jun-12 5:24 
GeneralMy vote of 5 Pin
Farhan Ghumra20-Jun-12 21:30
professionalFarhan Ghumra20-Jun-12 21:30 
GeneralExcellent Article Pin
VinceJS4-Apr-11 10:57
VinceJS4-Apr-11 10:57 
GeneralMy vote of 3 Pin
AbhishekTiwari6-Jul-10 0:10
AbhishekTiwari6-Jul-10 0:10 
GeneralMy vote of 2 Pin
deostroll28-Jun-10 19:12
deostroll28-Jun-10 19:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.