31
Things you should know Building a Public API } During Before After

Developing a Public API -- at Reversim Summit 2015

Embed Size (px)

Citation preview

Things you should know

Building a

Public API}During

Before

After

@yonatanm

Outbrain

Outbrain

0.5B> 190BUnique Visitors RecommendationS

per Month

“Boss, Boss hi API i not RESTful”

* min {control on usage}* max {responsibility}* decisions.exist {_.takeAtDay1}

* min {control on usage}* max {responsibility}* decisions.exist {_.takeAtDay1}

Be PragmaticMake reasonable

compromise

Quiz #1

???

Product

API

Users

Answer

Developers

Product

API

Users

Quiz #2

???

Product

API

U.X.

AnswerProduct

API Resources && URIS

U.X.

Be consistently consistent

* HTTP methods* HTTP codes* Headers* Authentication

No one likes surprises

Make your users feel at home

Use Standards:

Error handling

It is all about the Expectations

GET

POST

PUT

/customers/{id}

/customers

/customers

REQUEST RESPONSE

customerGET

customercustomer

customercustomer*

200

201

200

To embed GET /customers/1

GET /customer/1/orders

|| !to embed GET /customers/1

Can we have both ?

To embed || !to embed ?

SimpleAll you need in one requestFewer transactions

SimpleAll you need in one requestFewer transactions

FastBuilding blockflexibilityCacheable

FastBuilding blockflexibilityCacheable

!to embed

to embed

and do it right ?*

Yes We Can !GET /customers/1

GET /customers/1?embed=orders

Yes We Can #2GET /customers/1

Quiz #3

???

Product

API

U.I.

Answer

Documentation

Product

API

U.I.

Documentationapiary.io

Swager

Mashape and More...

apiary.io

Swager

Mashape and More...

* Be consistent* Focus on Resources* Less > More* Examples

* Be consistent* Focus on Resources* Less > More* Examples

" עבודה במקביל – הצלחה לכל דביל”

" עבודה במקביל – הצלחה לכל דביל”

** Sand-box ? +1** Sand-box ? +1

Documentation

Documentation

Documentation

* UX – interactions

* UI – documentation

* Ideas to new features

* Bugs

Eat your own dog foodTip #1

Tip #2What's wrong with using DB IDs as your entity IDs?

GET /customers/1

“Authorization”

“privacy” , your privacy

“Authorization”

“privacy” , your privacy

Bi Directional mapping using secret key -

HOW?

Tip #2

Add another column in the DB

27847321845691

Like a version

OR/SUPPORT/multiple/VERSIONS/v2.5/

/SELL/your/soul/to/backwards/compatibility

URI should control

identity not presentationhttp://bit.ly/1Mo0yXF

===>GET /customer/1 HTTP/1.1Accept: application/outbrain.customer-v2.5+json

===>GET /customer/1 HTTP/1.1Accept: application/outbrain.customer-v2.5+json

<===HTTP/1.1 200 OKContent-Type: application/outbrain.customer-v2.5+json

<===HTTP/1.1 200 OKContent-Type: application/outbrain.customer-v2.5+json

Like a version

– One ?– Three ?– Four ?

– One ?– Three ?– Four ?

Quiz #3How many Types do you need ?

GET /customer/1

PUT /customer/1POST /customer/1

Clones ? Not Really !

!= Internal ModelRetrieve != Update != Create

JSON 2 Case Class [Scala]

http://json2caseclass.cleverapps.io/http://json2caseclass.cleverapps.io/

.json

.scala

3

Security

Tip #3

Translation

1

2

WebWeb

Business Logic (API)

456

Events

Cache

Much more to talk about* Security

* Internal and Public API

* Rate Limit

* Testing

* Rest maturity model

* Security

* Internal and Public API

* Rate Limit

* Testing

* Rest maturity model

Q ? A !Thank You