OData: A Standard API for Data Access

22
OData A Standard API for Data Access Pat Patterson Developer Evangelist Architect, salesforce.com @metadaddy

description

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.

Transcript of OData: A Standard API for Data Access

Page 1: OData: A Standard API for Data Access

ODataA Standard API for Data Access

Pat Patterson

Developer Evangelist Architect, salesforce.com

@metadaddy

Page 2: OData: A Standard API for Data Access

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 and customer 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.

Page 3: OData: A Standard API for Data Access

Pat PattersonDeveloper Evangelist Architect

@metadaddy

Page 4: OData: A Standard API for Data Access

RESTful APIs are GREAT!

$ curl -H 'X-PrettyPrint:1' \-H 'Authorization: Bearer ACCESS_TOKEN' \https://na1.salesforce.com/services/data/v31.0/sobjects/Account/001E0000002Jv2eIAC{ "Id" : "001E0000002Jv2eIAC”, "Name" : "Edge Communications", "AccountNumber" : "CD451796", …}

Page 5: OData: A Standard API for Data Access

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?

Page 6: OData: A Standard API for Data Access

Enter… ODatawww.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.”

Page 7: OData: A Standard API for Data Access

OData

• Proposed by Microsoft– 2009

• Standardized by OASIS– 2014

Page 8: OData: A Standard API for Data Access

OData

• URIs for resource identity

http://services.odata.org/V4/OData/OData.svc/Products

?$filter=Rating+eq+3&$select=Rating,+Name

Page 9: OData: A Standard API for Data Access

OData

• HTTP transport– GET, POST, PUT/PATCH/MERGE, DELETE

GET /V4/OData/OData.svc/Products(1) HTTP/1.1Host: services.odata.org HTTP/1.1 200 OK...

Page 10: OData: A Standard API for Data Access

OData

• Atom XML/JSON representation

Page 11: OData: A Standard API for Data Access

OData ExamplesService 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" }, ...

Page 12: OData: A Standard API for Data Access

OData ExamplesService 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> ...

Page 13: OData: A Standard API for Data Access

OData ExamplesMetadata (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"/> ...

Page 14: OData: A Standard API for Data Access

OData ExamplesQuery

$ 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 }, ...

Page 15: OData: A Standard API for Data Access

OData ExamplesGet 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}

Page 16: OData: A Standard API for Data Access

OData ExamplesUpdate 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

Page 17: OData: A Standard API for Data Access

Odata Adoption

•Microsoft•SAP•Salesforce•IBM•RedHat

Page 18: OData: A Standard API for Data Access

OData Librarieswww.odata.org/libraries

• Java• .Net• JavaScript• Objective-C• Python• Ruby• Node.js• PHP• C++

Page 19: OData: A Standard API for Data Access

OData-Supporting Products

•Microsoft SQL Server•Windows Azure Active Directory•SAP NetWeaver• IBM WebSphere•JBoss Teiid•Salesforce1 Platform Connect

Page 20: OData: A Standard API for Data Access

Salesforce1 Platform Connect Demo

Page 21: OData: A Standard API for Data Access

OData Summary

•Standardizes data-centric web services•Exposes Data and Metadata•JSON or XML (Atom/AtomPub) representation over HTTP•Wide industry support

Page 22: OData: A Standard API for Data Access