APIs: The good, the bad, the ugly

93
APIs: The good, the bad, the ugly @MicheleTitolo

description

Apps consume a lot of web services these days. Sometimes, these new services can be fantastic, and other times not so much. Learning how to evaluate APIs and identify problem areas before jumping head first into development can save us frustration, time, and money. This session will walk through evaluating an API, best practices, and red flags, all from the standpoint of an iOS dev. No matter your experience level, you'll leave with the skills to effectively tackle your next API.

Transcript of APIs: The good, the bad, the ugly

Page 1: APIs: The good, the bad, the ugly

APIs:The good, the bad, the ugly

@MicheleTitolo

Page 2: APIs: The good, the bad, the ugly
Page 3: APIs: The good, the bad, the ugly
Page 4: APIs: The good, the bad, the ugly

What we’ll cover

Page 5: APIs: The good, the bad, the ugly

Documentation

Page 6: APIs: The good, the bad, the ugly

The Good

Page 7: APIs: The good, the bad, the ugly

It exists

Page 8: APIs: The good, the bad, the ugly

Bonus: it’s interactive

Page 9: APIs: The good, the bad, the ugly

I/O Docs

Page 10: APIs: The good, the bad, the ugly

The Bad

Page 11: APIs: The good, the bad, the ugly

Docs aren’t updated

Page 12: APIs: The good, the bad, the ugly

The Ugly

Page 13: APIs: The good, the bad, the ugly

Documentation?

Page 14: APIs: The good, the bad, the ugly
Page 15: APIs: The good, the bad, the ugly

URLs

Page 16: APIs: The good, the bad, the ugly

The Good

Page 17: APIs: The good, the bad, the ugly

Consistency

Page 18: APIs: The good, the bad, the ugly

/users/22445/products/3156/movies/127/times

Page 19: APIs: The good, the bad, the ugly

The Bad

Page 20: APIs: The good, the bad, the ugly

Inconsistency

Page 21: APIs: The good, the bad, the ugly

/users/22445/reviews/3156/times/127

Not review or time id’s

Page 22: APIs: The good, the bad, the ugly

The Ugly

Page 23: APIs: The good, the bad, the ugly

“Send GET to /remove to delete”

Page 24: APIs: The good, the bad, the ugly
Page 25: APIs: The good, the bad, the ugly

Payloads

Page 26: APIs: The good, the bad, the ugly

The Good

Page 27: APIs: The good, the bad, the ugly
Page 28: APIs: The good, the bad, the ugly

You have all the data you need

Page 29: APIs: The good, the bad, the ugly

The Bad

Page 30: APIs: The good, the bad, the ugly

Endpoint “id” field

/products id

/products/:id productID

/cart product_id

Page 31: APIs: The good, the bad, the ugly

Yes, this actually happened

Page 32: APIs: The good, the bad, the ugly

Change

Page 33: APIs: The good, the bad, the ugly

We expect certain things

Page 34: APIs: The good, the bad, the ugly

...like image urls having http://

Page 35: APIs: The good, the bad, the ugly

...like dates sent in the same format

Page 36: APIs: The good, the bad, the ugly

We expect certain thingsto not change

Page 37: APIs: The good, the bad, the ugly

The Ugly

Page 38: APIs: The good, the bad, the ugly

JSON containing HTML

Page 39: APIs: The good, the bad, the ugly
Page 40: APIs: The good, the bad, the ugly
Page 41: APIs: The good, the bad, the ugly

Unstable

Page 42: APIs: The good, the bad, the ugly
Page 43: APIs: The good, the bad, the ugly

Authentication

Page 44: APIs: The good, the bad, the ugly

The Good

Page 45: APIs: The good, the bad, the ugly

HTTP Basc Auth over SSL

Page 46: APIs: The good, the bad, the ugly

...when SSL is secure

Page 47: APIs: The good, the bad, the ugly

OAuth

Page 48: APIs: The good, the bad, the ugly

The Bad

Page 49: APIs: The good, the bad, the ugly

OAuth

Page 50: APIs: The good, the bad, the ugly
Page 51: APIs: The good, the bad, the ugly

The Ugly

Page 52: APIs: The good, the bad, the ugly
Page 53: APIs: The good, the bad, the ugly
Page 54: APIs: The good, the bad, the ugly

Authorization

Page 55: APIs: The good, the bad, the ugly

The Good

Page 56: APIs: The good, the bad, the ugly

App requests permissions

Page 57: APIs: The good, the bad, the ugly

The Bad

Page 58: APIs: The good, the bad, the ugly

A single API key

Page 59: APIs: The good, the bad, the ugly

The Ugly

Page 60: APIs: The good, the bad, the ugly

Authorization?

Page 61: APIs: The good, the bad, the ugly

goto fail;

Page 62: APIs: The good, the bad, the ugly
Page 63: APIs: The good, the bad, the ugly
Page 64: APIs: The good, the bad, the ugly

Errors

Page 65: APIs: The good, the bad, the ugly

The Good

Page 66: APIs: The good, the bad, the ugly

Error codes

Page 67: APIs: The good, the bad, the ugly

Error message in response

Page 68: APIs: The good, the bad, the ugly

Human readable error message

Page 69: APIs: The good, the bad, the ugly

The Bad

Page 70: APIs: The good, the bad, the ugly

“There was an error”

Page 71: APIs: The good, the bad, the ugly
Page 72: APIs: The good, the bad, the ugly

The Ugly

Page 73: APIs: The good, the bad, the ugly
Page 74: APIs: The good, the bad, the ugly
Page 75: APIs: The good, the bad, the ugly
Page 76: APIs: The good, the bad, the ugly

Caching

Page 77: APIs: The good, the bad, the ugly

The Good

Page 78: APIs: The good, the bad, the ugly

Using one of the standards

Page 79: APIs: The good, the bad, the ugly

Cache-Control

Page 80: APIs: The good, the bad, the ugly

If-Modified-Since

Page 81: APIs: The good, the bad, the ugly

etags

Page 82: APIs: The good, the bad, the ugly

The Bad

Page 83: APIs: The good, the bad, the ugly

Manually processing data

Page 84: APIs: The good, the bad, the ugly

The Ugly

Page 85: APIs: The good, the bad, the ugly

Caching

Page 86: APIs: The good, the bad, the ugly
Page 87: APIs: The good, the bad, the ugly
Page 88: APIs: The good, the bad, the ugly

In Summary

Page 89: APIs: The good, the bad, the ugly

Consistency

Page 90: APIs: The good, the bad, the ugly

Conventions

Page 91: APIs: The good, the bad, the ugly

Simple

Page 92: APIs: The good, the bad, the ugly

Questions?@MicheleTitolo