Top Banner
APIs Are Forever: How to Design Long-Las6ng APIs James Higginbotham API Architect @launchany
33

APIs Are Forever - How to Design Long-Lasting APIs

Apr 15, 2017

Download

Software

LaunchAny
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: APIs Are Forever - How to Design Long-Lasting APIs

APIsAreForever:HowtoDesignLong-Las6ngAPIs

JamesHigginbothamAPIArchitect@launchany

Page 2: APIs Are Forever - How to Design Long-Lasting APIs

YourAPItellsastory.Whatstorydoesyourstell?

Page 3: APIs Are Forever - How to Design Long-Lasting APIs

IfyourAPIisthestory,youaredoingitwrong.

Page 4: APIs Are Forever - How to Design Long-Lasting APIs

DowecreateoneAPIproduct?Morethanoneproduct?

Howcanwepreventaredesign?

Page 5: APIs Are Forever - How to Design Long-Lasting APIs

Architectureisdesign

Page 6: APIs Are Forever - How to Design Long-Lasting APIs

WebAPIsareanarchitecturalconcernthatexposeaninterfaceto

anunderlyingsystem.Designthemtotellyourstory.

Page 7: APIs Are Forever - How to Design Long-Lasting APIs

“Wehaveamonolithicapp,butweareintheprocessofrearchitecDngitusingmicroservicesandAPIs.”

--anyonewherecode.age>=3months

Page 8: APIs Are Forever - How to Design Long-Lasting APIs

Whydowehave“monolithicregret”andhow

canweavoidit?

Page 9: APIs Are Forever - How to Design Long-Lasting APIs

LackofModulariza6on=Regret

VS

Func6on-Based Module-Based

Page 10: APIs Are Forever - How to Design Long-Lasting APIs

(Re)IntroducingSystemsDesignandDomain-DrivenDesign

Page 11: APIs Are Forever - How to Design Long-Lasting APIs

ModelingaSystem

System/Solu6on

Subsystem Subsystem

Module Module

Module Module

Subsystem SubsystemModule Module

Page 12: APIs Are Forever - How to Design Long-Lasting APIs

TheSystemofLEGO

System

Sub-systems

Modules

Page 13: APIs Are Forever - How to Design Long-Lasting APIs

“YourAPIdesignshouldbecomethedefiniDonofyournew

targetarchitecture“-@jharmn

Page 14: APIs Are Forever - How to Design Long-Lasting APIs

MulD-SidedMarketplacePlaRormAPIExample

Page 15: APIs Are Forever - How to Design Long-Lasting APIs

ListAvailInventory

DistributorAddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

PointOfSale

RemoveProduct

Customer

Operator

Operator

Page 16: APIs Are Forever - How to Design Long-Lasting APIs

OrderMgmt

ListAvailInventory

DistributorAddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

Operator

PointOfSale

RemoveProduct

Customer

Operator

InventoryMgmt

Fulfillment

Page 17: APIs Are Forever - How to Design Long-Lasting APIs

EachsubsystemhasanAPIthatexposesoneormoreendpoints.

Page 18: APIs Are Forever - How to Design Long-Lasting APIs

OrderAPI

ListAvailInventory

DistributorAddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

PointOfSale

RemoveProduct

Customer

Operator

InventoryAPI

FulfillmentAPI

Operator

Page 19: APIs Are Forever - How to Design Long-Lasting APIs

IdenDfyingtheproductsbecomeseasierwhenwehaveboundariesaroundtheAPIs

Page 20: APIs Are Forever - How to Design Long-Lasting APIs

OrderAPI

ListAvailInventory

DistributorAddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

Operator

RemoveProduct

InventoryAPI

FulfillmentAPI

#1 #2`

PointOfSale

Page 21: APIs Are Forever - How to Design Long-Lasting APIs

ForeveryAPI,ask:“Whatareyourresources?”

Page 22: APIs Are Forever - How to Design Long-Lasting APIs

Domain-DrivenDesign

Page 23: APIs Are Forever - How to Design Long-Lasting APIs

ModeldomainobjectstofindbusinessenDDes,relaDons,statetransiDons,andevents

Page 24: APIs Are Forever - How to Design Long-Lasting APIs

OrderAPI

ListAvailInventory

AddProducttoOrder

CompleteOrder

CancelBooking

AddProducttoInventory

UpdateProductQty

LocateBooking

RedeemBooking

RemoveProduct

InventoryAPI

FulfillmentAPI

Page 25: APIs Are Forever - How to Design Long-Lasting APIs

OrderAPI

Availabili6es

Orders

Products(Inventory)

Bookings

InventoryAPI

FulfillmentAPI

Samedata,Conceptuallydifferentto

theAPIconsumer!

Page 26: APIs Are Forever - How to Design Long-Lasting APIs

AvailabiliDes-product

-date(s)avail-qtyavail

Orders-bookings-ordertotal

Products-name

-availschedule

Bookings-product-date(s)-status

Page 27: APIs Are Forever - How to Design Long-Lasting APIs

AvailabiliDes-product

-date(s)avail-qtyavail

availabilityChanged()

Orders-bookings-ordertotal

created()updated()

Products-name

-availschedule

created()removed()updated()

Bookings-product-date(s)-status

redeemed()cancelled()

Page 28: APIs Are Forever - How to Design Long-Lasting APIs

PuXngitalltogether

Page 29: APIs Are Forever - How to Design Long-Lasting APIs

AvailabiliDes-product

-date(s)avail-qtyavail

availabilityChanged()

Orders-bookings-ordertotal

created()updated()

Products-name

-availschedule

created()removed()updated()

Bookings-product-date(s)-status

redeemed()cancelled()

OrderAPI InventoryAPI

FulfillmentAPI

Page 30: APIs Are Forever - How to Design Long-Lasting APIs

Wheredomicroservicesfit?

Page 31: APIs Are Forever - How to Design Long-Lasting APIs

AvailabiliDesService

createAvailability()updateAvailability()deleteAvailability()

…availabilityChanged()

OrdersServicecreateOrder()updateOrder()deleteOrder()

…created()updated()

ProductsServicecreateProduct()updateProduct()deleteProduct()

…created()removed()updated()

BookingsServicelookupBooking()redeemBooking()cancelBooking()

…redeemed()cancelled()

OrderAPI InventoryAPI

FulfillmentAPI

OrdersHTTPAPI InventoryHTTPAPI

FulfillmentHTTPAPI

Page 32: APIs Are Forever - How to Design Long-Lasting APIs

HowdoesyourAPIdesignreflectyourAPIstory?

Page 33: APIs Are Forever - How to Design Long-Lasting APIs

Thankyou!

JamesHigginbotham

[email protected]@launchany