+ All Categories
Home > Documents > on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a...

on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a...

Date post: 07-Oct-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
42
How to Reach the Highest Level on APIs
Transcript
Page 1: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

How to Reachthe Highest Levelon APIs

Page 2: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

About meI wrote my first lines of code at 12. When I turned 17, I founded my first

tech company, making an exit at 19 to follow my dream of becoming a

professional fighter. 2 years later, as a professional fighter, I had a nasty

fracture and decided to come back to the tech world.

Nowadays, I’m CEO at LinkApi, a new developer experience in API

management and Integration tools as a service.

/thiagolimabr

@thiago.limabr

Page 3: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Client-serverA little about history

Page 4: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

WebA little about history

Page 5: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

SOAA little about history

Page 6: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

“All companies aresoftware companies”

- Satya Nadella

Digital transformationAnd finally...

Page 7: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

The API ecosystemAbout APIs

Page 8: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Generates 60% of its revenue through APIs

Total revenue of $650.1 million in 2018

10K third apps created by community

Generates 60% of its revenue through APIs

Generates 90% of its revenue through APIs

The API economyAbout APIs

Page 9: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Partnerships Open innovation Digital business

Internal integrations Mobile apps IoT

Digital TransformationRESTFul APIs

Page 10: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Best practices on APIs

Page 11: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

01

23

4

The swamp of POX - Single URI and a single verb

Resources - MULTIPLE URI BASED RESOURCES AND SINGLE VERBS

HTTP Verbs

Hypermedia Controls

Developer ExperienceGlory of REST

Page 12: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

• Independent resources in each URL

• Specific objects

• REST as a transport mechanism, without good practices.

Level 1GLORY OF APIs RESTFul

Page 13: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

• Uses HTTP specification through methods, headers, status codes and pagination.

• Other best practices

Level 2GLORY OF APIs RESTFul

Page 14: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Base URL

LEVEL 2

Not recommended

http://www.test.com/dev/api

Recommended

http(s)://api.test.com

Good practices

Page 15: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Keep verbs out of your base URLs

LEVEL 2

Not recommended

URL mediumgameapi.com/getaccounts

Recommended

GET mediumgameapi.com/accountsPUT mediumgameapi.com/accountsPOST mediumgameapi.com/accountsDELETE mediumgameapi.com/accounts

Good practices

Page 16: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Content-type in header

LEVEL 2

Not recommended

GET /entities/123/payable_accounts.json

Recommended

GET /entities/123/payable_accounts HTTP/1.1Accept: application/jsonContent-Type: application/json

Good practices

Page 17: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Simplicity in the hierarchical structure

LEVEL 2

Not recommended /accounts/00928376/transaction/8738903/zip/6500/city/dublin/state/ca

Recommended

/accounts/00928376/transaction/8738903?zip=6500&city=dublin&state=ca

Good practices

(max 3 levels)

Page 18: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Use status code in the right way

LEVEL 2

Good practices

200 201 204 404 400 500

OK Created No content Not found Bad requestInternal

server error

Page 19: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Pagination

LEVEL 2

Recommendedhttps://api.pipedrive.com/v1/deals?offset=2&limit=100

Good practices

Specify which is the first page (0 or 1), if you're using page and pageSize.

Page 20: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Smart Filters

LEVEL 2

Good practices

Not recommended

Recommended

Make date ranges available on the filter.

Page 21: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

• More complex demands like versioning, traceability and HATEOAS.

• Starts questioning about how the experience of the developer consuming your API.

• Uses worldwide developing patterns and creates objects thinking about readability.

Level 3GLORY OF APIs RESTFul

Page 22: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Versioning

LEVEL 3 Not recommended

//yourInstance.salesforce.com/services/data/

[ { "version" : "20.0", "label" : "Winter '11", "url" : "/services/data/v20.0" }, { "version" : "21.0", "label" : "Spring '11", "url" : "/services/data/v21.0" }, ... { "version" : "26.0", "label" : "Winter '13", "url" : "/services/data/v26.0" }]

Recommended

//api.stripe.com/v1/charges \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -H "Stripe-Version: 2019-03-14"

Good practices

Be clean and organized, providing a good experience for who is consuming.

Page 23: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Clean and legible objects

LEVEL 3Not recommended

GET /entities/:entity_id/receivable_accounts?per_page=15&page=3

{ "receivable_account": { "id": 1, "entity_id": 1, "status": 1, "status_name": "unreceived", "due_date": "2011-09-10", "occurred_at": null, "amount": "100.0", "ticket_amount": null, "interest_amount": null, "discount_amount": null, "nominal_amount": null, "total_amount": null, "description": "Material para escritório", "document": "897671718", "document_emission_date": "2011-08-07", "observation": "Papel para impressão.", "remind": true, "reminded_at": null, "income_tax_relevant": true, }}

Good practices

Readability may seem individual, but in practice, it’s not. The simpler an object is, the easier it is to understand it.

Page 24: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Track records

LEVEL 3

Recommended

{ "createdAt": 1501869101896,

"createdBy": "Thiago", "updatedAt": 1501869101896, "updatedBy": "Thiago"

}

Good practices

Use traceability patterns that allow you to understand who created or altered data.

Page 25: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Use always the default ISO 8601 for dates

LEVEL 3

Recommended

{ "createdAt":"2019-07-08T18:02:24.343Z"}

// Use UTC

Good practices

Date and time are chaotic. Keep up with the patterns.

Page 26: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Be careful with HATEOAS

LEVEL 3

GET https://api.github.com/users/codemazeblog

{ "login": "CodeMazeBlog", "id": 29179238, "avatar_url": "https://avatars0.githubusercontent.com/u/29179238?v=4", "gravatar_id": "", "url": "https://api.github.com/users/CodeMazeBlog", "html_url": "https://github.com/CodeMazeBlog", "followers_url": "https://api.github.com/users/CodeMazeBlog/followers", ...

Good practices

Hypermedia As The Engine Of Application State

Page 27: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

• Beyond a stable and functioning API, delivers a better experience for who’s consuming your API.

• Now the challenge it’s on the details that will impact your consume and navigation.

Level 4GLORY OF APIs RESTFul

Page 28: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Use developer experience concepts

LEVEL 4

Good practices

User Experience

Development Principles

DX

Page 29: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Be careful with policies

LEVEL 4

Good practices

Use Throttling e Rate limiting.

Using that, consider the use cases, and the minimum acceptable for the consumer.

Page 30: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Event-driven API

LEVEL 4

Good practices

event

event

event

Page 31: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Dev-friendly error handling

LEVEL 4

Good practices Recommended

Request: GET https://api.twilio.com/2010-04-01/Accounts/1234/IncomingPhoneNumbers/1234Response: Status Code 404

{ "RestException": { "Code": "20404", "Message": "The requested resource /2010-04-01/Accounts/1234/IncomingPhoneNumbers/1234 was not found", "MoreInfo": "https://www.twilio.com/docs/errors/20404", "Status": "404" }}

Custom structure with detailed error and link to help.

Page 32: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Great documentation

LEVEL 4

Good practices

Not recommended

Recommended

Be clear and straight.

Describe resources and how to use them in arequest/response structure.

Page 33: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Getting Started Guide

LEVEL 4

Good practices

Onboarding is important.

Show the devs how to start.

Page 34: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Useful Tutorials

LEVEL 4

Good practices

Make good and simple tutorials about the most important API actions.

Page 35: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

LEVEL 4

Good practices

SDK in multiple languages

Make it easy to use no matter the client library.

Page 36: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Provide a space for feedbacks

LEVEL 4

Good practices

There’s always room for improvement. Why not get feedbacks from who’s using more?

Page 37: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Good Release Notes and Changelogs

LEVEL 4

Good practices

Communicate to your final user what’s changing and why it’s important.

Page 38: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Dashboard and monitoring

LEVEL 4

Good practices

Data is crucial. Make sure you havea good monitoring tool.

Page 39: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

LEVEL 4

Good practices

Console mode

Making testing easier is the first step to less errors.

Page 40: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Status page

LEVEL 4

Good practices

Your final user would like to know if your systems are offline.

Page 41: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Communication is key

LEVEL 4

Good practices

Keep your final users updated.

Page 42: on APIs Level the Highest How to Reach · • Beyond a stable and functioning API, delivers a better experience for who’s consuming your API. • Now the challenge it’s on the

Thank you!

/thiagolimabr

@thiago.limabr


Recommended