Post on 02-Jul-2015
description
OData and Impact on API Design
With
Brian Pagano
@brianpagano
Greg Brail
@gbrail
Anant Jhingran
@jhingran
groups.google.com/group/api-craft
youtube.com/apigee
slideshare.net/apigee
Introductions OData Primer API Design The OData Community Conclusions
@gbrail@brianpagano@jhingran
Interactions are shifting to edge of enterprise
Business
Networks
Social
Networks
Apps
Your
Company
Your
Web Site
Your Store
Your apps
Your Data
APIs
What the means is that
you’ve think about “data” –
what you expose, and what
you collect “differently”
- API-centric
Exposing data attracts business to the core even if data is not your core business
http://blog.apigee.com/detail/api_strategy_talk_web_2.0/
See Amundsen’s Dogs, Information Halos and APIs: The epic story of your API Strategy »
Exposing Data is more than the “R” of CRUD in REST
M(E/A)SS OF
INTERCONNECTED DATA
GOOD CLEAN API’S
How do you go from the m(e/a)ss to clean APIs?
Two schools of thought
Table1 Table2
1 N
REST APIS
“Schema-ed” Relational or
Relational-like view of “data”
REST APIS
“Linked Data” view – individual
objects, with properties and
interconnections
Today we’ll discuss the “Schema-ed” view of the world, and in particular, the OData approach
1 N
REST APIS
Let’s look at OData requests and responses.
SQL Query OData Request
select * from products where id = 1 /Products(1)
select * from productswhere name = ‘Milk’
/Products?$filter=name eq ‘Milk’
select name from products /Products?$select=name
select * from products order by name /Products?$orderby=name
select * from products offset 10 limit 10 /Products?$top=10&$skip=10
select * from prices r, products p where r.id = p.id
/Products(1)?$expand=Prices
OData by Example
(* sort of)
/Categories?$filter=Name eq ‘Dairy’
Filters
Logical Operators
eq ne gt ge lt le eq or and
Arithmetic Operators
add sub mul div mod
Parenthesis Operator
()
Canonical Functions
substrof endswith startswith
length indexof replace substring tolower
toupper trim concat year years month day
days hour hours minute minutes second
seconds round floor ceiling isof cast
atom json xml
(plus any other IANA-defined media types)
*If the $format query option is present in a request URI it takes precedence over the value(s) specified in the Accept request header.
Format
/Categories?$format=json *
Metadata
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
m:DataServiceVersion="1.0">
<Schema Namespace="NorthwindModel"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityType Name="Category">
<Key>
<PropertyRef Name="CategoryID" />
</Key>
<Property Name="CategoryID" Type="Edm.Int32" Nullable="false"
p8:StoreGeneratedPattern="Identity"
xmlns:p8="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
<Property Name="CategoryName" Type="Edm.String" Nullable="false"
MaxLength="15" Unicode="true" FixedLength="false" />
<Property Name="Description" Type="Edm.String" Nullable="true" MaxLength="Max"
Unicode="true" FixedLength="false" />
</EntityType>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Libraries
from http://www.odata.org/libraries
WTF is WCF?
Who is using OData?
Who created OData?
How does OData compare to other approaches?
Odata Request Web API Style
/Products(1) /Products/1
/Products?$filter=name eq ‘Milk’ /Products?name=Milk
/Products/1?$select=name /Products/1/name
/Products?$orderby=name /Products?orderby=name
/Products?$top=10&$skip=10 /Products?offset=10&limit=10
/Products(1)?$expand=Prices /Products/1?expand=Prices
OData or Not?
OData GData SOAP Observed API Patterns on the Web
How active is community support for OData?
Is it time to rally around a standard like OData?
Or is too early?
Should one implement OData?
Questions
THANK YOU
Greg Brail
@gbrail
Anant Jhingran
@jhingran
Brian Pagano
@brianpagano
Questions and ideas to:
groups.google.com/group/api-craft