Best Practices for Building with External APIs

A presentation at Momentum Dev Con in October 2021 in Cincinnati, OH, USA by Ben Greenberg

Slide 1

Slide 1

Best Practices for Building with External APIs Ben Greenberg @rabbigreenberg

Slide 2

Slide 2

or alternatively… @rabbigreenberg

Slide 3

Slide 3

@rabbigreenberg Becoming an API Explorer

Slide 4

Slide 4

Welcome to API Explorer Academy! πŸš€ Our Mission ● Discovering what to look for ● Equipping with the right tools ● Loving the journey, even with the bumps along the way! @rabbigreenberg

Slide 5

Slide 5

Before we start, who is this person talking to me? ● Professional API Wrangler (i.e. Developer Advocate) at Orbit ● Ruby is my happy language ● SAN πŸ›« JFK πŸ›« TLV 🌍 orbit.love @rabbigreenberg πŸ“§ ben@orbit.love

Slide 6

Slide 6

Bonus Slide! We’re hiring πŸ™Œ ● Globally distributed team ● Remote first ● Empathetic product-driven engineering ● Enjoys space puns… sometimes πŸ‘‰ orbit.love/careers

Slide 7

Slide 7

First of all… What is an API? @rabbigreenberg

Slide 8

Slide 8

β€œβ€¦ when a company offers an API to their customers, it just means that they’ve built a set of dedicated URLs that return pure data responses β€” meaning the responses won’t contain the kind of presentational overhead that you would expect in a graphical user interface like a website.” - What is an API in Plain English @rabbigreenberg

Slide 9

Slide 9

Examples of APIs ● Cat Facts - https://alexwohlbruck.github.io/cat-facts/ ● Harvard Art Museums - https://github.com/harvardartmuseums/api-docs ● Google Books - https://developers.google.com/books/ ● Charity Search - http://charityapi.orghunter.com/ ● National Bank of Poland - http://api.nbp.pl/en.html ● U.S. Street Address Validation - https://www.smartystreets.com/docs/cloud/us-street-api ● Associated Press - https://developer.ap.org/ @rabbigreenberg

Slide 10

Slide 10

You’re interested in an API? @rabbigreenberg

Slide 11

Slide 11

API Explorer Academy: Stage I Initial Discovery

Slide 12

Slide 12

Your Investigation Checklist βœ… πŸš€ πŸš€ πŸš€ πŸš€ πŸš€ πŸš€ API Reference Documentation Credentialing Rate Limits Pagination Support @rabbigreenberg

Slide 13

Slide 13

API Reference Why do you need an API reference? @rabbigreenberg

Slide 14

Slide 14

β€œThe OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection.” - OpenAPI Introduction @rabbigreenberg

Slide 15

Slide 15

What are the parameters? What does an error look like? What does success look like? @rabbigreenberg

Slide 16

Slide 16

@rabbigreenberg

Slide 17

Slide 17

@rabbigreenberg

Slide 18

Slide 18

β˜‘ Does it have an API reference? @rabbigreenberg

Slide 19

Slide 19

Documentation Is there documentation? @rabbigreenberg

Slide 20

Slide 20

Can an API even be used without documentation… ? - Stoplight

Slide 21

Slide 21

Types of Documentation πŸ“š πŸ“š πŸ“š πŸ“š πŸ“š Overviews Tutorials Quickstarts Code Snippets Use Cases @rabbigreenberg

Slide 22

Slide 22

Describe each status code Soliciting feedback Attributes with data types Describe error types @rabbigreenberg

Slide 23

Slide 23

β˜‘ Does it have documentation? @rabbigreenberg

Slide 24

Slide 24

Credentials Is it secure? @rabbigreenberg

Slide 25

Slide 25

Authentication is Identity Authorization is Access @rabbigreenberg

Slide 26

Slide 26

API πŸ”‘ β€œI am who I say I am, please give me what I am asking for.” πŸ”“ β€œI believe you are who you say you are, here is your data.” APPLICATION @rabbigreenberg

Slide 27

Slide 27

Authentication Protocols πŸ” Basic Auth πŸ” API Key πŸ” OAuth @rabbigreenberg

Slide 28

Slide 28

Authentication Protocols πŸ” Basic Auth β—‹ Base64 encoded username and password πŸ” API Key β—‹ A key that identifies an authorized application πŸ” OAuth β—‹ User scoped authentication β—‹ Multi-step process @rabbigreenberg

Slide 29

Slide 29

Basic Authentication Example @rabbigreenberg

Slide 30

Slide 30

API Key Example @rabbigreenberg

Slide 31

Slide 31

OAuth 2.0 Client Credentials Flow 1 CLIENT Send Client ID and secret to /token 4 2 Validate client ID and secret Request data with token 3 Send token to client API @rabbigreenberg

Slide 32

Slide 32

β˜‘ How does it authenticate? @rabbigreenberg

Slide 33

Slide 33

Rate Limiting and Pagination Are there limits? @rabbigreenberg

Slide 34

Slide 34

Rate Limiting is about requests Pagination is about records @rabbigreenberg

Slide 35

Slide 35

@rabbigreenberg

Slide 36

Slide 36

@rabbigreenberg

Slide 37

Slide 37

API Explorer Academy:Stage II Pre-Flight Checks

Slide 38

Slide 38

Let’s check out this API! @rabbigreenberg

Slide 39

Slide 39

Experimenting with an API @rabbigreenberg

Slide 40

Slide 40

Why do we experiment? βœ… See Live Data βœ… Check Assumptions βœ… Do Something Wrong @rabbigreenberg

Slide 41

Slide 41

@rabbigreenberg

Slide 42

Slide 42

Save requests to replay later Examine the API response @rabbigreenberg Define parameters, authentication, headers and more

Slide 43

Slide 43

@rabbigreenberg

Slide 44

Slide 44

Authorization options: ● ● API Key OAuth Possible API responses: ● ● 200 401 @rabbigreenberg

Slide 45

Slide 45

@rabbigreenberg

Slide 46

Slide 46

API Explorer Academy: Stage III Ready to Launch

Slide 47

Slide 47

You don’t have to do it alone @rabbigreenberg

Slide 48

Slide 48

Tools To Help You On Launch Day βœ… SDKs βœ… Low-Code/No-Code Tools @rabbigreenberg

Slide 49

Slide 49

What is an SDK? @rabbigreenberg

Slide 50

Slide 50

β€œSDK stands for software development kit. Also known as a devkit, the SDK is a set of software-building tools for a specific platform, including the building blocks, debuggers and, often, a framework or group of code libraries such as a set of routines specific to an operating system (OS).” IBM Introduction to SDKs @rabbigreenberg

Slide 51

Slide 51

@rabbigreenberg

Slide 52

Slide 52

Stop worrying about the API @rabbigreenberg

Slide 53

Slide 53

Manages authentication Handles rate limiting and pagination @rabbigreenberg

Slide 54

Slide 54

APIs Can Introduce Breaking Changes Don’t Let Them Break You @rabbigreenberg

Slide 55

Slide 55

Adding Activities to Orbit via the API directly You need to know: ● Headers ● Authentication ● Data format (JSON) ● Data types All these are subject to change (often)! @rabbigreenberg

Slide 56

Slide 56

Adding Activities to Orbit via the SDK You need to know: ● ● What your data is What method to call @rabbigreenberg

Slide 57

Slide 57

● ● ● ● ● ● @rabbigreenberg Build workflows graphically Integrate with numerous services automatically Customer support Build workflows graphically Add custom code solutions More programmer-oriented

Slide 58

Slide 58

API Explorer Academy: Stage IV Creating Outposts

Slide 59

Slide 59

Celebrate your wins along the way @rabbigreenberg

Slide 60

Slide 60

Each new learning is another new outpost in your growth @rabbigreenberg

Slide 61

Slide 61

β€œInstead of specializing in speedometers or steering wheels, software supply chain companies deliver reusable chunks of code that developers bring together to make finished applications… @rabbigreenberg

Slide 62

Slide 62

These are called APIs… @rabbigreenberg

Slide 63

Slide 63

… This shift to component software is the next big leap in the evolution of the software industry.” - Jeff Lawson @rabbigreenberg

Slide 64

Slide 64

Stay in Touch ben@orbit.love @rabbigreenberg @bencgreenberg @rabbigreenberg