Skip to Content
Author's profile photo Shabarish V Nair

Let’s Talk OData, Shall We? And keep it simple please!

The idea of this blog is simple. This blog is an effort to simplify OData and help beginners understand and start adopting the standard for their development needs.

When I started off with trying to break down and understand OData, I found the internet a big world to get lost in. If you are one of those, patient enough to read through precise technical details, then will be the best place to learn OData.

In this blog, I will try to summarize OData into a crash course version for those who like me come with a lazy attitude towards reading online documentation. To keep this a blog easily readable by beginners, I will try to keep the discussion of OData to 10 short sections that I personally believe is what we need to know as to get our basics clear.

Note: I will use the various references inline with the site so that it might be easier for readers to refer back to the website for further details and keep the context alive.

Lets start with

1. What is OData?

The simplest definition of OData would be that it is a standardized protocol built over existing HTTP and REST protocols supporting CRUD (Create, Read, Update, Delete) operations for creating and consuming data APIs.

Nickname: ODBC for the Web

2. Entity Data Model and an OData metadata

The metadata of an OData message can be summarized as below;


An OData metadata will contain the definition of Entity Sets and the associations. An entity set is nothing but a collection of Entity Type. An entity type can be considered as a data type that contains details of a specific type of data ex. Customer, Supplier, Sales Order, Employee etc.

You would have already figured out that an entity key is used to uniquely identify an entity type. Ex. Employee number, Sales Order number, Product ID etc

Now an association is simply the relationship between two or more entity types. A good example for association would be Products to its Manufacturer. An entity set Product can be associated with an entity set Manufacturer in an OData metadata.

A navigation property then is nothing but a property set on an entity type to understand the associations of the entity type.

3. Access an OData service

We access and OData service via an URI


4. How do I understand/access the metadata model of the above service?

Add the suffix to the service URI- $metadata


5. Lets talk details please!

If we deep dive into the OData service referred earlier, we find that there are four Entity sets i.e Four different types of data returned by the service.


Now to understand more about this, we will have to look into the metadata and see what information it reveals.

Below we see how the metadata revels the Entity type to Entity set relationship;


To understand the relation between each of the Entity sets and Entities, refer the below;


The above means that for particular item in the Products Entity set, we can refer its Category or its Supplier. Similarly for a particular Supplier in the Supplier entity set (Suppliers), we can get a Product set (Products) and for a particular Product from that set, can further extract it’s category.

In the case of Categories, for a Particular Category, we can extract a Product set (Products) related to it and further also extract the supplier for a specific product.

6. OK, enough with the pictures. Show me the real stuff now!

6.A. How do I access an Entity set?

If you want to access say the Categories entity set, use the URI –

This will return the entire Categories available with the service. You will find three Categories returned, Food, Beverages and Electronics.

6.B. How do I access a particular entity in an entity set?

You can refer the entity key in the URI to access the particular record. Ex. in the above service for a specific category, we can refer it with its ID. From the above URI, lets access only the beverages category. The id for Beverages is 1. So we can use the following URI to access that specific record;

Note: How do I know what’s the entity key?

In the metadata, for the Entity type definition, you can find the Key referenced. In the case of Category, it is the field ‘ID’.


6.C. Show me an example of the associations and navigation between Categories, Products and Suppliers.

The above link can be interpreted as finding the Supplier of Product with ID = 2 within the Categories entity set with the Category ID as 1.

7. So what are the queries I can use to manipulate the data?

The below table will document the most used and helpful queries when dealing with an OData service;

Query Description Example
$format By default you would have noticed that the data returned is in an XML feed. This query allows us to change the format of data. The example here shows how you can return all the suppliers returned by the service in JSON format instead of XML.$format=json
$top This query option helps to limit the data returned by the service. The example here shows how you can return only the 1st Category instead of all the Categories.$top=1
$skip This can be treated as the opposite of $top. The skip queries can be used to skip records. The example here shows how you can skip the first 2 records in the Products set and return the rest of products. Hence on the execution of the given query, Products with ID as 0 and 1 gets skipped.$skip=2
$inlinecount This will return the total number of records as part of the response payload. We can extract the number from the field <count></count>. If you execute the given example, in the payload you will find that in the field <count>, the value is returned as 2, meaning there are total 2 Suppliers as part of the service.$inlinecount=allpages
$orderby Use this to sort the records returned by the service. The given example shows how to sort the Product entity set by the price of each product. Here Price is a field returned as part of the Product set. On use of the query, the record set is returned with the ascending order of Price. You can use a suffix desc to return the records in the descending order.$orderby=Price$orderby=Price desc

$expand This I found to be a very helpful query to reduce the number of calls we need to make to access a particular set of data. Say, in case you want to return all the products along with their Category, use the URL provided in the example.$expand=Category
$filter This can be compared to the ‘where’ query in SQL. Lets say we want to get all the products with rating greater than 3, then use the example as defined here. Note that we can use both Logical and Arithmetic operators. There are also various functions like substring etc that is supported. Please refer this link for the extensive list that you can use.$filter=Rating gt 3


As in any SQL query, this query option can be used to Select specific or all fields of an Entity set or entity. A simple example, lets say the requirement for which is for us to return the fields rating and Price of a Product with ID = 3

Note: I found that it is not possible to use $select on Complex types. For example, the Address is a complex type in the Entity Supplier. So if we want to say, select the City and State which are the fields part of the Address structure, the $select is not supported. (Or am I struggling to use it correctly?)$select=Rating,Price

More examples,

a. Get me the three of the best rated products$top=3&$orderby=Rating desc

b. Ok! Now get me the next three best rated products.$top=3&$skip=3&$orderby=Rating desc

c. Get me the count of Products with the Price greater than or equal to 20?$inlinecount=allpages&$filter=Price ge 20

8. Instead of a browser, are there any tools I can use to play around with OData?

Yes. One simple tool is the Advanced REST Client for Chrome. There are also many other clients available online for free which help you.

9. What was all the CRUD thing about?

In case of OData, CRUD operations are defined as POST (Create), GET (Read), PUT (Update) and Delete (Delete) HTTP methods.

You can do a GET and POST request on an Entity Set while GET, PUT and DELETE can be done on an Entity.


10. This is all good but why OData instead of normal REST?

Well, you have seen how OData provides you with a consistent uniform standard way of describing the data and the data model. That precisely gives it an edge over REST. Moreover, hey SAP seems to be investing heavily on the standard. Which might mean, like it or not, you will eventually end up using OData 😉

Hope this was an enjoyable read. Please do leave a feedback or comment on anything you wish to see changed or added additionally.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Shakul Jugran
      Shakul Jugran

      Just stumbled on your blog and I'm glad I did

      Very informative post Shabarish.

      Author's profile photo VINO GANDHI MUTHUKRISHNAN

      I am a technical writer and i was looking to get a basic understanding of OData. This blog is written in simple language and is really helpful


      Author's profile photo vijay m
      vijay m

      Very Nice Blog. Explained with simple words and with sample ODATA and diagrams to understand the beginners very easily with out any difficult.

      Author's profile photo Former Member
      Former Member

      Helpful info. Thanks.

      Author's profile photo Pavan Golesar
      Pavan Golesar



      Good Guide,

      A well documented post, Good info.



      Cheers !! Keep up .


      Pavan Golesar

      Author's profile photo Gaurav Dey
      Gaurav Dey

      Really helpful doc.

      Author's profile photo Former Member
      Former Member

      Thank you Shabarish; this really helped me to understand Odata.

      Author's profile photo Former Member
      Former Member

      Thank you Shabarish!


      Really helpful doc indeed!



      Taran Narula

      Author's profile photo Helder Duarte Da Costa
      Helder Duarte Da Costa

      Great blog and indeed this feels a gap.

      There's a lot of Odata blogs, but none as nailed to simplify the concepts like you did.


      Thanks for sharing.


      Author's profile photo Former Member
      Former Member

      A great blog. Thanks for sharing!




      Author's profile photo Christopher Solomon
      Christopher Solomon

      Very nicely done!

      Author's profile photo Former Member
      Former Member

      Great Job !  Shabarish Vijayakumar

      nice blog , simple and easy  to understand  Odata.

      Author's profile photo Raghavender Poosarla
      Raghavender Poosarla

      Crisp and clear

      Author's profile photo Harsh Bhatt
      Harsh Bhatt

      Hi Shabarish,


      Kudos ! I would say I found exactly what I was looking for.

      Keep up the good work.




      Author's profile photo Arpitha Karuna
      Arpitha Karuna

      Great effort Shabarish Vijayakumar.

      Very useful and easy blog for a beginner.




      Author's profile photo Mahesh Pusala
      Mahesh Pusala

      Interesting to read and good points to start with in ODATA for beginners. Thank you Shabarish.


      Liked, Bookmarked and Following you.

      Author's profile photo Ravi Singh
      Ravi Singh

      Why don't others explain the concept in such a concise manner. Thank Shabarish!

      Author's profile photo Pfano Nemaorani
      Pfano Nemaorani

      Thanks Shabarish, This explains OData basics in short form. I will read up more on the details to get myself going.

      Author's profile photo Former Member
      Former Member

      Useful post. Thank you!

      Author's profile photo Miguel Peredo Zurcher
      Miguel Peredo Zurcher

      Hi, great post! I just published about OData and Bex queries: BEx queries and OData in BW 7.4

      Author's profile photo Christophe Schutz
      Christophe Schutz

      Great blog . Thank you.

      Author's profile photo Pramod Kumar
      Pramod Kumar

      Great read...this blog helped me to understand basic concept of OData !!!

      Author's profile photo Emanuel Affatati
      Emanuel Affatati

      This is a really good introduction to the world of OData.



      Author's profile photo Sankar Ram Subbiah
      Sankar Ram Subbiah

      A very good introduction to OData !!!

      Author's profile photo Muhammad Zafarullah
      Muhammad Zafarullah

      Good introduction to OData  for Beginner

      Author's profile photo Former Member
      Former Member


      we are  using SAP Net weavers  in desktop,i need know how connect the server using Android Application or  .Net Application how and where i can get the answer for this..reply me any guys...

      Author's profile photo Michael Appleby
      Michael Appleby

      Unless you are asking for clarification/correction of some part of the Document, please create a new Discussion marked as a Question.  The Comments section of a Blog (or Document) is not the right vehicle for asking questions as the results are not easily searchable.  Once your issue is solved, a Discussion with the solution (and marked with Correct Answer) makes the results visible to others experiencing a similar problem.  If a blog or document is related, put in a link.  Read the Getting Started documents (link at the top right) including the Rules of Engagement. 



      NOTE: Getting the link is easy enough for both the author and Blog.  Simply MouseOver the item, Right Click, and select Copy Shortcut.  Paste it into your Discussion.  You can also click on the url after pasting.  Click on the A to expand the options and select T (on the right) to Auto-Title the url.



      Thanks, Mike (Moderator)

      SAP Technology RIG

      Author's profile photo Sai Giridhar Varanasi
      Sai Giridhar Varanasi

      Well written and easy to understand. This will help us. Thanks.

      Author's profile photo vamsilakshman p
      vamsilakshman p

      Simply Superb.Nice explanation for beginners.


      Author's profile photo Narayan VK
      Narayan VK

      Great blog and style of writing! thank you

      Author's profile photo Gautam Jamang
      Gautam Jamang

      Very helpful ! Thanks for putting this blog.

      Author's profile photo Former Member
      Former Member

      good job bro given a nice information thank you for this

      if it possible can u please give some mo detailed information about the odata and sap netweaver gateway server  as  i am a beginner i just request you to provide some more information regarding this topic .


      Author's profile photo Former Member
      Former Member

      so helpfull! thanks!

      Author's profile photo Matthias Heiler
      Matthias Heiler

      Hello Shabarish,

      I just read and tested the links in the blog. Great collection of examples and valuable further link.

      There are some minor changes required as the metadata model of the odata.svc obviously had changed, since you wrote the blog.

      What also would be helpful to add to each example link the "&$format=json" as without you get rather wired and hard to read XML documents. So for example see the difference with:$filter=Rating%20gt%204&$select=Rating,Price

      Result: <?xml version="1.0" encoding="utf-8"?><feed xml:base="" xmlns="" xmlns:d="" xmlns:m="" xmlns:georss="" xmlns:gml=""><id></id><title type="text">Products</title><updated>2017-11-30T15:55:52Z</updated><link rel="self" title="Products" href="Products" /><entry><id></id><category term="ODataDemo.Product" scheme="" /><link rel="edit" title="Product" href="Products(7)" /><title type="text">DVD Player</title><summary type="text">1080P Upconversion DVD Player</summary><updated>2017-11-30T15:55:52Z</updated><author><name /></author><content type="application/xml"><m:properties><d:Rating m:type="Edm.Int16">5</d:Rating><d:Price m:type="Edm.Double">35.88</d:Price></m:properties></content></entry><entry><id></id><category term="ODataDemo.FeaturedProduct" scheme="" /><link rel="edit" title="Product" href="Products(9)/ODataDemo.FeaturedProduct" /><title type="text">Lemonade</title><summary type="text">Classic, refreshing lemonade (Single bottle)</summary><updated>2017-11-30T15:55:52Z</updated><author><name /></author><content type="application/xml"><m:properties><d:Rating m:type="Edm.Int16">7</d:Rating><d:Price m:type="Edm.Double">1.01</d:Price></m:properties></content></entry></feed>


      and (now with &$format=json)
      (if it's not displayed as shown below add for example a json Viewer to your Chrome/IE/Firefox... browser)$filter=Rating%20gt%204&$select=Rating,Price&$format=json

      / 20171130165652

      "odata.metadata": "$metadata#Products&$select=Rating,Price",
      "value": Array[2][
      "Rating": 5,
      "Price": 35.88
      "odata.type": "ODataDemo.FeaturedProduct",
      "Rating": 7,
      "Price": 1.01


      What a difference in reading and understanding an odata response 🙂

      Author's profile photo Mohammed Arshad
      Mohammed Arshad

      Very well explained..