Open Data Protocol

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Open Data Protocol (OData) is a RESTful data access protocol initially defined by Microsoft. Versions 1.0, 2.0, and 3.0 are released under the Microsoft Open Specification Promise. Version 4.0 was standardized at OASIS,[1] with a release in March 2014.[2]

The 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.


It is the data API for Microsoft Azure. SAP NetWeaver Gateway[3] provides OData access to SAP Business Suite and SAP Business Warehouse. IBM WebSphere eXtreme Scale REST data service can be accessed by any HTTP client using oData.[4] OData client implementations include Microsoft SharePoint 2010, WCF Data Services[5] and Windward Reports.[6]


OData is built on the AtomPub protocol and XML where the Atom structure is the envelope that contains the data returned from each OData request. An OData request uses the REST model for all requests. Each REST command is a POST, GET, PUT, PATCH, or DELETE HTTP request (mapping to CRUD) where the specifics of the command are in the URL.

  • GET: Get a collection of entities (as a feed document) or a single entity (as an entry document).
  • POST: Create a new entity from an entry document.
  • PUT: Update an existing entity with an entry document.
  • PATCH: Update an existing entity with a partial entry document.
  • DELETE: Remove an entity.

Any platform that provides support for HTTP and XML is enough to form HTTP requests to interact with AtomPub. The OData specification defines how AtomPub is used to standardize a typed, resource-oriented CRUD interface for manipulating data sources.


Fundamentally OData extends AtomPub with a data model for defining typed or untyped values on an entity (e.g. columns in a row) and adds a query language for getting just the entity and the data requested.

The following examples use the sample OData datasource located at This URI is the root URI for the data source offered via the OData protocol. All requests are extensions of this URI.


OData provides full metadata of the datasource. With a $metadata query it is possible to see the full structure of the data available from a given OData service, as well as data types, relationships, etc.

The document returned from the OData $metadata operation is defined by the “Entity Data Model for Data Services Packaging Format” specification which is a small document that says it’s the Schema element under the Edmx and DataServices elements. That Schema element and everything inside it is the “Conceptual Schema Definition File Format” specification, normally called the “CSDL spec” (or Conceptual Schema Definition Language specification). CSDL defines Microsoft’s Entity Data Model (EDM), which is also the data model of OData. The CSDL specification describes how to interpret the result of the $metadata operation to see what kind of data is being exposed by the OData service.

Partial metadata for$metadata (duplicate element types removed):

  1. <?xml version="1.0" encoding="utf-8" standalone="yes"?>
  2. <edmx:Edmx Version="1.0" xmlns:edmx="">
  3.     <edmx:DataServices xmlns:m="" m:DataServiceVersion="2.0">
  4.         <Schema Namespace="ODataDemo" xmlns:d="" xmlns:m="" xmlns="">
  5.             <EntityType Name="Product">
  6.                 <Key>
  7.                     <PropertyRef Name="ID"/>
  8.                 </Key>
  9.                 <Property Name="ID" Type="Edm.Int32" Nullable="false"/>
  10. ...
  11.                 <NavigationProperty Name="Category" Relationship="ODataDemo.Product_Category_Category_Products" FromRole="Product_Category" ToRole="Category_Products"/>
  12.                 <NavigationProperty Name="Supplier" Relationship="ODataDemo.Product_Supplier_Supplier_Products" FromRole="Product_Supplier" ToRole="Supplier_Products"/>
  13.             </EntityType>
  14.             <EntityType Name="Category">
  15. ...            
  16.             </EntityType>
  17.             <EntityType Name="Supplier">
  18.                 <Property Name="Address" Type="ODataDemo.Address" Nullable="false"/>
  19. ...                
  20.             </EntityType>
  21.             <ComplexType Name="Address">
  22.                 <Property Name="Street" Type="Edm.String" Nullable="true"/>
  23. ...                
  24.             </ComplexType>
  25.             <Association Name="Product_Category_Category_Products">
  26.                 <End Role="Product_Category" Type="ODataDemo.Product" Multiplicity="*"/>
  27.                 <End Role="Category_Products" Type="ODataDemo.Category" Multiplicity="0..1"/>
  28.             </Association>
  29. ...            
  30.             <EntityContainer Name="DemoService" m:IsDefaultEntityContainer="true">
  31.                 <EntitySet Name="Products" EntityType="ODataDemo.Product"/>
  32.                 <EntitySet Name="Categories" EntityType="ODataDemo.Category"/>
  33.                 <EntitySet Name="Suppliers" EntityType="ODataDemo.Supplier"/>
  34.                 <AssociationSet Name="Products_Category_Categories" Association="ODataDemo.Product_Category_Category_Products">
  35.                     <End Role="Product_Category" EntitySet="Products"/>
  36.                     <End Role="Category_Products" EntitySet="Categories"/>
  37.                 </AssociationSet>
  38. ...                
  39.                 <FunctionImport Name="GetProductsByRating" EntitySet="Products" ReturnType="Collection(ODataDemo.Product)" m:HttpMethod="GET">
  40.                     <Parameter Name="rating" Type="Edm.Int32" Mode="In"/>
  41.                 </FunctionImport>
  42.             </EntityContainer>
  43.         </Schema>
  44.     </edmx:DataServices>
  45. </edmx:Edmx>

CSDL defines the usual primitive types which are the same types found in .NET DbTypes enum.

CSDL defines a Navigation element references a corresponding Association, which defines the nature of the relationship between two entity types. In most cases, the important part is the multiplicity defined on both ends.

To get to the related products, follow the relative URL in the href to a feed document which can have any number of products in it.

The properties in the content element map to properties on the entity type and what types each of the properties is. If it’s not specified, the default type is Edm.String.


OData provides functionality to form URLs based on what you know (and can discover) about the underlying data. For example, you can start at the top level service document and keep drilling in.

A very simple query is which returns the first Category in the data source:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="" 
   xmlns:m="" xmlns="">
  <title type="text">Food</title>
    <name />
  <link rel="edit" title="Category" href="Categories(0)" />
  <link rel="" 
      title="Products" href="Categories(0)/Products" />
  <category term="ODataDemo.Category" scheme="" />
  <content type="application/xml">
      <d:ID m:type="Edm.Int32">0</d:ID>

You can do more than request a single dataset.You can request more (multiple datasets), less (a single value), and links to associated data.

Client libraries[edit]

There are a number of OData client libraries available to access OData:

  • Microsoft .NET Framework 3.51: the WCF Data Services framework is available as a separate download for .NET 3.x.
  • Microsoft .NET Framework 4.0: the WCF Data Services framework built into .NET 4.0.
  • Java: odata4j (including Java on an Android phone) supports the OData protocol.
  • Java: Apache Olingo is a client and server library.
  • JavaScript: datajs XMLHttpRequest object is standard in modern browsers.
  • JavaScript: JayData for higher level of abstraction (LINQ-like syntax, support for OData geo features, IndexedDB, WebSQL, integration for Kendo UI, Angular.js, Knockout.js and Sencha).
  • JavaScript: OpenUI5 library maintained by SAP
  • JavaScript (Node.js): JayData for node
  • PHP: odataphp provides OData support for PHP clients.
  • AJAX: the ASP.NET Ajax Library for getting to OData.
  • Windward provides OData connection via Microsoft Office templates in either Java or .NET
  • Reporting tool List & Label has a specialized data provider for OData.

More libraries are listed at the site.

Server libraries[edit]

There are a number of OData server libraries available to publish OData:

  • Microsoft .NET Framework 3.5.1: the WCF Data Services framework is available as a separate download for .NET 3.x.
  • Microsoft .NET Framework 4.0: the WCF Data Services framework built into .NET 4.0.
  • Java: odata4j (including Java on an Android phone) supports the OData protocol.
  • Java: Apache Olingo is a client and server library.
  • Python: Pyslet is a client and server library.

More libraries are listed at the site.



  • "Nucleon Database Manager". OData Browser which supports also NoSQL and RDBMS systems( MongoDB, Oracle, MySQL, PostgreSQL, SQLite etc.). Retrieved 2014-11-19. 

See also[edit]


External links[edit]