Top Banner
Giuliano Iacobelli, Stamplay [email protected] Webhooks do’s and dont’s: what we learned integrating +100 APIs
27

Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

Apr 14, 2017

Download

Technology

Codemotion
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: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

Giuliano Iacobelli, [email protected]

Webhooks do’s and dont’s: what we learned integrating +100 APIs

Page 2: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017
Page 3: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Lego for APIsStamplay is a low-code platform that provides a visual interface to drag&drop

connectors and creates integration workflows between services

Page 4: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Token based Auth (e.g OAuth2)

Machine readable docs (Swagger, RAML, IO docs)

Webhooks HATEOAS

Key requirements for APIs in the automation era Simple, consistent, flexible, friendly, explorable via URL

and use web standards where they make sense.

Page 5: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Key requirements for APIs in the automation era Simple, consistent, flexible, friendly, explorable via URL

and use web standards where they make sense.

Token based Auth (e.g OAuth2)

Machine readable docs (Swagger, RAML, IO docs)

Webhooks HATEOAS

Page 6: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

WEBHOOKS =

HTTP PUSH NOTIFICATIONS

Page 12: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Consumer sets up a server to listen for webhooks

Consumer registers webhook URL with provider

Provider starts making request to webhook URL when event happens

Webhook Setup

Page 13: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Consumer sets up a server to listen for webhooks

Consumer registers webhook URL with provider

Provider starts making request to webhook URL when event happens

Webhook Setup

Page 14: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Consumer sets up a server to listen for webhooks

Consumer registers webhook URL with provider

Provider starts making request to webhook URL when event happens

Webhook Setup

Page 15: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Webhook anatomy Webhooks are fundamental pieces of an API today and a simple notification

is no longer enough, as an API provider you need to do the heavy lifting for your users

• a verb: POST • an explicit event type: which could be subscribed by any

user (for Github: pull_request, fork, commit, issues, etc.. ) • a payload: containing the relevant data for the related event

• including: the resource itself, the sender (user who triggered the webhook) • constant data structure

• a security hash: to ensure webhook was delivered by the rightful authority • for Github: sharing a common secret used to generate a hash from the payload

• an ID

Page 16: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Fat payload vs Thin payload Provide as much information as possible about the event that is being notified, as well as

additional information for the client to act upon that event.

Page 17: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Batch vs Single Services providing high frequency / volume of data might opt to make less calls

and batch data into an array

Page 18: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Subscribing to events using multiple URLs Webhooks are fundamental pieces of an API today and a simple notification

is no longer enough, as an API provider you need to do the heavy lifting for your users

• a CRUD API • a payload URL: the server endpoint that will receive the webhook payload • events list: which events would you like to subscribe to • (optional) the content type

Page 19: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Subscribing to multiple events to single URL Webhooks are fundamental pieces of an API today and a simple notification

is no longer enough, as an API provider you need to do the heavy lifting for your users

Page 20: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Fine grained control on events you want to listen on Webhooks are fundamental pieces of an API today and a simple notification

is no longer enough, as an API provider you need to do the heavy lifting for your users

Page 21: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Renewing subscriptions Avoid sending webhooks to endpoints that are no longer active

by implementing a subscription renewal logic

Page 22: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

API for Webhooks aka REST Hooks Webhooks are fundamental pieces of an API today and a simple notification

is no longer enough, as an API provider you need to do the heavy lifting for your users

Page 23: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Securing Webhooks Webhooks are fundamental pieces of an API today and a simple notification

is no longer enough, as an API provider you need to do the heavy lifting for your users

Page 24: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Webhooks debugging Receives HTTP requests and captures the data for later inspection

Page 25: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Webhooks toolkit: Ngrok Secure introspectable tunnels to localhost

Page 27: Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuliano Iacobelli - Codemotion Rome 2017

[email protected]

Questions? [email protected]

Try Stamplay: stamplay.com

Thank you!