Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

OData: A Standard API for Data Access

9,678 views

Published on

The Open Data Protocol, or OData for short, provides a RESTful interface for CRUD operations against data services. OData services, such as Microsoft Azure, SAP, and WebSphere expose data and metadata as typed name/value pairs in JSON or XML, allowing 'off-the-shelf' data consumers to integrate with services without custom code. This session gives an overview of OData, and explains why salesforce.com selected it as a protocol to integrate with external data services.

Published in: Software

OData: A Standard API for Data Access

  1. 1. OData A Standard API for Data Access Pat Patterson Developer Evangelist Architect, salesforce.com @metadaddy
  2. 2. Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments andcustomer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
  3. 3. Pat Patterson Developer Evangelist Architect @metadaddy
  4. 4. RESTful APIs are GREAT! $ curl -H 'X-PrettyPrint:1' -H 'Authorization: Bearer ACCESS_TOKEN' https://na1.salesforce.com/services/data/v31.0/sobjects/A ccount/001E0000002Jv2eIAC { "Id" : "001E0000002Jv2eIAC”, "Name" : "Edge Communications", "AccountNumber" : "CD451796", … }
  5. 5. BUT… • REST is a style, not a standard • RESTful, RESTlike, RESTish • URL parameters? – e.g. retrieve only a subset of properties • Retrieve a set of records via a query? •Metadata – WADL? – RAML? – Swagger?
  6. 6. Enter… OData www.odata.org “OData is a standardized protocol for creating and consuming data APIs. OData builds on core protocols like HTTP and commonly accepted methodologies like REST. The result is a uniform way to expose full-featured data APIs.”
  7. 7. OData •Proposed by Microsoft – 2009 •Standardized by OASIS – 2014
  8. 8. OData •URIs for resource identity http://services.odata.org/V4/OData/OData.svc /Products ?$filter=Rating+eq+3&$select=Rating,+Name
  9. 9. OData •HTTP transport –GET, POST, PUT/PATCH/MERGE, DELETE GET /V4/OData/OData.svc/Products(1) HTTP/1.1 Host: services.odata.org HTTP/1.1 200 OK ...
  10. 10. OData •Atom XML/JSON representation
  11. 11. OData Examples Service Document (JSON) $ curl 'http://services.odata.org/V4/OData/OData.svc/' { "@odata.context": "http://services.odata.org/V4/OData/OData.svc/$metadata", "value": [ { "kind": "EntitySet", "name": "Products", "url": "Products" }, { "kind": "EntitySet", "name": "ProductDetails", "url": "ProductDetails" }, ...
  12. 12. OData Examples Service Document (XML) $ curl 'http://services.odata.org/V4/OData/OData.svc/?$format=xml' <?xml version="1.0" encoding="utf-8"?> <service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xml:base="http://services.odata.org/V4/OData/OData.svc/" m:context="http://services.odata.org/V4/OData/OData.svc/$metadata"> <workspace> <atom:title type="text">Default</atom:title> <collection href="Products"> <atom:title type="text">Products</atom:title> </collection> <collection href="ProductDetails"> <atom:title type="text">ProductDetails</atom:title> </collection> ...
  13. 13. OData Examples Metadata (XML Only ) $ curl 'http://services.odata.org/V4/OData/OData.svc/$metadata' <?xml version="1.0" encoding="utf-8"?> <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0"> <edmx:DataServices> <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="ODataDemo"> <EntityType Name="Product"> <Key> <PropertyRef Name="ID"/> </Key> <Property Name="ID" Type="Edm.Int32" Nullable="false"/> <Property Name="Name" Type="Edm.String"/> ...
  14. 14. OData Examples Query $ curl 'http://services.odata.org/V4/OData/OData.svc/Products?$filter=Rating+eq+3&$select=Rating,+ Name' { "@odata.context": "http://services.odata.org/V4/OData/OData.svc/$metadata#Products(Rating,Name)", "value": [ { "Name": "Milk", "Rating": 3 }, { "Name": "Vint soda", "Rating": 3 }, ...
  15. 15. OData Examples Get Individual Entity $ curl 'http://services.odata.org/V4/OData/OData.svc/Products(1)' { "@odata.context": "http://services.odata.org/V4/OData/OData.svc/$metadata#Products/$entity", "ID": 1, "Name": "Milk", "Description": "Low fat milk", "ReleaseDate": "1995-10-01T00:00:00Z", "DiscontinuedDate": null, "Rating": 3, "Price": 3.5 }
  16. 16. OData Examples Update Entity $ curl -w "Status: %{http_code}n” -H 'Content-Type: application/json' -X PATCH -d '{"@odata.type":"ODataDemo.Product","Price":"2.99"}' 'http://services.odata.org/V4/OData/OData.svc/Products(1)’ Status: 204
  17. 17. Odata Adoption •Microsoft •SAP •Salesforce •IBM •RedHat
  18. 18. OData Libraries www.odata.org/libraries • Java • .Net • JavaScript • Objective-C • Python • Ruby • Node.js • PHP • C++
  19. 19. OData-Supporting Products •Microsoft SQL Server •Windows Azure Active Directory •SAP NetWeaver • IBM WebSphere •JBoss Teiid •Salesforce1 Platform Connect
  20. 20. Salesforce1 Platform Connect Demo
  21. 21. OData Summary •Standardizes data-centric web services •Exposes Data and Metadata •JSON or XML (Atom/AtomPub) representation over HTTP •Wide industry support

×