Open Data Protocol

From Wikipedia, the free encyclopedia
  (Redirected from OData)
Jump to: navigation, search

Open Data Protocol (OData) is an open protocol to allow the creation and consumption of queryable and interoperable RESTful APIs in a simple and standard way. It was initiated by Microsoft in 2007.[1] Versions 1.0, 2.0, and 3.0 are released under the Microsoft Open Specification Promise. Version 4.0 was standardized at OASIS,[2] with a release in March 2014.[3] In April 2015, OASIS has further Submitted OData v4 and OData JSON Format v4 to ISO/IEC JTC 1 for approval as an International Standard.[4]

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.

Standardization[edit]

OData is currently a protocol standardized at the OASIS OData Technical Committee (TC).

OASIS OData Technical Committee[edit]

"The OASIS OData TC works to simplify the querying and sharing of data across disparate applications and multiple stakeholders for re-use in the enterprise, Cloud, and mobile devices. A REST-based protocol, OData builds on HTTP, AtomPub, and JSON using URIs to address and access data feed resources. It enables information to be accessed from a variety of sources including (but not limited to) relational databases, file systems, content management systems, and traditional Web sites. OData provides a way to break down data silos and increase the shared value of data by creating an ecosystem in which data consumers can interoperate with data producers in a way that is far more powerful than currently possible, enabling more applications to make sense of a broader set of data. Every producer and consumer of data that participates in this ecosystem increases its overall value."[5]

TC Participants[edit]

OData OASIS Standards[edit]

Committee Specifications[edit]

Committee Notes[edit]

Architecture[edit]

OData is a protocol about the creation and consumption of RESTful APIs. Thus, as common practices of REST, OData builds on HTTP, AtomPub, and JSON using URIs to address and access data feed resources.

Resource identification[edit]

OData uses URIs to identify resources. For every OData service whose service root is abbreviated as http://host/service/, the following fixed resources can be found:

The service document[edit]

The service document lists entity sets, functions, and singletons that can be retrieved. Clients can use the service document to navigate the model in a hypermedia-driven fashion.

The service document is available at http://host/service/.

The metadata document[edit]

The metadata document describes the types, sets, functions and actions understood by the OData service. Clients can use the metadata document to understand how to query and interact with entities in the service.

The metadata document is available at http://host/service/$metadata.

Dynamic resources[edit]

The URIs for the dynamic resources may be computed from the hypermedia information in the service document and metadata document.

Resource operation[edit]

OData leverages the HTTP verbs to indicate the operations on the resources.

  • GET: Get the resource (a collection of entities, a single entity, a structural property, a navigation property, a stream, etc.).
  • POST: Create a new resource.
  • PUT: Update an existing resource by replacing it with a complete instance.
  • PATCH: Update an existing resource by replacing part of it's properties with a partial instance.
  • DELETE: Remove the resource.

Resource representation[edit]

OData uses different formats for representing data and the data model. In OData protocol version 4.0, JSON format is the standard for representing data, with the Atom format still being in committee specification stage. For representing the data model, the Common Schema Definition Language (CSDL) which defines an XML representation of the entity data model exposed by OData services is used.

A sample OData JSON data payload[edit]

A collection of products:

 1 {
 2   "@odata.context": "http://services.odata.org/V4/OData/OData.svc/$metadata#Products",
 3   "value": [
 4     {
 5       "ID": 0,
 6       "Name": "Bread",
 7       "Description": "Whole grain bread",
 8       "ReleaseDate": "1992-01-01T00:00:00Z",
 9       "DiscontinuedDate": null,
10       "Rating": 4,
11       "Price": 2.5
12     },
13     {
14       "ID": 1,
15       "Name": "Milk",
16       "Description": "Low fat milk",
17       "ReleaseDate": "1995-10-01T00:00:00Z",
18       "DiscontinuedDate": null,
19       "Rating": 3,
20       "Price": 3.5
21     },
22     ...
23   ]
24 }

A sample OData Atom data payload[edit]

A collection of products:

 1 <feed xml:base="http://services.odata.org/V4/OData/OData.svc/" m:context="http://services.odata.org/V4/OData/OData.svc/$metadata#Products" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
 2   <id>http://services.odata.org/v4/odata/odata.svc/Products</id>
 3   <title type="text">Products</title>
 4   <updated>2015-05-19T03:38:50Z</updated>
 5   <link rel="self" title="Products" href="Products"/>
 6   <entry>
 7     <id>http://services.odata.org/V4/OData/OData.svc/Products(0)</id>
 8     <category term="#ODataDemo.Product" scheme="http://docs.oasis-open.org/odata/ns/scheme"/>
 9     <link rel="edit" title="Product" href="Products(0)"/>
10     <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Categories" type="application/xml" title="Categories" href="Products(0)/Categories/$ref"/>
11     <link rel="http://docs.oasis-open.org/odata/ns/related/Categories" type="application/atom+xml;type=feed" title="Categories" href="Products(0)/Categories"/>
12     <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier" type="application/xml" title="Supplier" href="Products(0)/Supplier/$ref"/>
13     <link rel="http://docs.oasis-open.org/odata/ns/related/Supplier" type="application/atom+xml;type=entry" title="Supplier" href="Products(0)/Supplier"/>
14     <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/ProductDetail" type="application/xml" title="ProductDetail" href="Products(0)/ProductDetail/$ref"/>
15     <link rel="http://docs.oasis-open.org/odata/ns/related/ProductDetail" type="application/atom+xml;type=entry" title="ProductDetail" href="Products(0)/ProductDetail"/>
16     <title/>
17     <updated>2015-05-19T03:38:50Z</updated>
18     <author>
19       <name/>
20     </author>
21     <content type="application/xml">
22       <m:properties>
23         <d:ID m:type="Int32">0</d:ID>
24         <d:Name>Bread</d:Name>
25         <d:Description>Whole grain bread</d:Description>
26         <d:ReleaseDate m:type="DateTimeOffset">1992-01-01T00:00:00Z</d:ReleaseDate>
27         <d:DiscontinuedDate m:null="true"/>
28         <d:Rating m:type="Int16">4</d:Rating>
29         <d:Price m:type="Double">2.5</d:Price>
30       </m:properties>
31     </content>
32   </entry>
33   <entry>
34     <id>http://services.odata.org/V4/OData/OData.svc/Products(1)</id>
35     <category term="#ODataDemo.Product" scheme="http://docs.oasis-open.org/odata/ns/scheme"/>
36     <link rel="edit" title="Product" href="Products(1)"/>
37     <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Categories" type="application/xml" title="Categories" href="Products(1)/Categories/$ref"/>
38     <link rel="http://docs.oasis-open.org/odata/ns/related/Categories" type="application/atom+xml;type=feed" title="Categories" href="Products(1)/Categories"/>
39     <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Supplier" type="application/xml" title="Supplier" href="Products(1)/Supplier/$ref"/>
40     <link rel="http://docs.oasis-open.org/odata/ns/related/Supplier" type="application/atom+xml;type=entry" title="Supplier" href="Products(1)/Supplier"/>
41     <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/ProductDetail" type="application/xml" title="ProductDetail" href="Products(1)/ProductDetail/$ref"/>
42     <link rel="http://docs.oasis-open.org/odata/ns/related/ProductDetail" type="application/atom+xml;type=entry" title="ProductDetail" href="Products(1)/ProductDetail"/>
43     <title/>
44     <updated>2015-05-19T03:38:50Z</updated>
45     <author>
46       <name/>
47     </author>
48     <content type="application/xml">
49       <m:properties>
50         <d:ID m:type="Int32">1</d:ID>
51         <d:Name>Milk</d:Name>
52         <d:Description>Low fat milk</d:Description>
53         <d:ReleaseDate m:type="DateTimeOffset">1995-10-01T00:00:00Z</d:ReleaseDate>
54         <d:DiscontinuedDate m:null="true"/>
55         <d:Rating m:type="Int16">3</d:Rating>
56         <d:Price m:type="Double">3.5</d:Price>
57       </m:properties>
58     </content>
59   </entry>
60   ...
61 </feed>

A sample OData metadata document[edit]

 1 <edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
 2   <edmx:DataServices>
 3     <Schema Namespace="ODataDemo" xmlns="http://docs.oasis-open.org/odata/ns/edm">
 4       <EntityType Name="Product">
 5         <Key>
 6           <PropertyRef Name="ID"/>
 7         </Key>
 8         <Property Name="ID" Type="Edm.Int32" Nullable="false"/>
 9         <Property Name="Name" Type="Edm.String"/>
10         <Property Name="Description" Type="Edm.String"/>
11         <Property Name="ReleaseDate" Type="Edm.DateTimeOffset" Nullable="false"/>
12         <Property Name="DiscontinuedDate" Type="Edm.DateTimeOffset"/>
13         <Property Name="Rating" Type="Edm.Int16" Nullable="false"/>
14         <Property Name="Price" Type="Edm.Double" Nullable="false"/>
15       </EntityType>
16 
17       <ComplexType Name="Address">
18         <Property Name="Street" Type="Edm.String"/>
19         <Property Name="City" Type="Edm.String"/>
20         <Property Name="State" Type="Edm.String"/>
21         <Property Name="ZipCode" Type="Edm.String"/>
22         <Property Name="Country" Type="Edm.String"/>
23       </ComplexType>
24       
25       <EntityContainer Name="DemoService">
26         <EntitySet Name="Products" EntityType="ODataDemo.Product"></EntitySet>
27       </EntityContainer>
28     </Schema>
29   </edmx:DataServices>
30 </edmx:Edmx>

Ecosystem[edit]

The ecosystem of OData consists of the client/server libraries that implements the protocol, and applications that is based on the protocol.

Libraries[edit]

There are a number of OData libraries available to access/produce OData APIs:

.NET[edit]

Java[edit]

JavaScript[edit]

  • Client: Apache Olingo
  • Client: data.js
  • Client: 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).
  • Client: OpenUI5 library maintained by SAP
  • Client (Node.js): JayData for node

Others[edit]

  • 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 OData.org site.

For more libraries, visit the community site http://www.odata.org/libraries/.

Applications[edit]

For more applications, visit the community site http://www.odata.org/ecosystem/.

Community[edit]

The community website of OData is http://www.odata.org. It's a Jekyll instance open sourced at https://github.com/ODataOrg/odataorg.github.io. The current organization of the website is as follows:

See also[edit]

References[edit]

External links[edit]