Top Banner
API Façade: Common Patterns Episode 2 Webinar Shorts March 2012 Series Brian Mulloy @landlessness Apigee @apigee
49

The API Facade Pattern: Common Patterns - Episode 2

Aug 20, 2015

Download

Technology

Apigee
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: The API Facade Pattern: Common Patterns - Episode 2

API Façade: Common Patterns

Episode 2Webinar ShortsMarch 2012 Series

Brian Mulloy@landlessness

Apigee@apigee

Page 2: The API Facade Pattern: Common Patterns - Episode 2

groups.google.com/group/api-craft

Page 3: The API Facade Pattern: Common Patterns - Episode 2

youtube.com/apigee

Page 4: The API Facade Pattern: Common Patterns - Episode 2

IRC Channel#api-crafton freenode

New!

Page 5: The API Facade Pattern: Common Patterns - Episode 2

Episode 1The API Facade: OverviewTuesday, March 6th

Episode 2The API Facade: Common PatternsTuesday, March 13th

Episode 3The API Facade: TechnologyTuesday, March 20th

Episode 4The API Facade: PeopleTuesday, March 27th

Webinar Shorts - March 2012 New!

Page 6: The API Facade Pattern: Common Patterns - Episode 2

Episode 2 Topics

• Recap: API façade• Errors• Stubs• URLs• Versioning• Data formats• Internal & external systems

Page 7: The API Facade Pattern: Common Patterns - Episode 2

Recap: API Façade

Page 8: The API Facade Pattern: Common Patterns - Episode 2

Big System

DBContent

Management SOAP JDBC RSS

API Facade

AppApp

Developer

Page 9: The API Facade Pattern: Common Patterns - Episode 2

RSSObjects

XML

App

1. Build up from systems of record

1.

Big System

DBContent

Management SOAP JDBC RSS

Tables

XML

RSS

XMLXML

Tables

XML

RSS

XML

One Big Problem

Page 10: The API Facade Pattern: Common Patterns - Episode 2

1. Design the Ideal API2. Implement Design with Stubs as Façade3. Mediate between Façade and SystemsApp

Developer

Mediate

API Facade

1.

2.

3.

Big System

DBContent

Management SOAP JDBC RSS

Ideal Design

Three Small Problems

Page 11: The API Facade Pattern: Common Patterns - Episode 2

Common patterns

Page 12: The API Facade Pattern: Common Patterns - Episode 2

Errors

Page 13: The API Facade Pattern: Common Patterns - Episode 2

When I say errors, you say test-driven development.

Page 14: The API Facade Pattern: Common Patterns - Episode 2

API Facade

Errors

Request Response

nothing to see here

200 201 304 400 401 403 404 500

{“developerMessage”:“Verbose, plain language description of the problem for the app developer with hints about how to fix it.”,“userMessage”:“Pass this message on to the app user, if needed.”,"errorCode":12345, ”status":401,“moreInfo”:“http://dev.teachdogrest.com/errors/12345”}

Page 15: The API Facade Pattern: Common Patterns - Episode 2

API Facade

Errors

Request Response

nothing to see here

GET /products?raise=500

(don’t support raise in production)

Page 16: The API Facade Pattern: Common Patterns - Episode 2

API Facade

Errors

Request Response

Big System

449 Retry With

404 Not Found

Page 17: The API Facade Pattern: Common Patterns - Episode 2

Stubs

Page 18: The API Facade Pattern: Common Patterns - Episode 2

API Facade

Stubs

Request Response

nothing to see here

{"products”: [ {"product":{"id":"1234”,"name":"Widget”, "color":"white"}},{"product":{"id":"1235”, "name":"Gadget”, "color":"brown"}} ]}

Page 19: The API Facade Pattern: Common Patterns - Episode 2

API Facade

Stubs

Request Response

nothing to see here

GET /products?mock=true

(don’t support mock in production)

Page 20: The API Facade Pattern: Common Patterns - Episode 2

URLs

Page 21: The API Facade Pattern: Common Patterns - Episode 2

URLs

/v2/accounts

AppDeveloper

Page 22: The API Facade Pattern: Common Patterns - Episode 2

URLs

Big System

/services/data/v20.0/sobjects/Account

Page 23: The API Facade Pattern: Common Patterns - Episode 2

API Facade

URLs

Request Response

Big System

/services/data/v20.0/sobjects/Account

/v2/accounts

Page 24: The API Facade Pattern: Common Patterns - Episode 2

API Facade

Support Limited Clients

Request Response

Big System

DELETE /services/data/v20.0/sobjects/Account/123

GET /v2/accounts/123?method=delete

Page 25: The API Facade Pattern: Common Patterns - Episode 2

Versioning

Page 26: The API Facade Pattern: Common Patterns - Episode 2

Versioning

/v3/accounts

Fast AppDeveloper

Slow AppDeveloper

/v2/accounts

Page 27: The API Facade Pattern: Common Patterns - Episode 2

API Facade

Versioning

Request

GET /v2/accounts GET /v3/accounts

Big OldSystem

New UntriedSystem

GET old.internal.com/accounts GET new.internal.com/accounts

Page 28: The API Facade Pattern: Common Patterns - Episode 2

Data Formats

Page 29: The API Facade Pattern: Common Patterns - Episode 2

Data Formats

JSON

HTML5 AppDeveloper

Java AppDeveloper

SOAP

Page 30: The API Facade Pattern: Common Patterns - Episode 2

SOAP

API Facade

Request Response

/services/data/v20.0/sobjects/Account

POST /v2/accounts.xml

SOAP

Data FormatsSOAP

Page 31: The API Facade Pattern: Common Patterns - Episode 2

SOAP

API Facade

Request Response

/services/data/v20.0/sobjects/Account

GET /v2/accounts.json

SOAP

Data FormatsJSON

Page 32: The API Facade Pattern: Common Patterns - Episode 2

Internal & external systems

Page 33: The API Facade Pattern: Common Patterns - Episode 2

DBContent

Management SOAP JDBC

API Facade

Internal

Page 34: The API Facade Pattern: Common Patterns - Episode 2

API Facade

External

SOAP RSSXML JSON

Page 35: The API Facade Pattern: Common Patterns - Episode 2

Q&A

Page 36: The API Facade Pattern: Common Patterns - Episode 2

Should the version number appear in the URL immediately after the domain name or is it better to have application name after domain name? Billing accounts /accounts/v2/create?

Q&A

Page 37: The API Facade Pattern: Common Patterns - Episode 2

With all the shunting you suggest make for a terrible complex layer?

Q&A

Page 38: The API Facade Pattern: Common Patterns - Episode 2

What would you recommend for a URL pattern for a sandbox instance?

Q&A

Page 39: The API Facade Pattern: Common Patterns - Episode 2

How can a GET request be transformed to a SOAP POST, specifically when the SOAP POST request size is huge?

Q&A

Page 40: The API Facade Pattern: Common Patterns - Episode 2

What about version in the request header instead of putting it in the URL, what would the drawback be of using it in the request header?

Q&A

Page 41: The API Facade Pattern: Common Patterns - Episode 2

Should every response follow a standard format that contains errors, if any, along with response body or should the response body change based on success or failure of the operation?

Q&A

Page 42: The API Facade Pattern: Common Patterns - Episode 2

What is the functional difference between the raise and the mock parameters again?

Q&A

Page 43: The API Facade Pattern: Common Patterns - Episode 2

For the API I am hosting façade pattern makes sense, but for the external systems where I am consuming APIs, factory seems more appropriate. What’s your take?

Q&A

Page 44: The API Facade Pattern: Common Patterns - Episode 2

What are your thoughts on REST sitemaps, worth it?

Q&A

Page 45: The API Facade Pattern: Common Patterns - Episode 2

Get flash accounts should return all accounts right? Wouldn’t want to prevent this, what would a URL request look like? If you’re reflecting a response from the database where the state=Washington, how would that work?

Q&A

Page 46: The API Facade Pattern: Common Patterns - Episode 2

THANK YOUSubscribe to API webinars at:

youtube.com/apigee

Page 47: The API Facade Pattern: Common Patterns - Episode 2

THANK YOUIRC#api-crafton freenode

Page 48: The API Facade Pattern: Common Patterns - Episode 2

THANK YOUQuestions and ideas to:

groups.google.com/group/api-craft

Page 49: The API Facade Pattern: Common Patterns - Episode 2

THANK YOUContact me at:

@[email protected]