Slide 1

Slide 1 text

API Design at Andrew Godwin @andrewgodwin

Slide 2

Slide 2 text

The Problem

Slide 3

Slide 3 text

Two existing APIs: APIv1 at least 6 years old APIv2 never finished and now too specialised

Slide 4

Slide 4 text

Outdated: No provision for new features Some interfaces locked down to old ideas (e.g. payment)

Slide 5

Slide 5 text

Bad patterns: Same domain as main site /xml/?method=access_code_new Both XML and JSON as return formats, transformed from each other.

Slide 6

Slide 6 text

The Task Build a new API for the modern era

Slide 7

Slide 7 text

SOA Match it as closely as possible

Slide 8

Slide 8 text

Event service Venue service Order service Payment service SOA Client

Slide 9

Slide 9 text

Event service Venue service Order service Payment service SOA Client APIv3 API Client

Slide 10

Slide 10 text

Future-proof Allow for more features easily

Slide 11

Slide 11 text

Maintainable Make sure it's easier to extend than start again

Slide 12

Slide 12 text

The Basis

Slide 13

Slide 13 text

The Basis Django REST Framework

Slide 14

Slide 14 text

The Basis Django REST Framework Custom SOA/API coupling

Slide 15

Slide 15 text

The Basis Django REST Framework Custom SOA/API coupling Piecemeal refactors of current code

Slide 16

Slide 16 text

The Basis Django REST Framework Custom SOA/API coupling Piecemeal refactors of current code APIv1 as initial target to start deprecation

Slide 17

Slide 17 text

Design Principles

Slide 18

Slide 18 text

JSON only Mapping XML ←→ JSON rarely works well

Slide 19

Slide 19 text

REST (ish) Sensible paths, sensible verbs

Slide 20

Slide 20 text

/events/ /events/39992/ /events/39992/orders/ /events/39992/publish/ /users/me/owned_events/ POST: New event GET: Event details POST: Update event GET: List of orders /events/39992/orders/12392/ GET: Order details POST: Publish event GET: List of your events DELETE: Delete event

Slide 21

Slide 21 text

Every response is {} Leaves room for new features/pagination

Slide 22

Slide 22 text

Pagination everywhere And standardised, so there's no surprises

Slide 23

Slide 23 text

Introspectable parameters For our documentation and API explorer

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Always more to do Documentation, consistency, and new features

Slide 27

Slide 27 text

Try it today! http://developer.eventbrite.com

Slide 28

Slide 28 text

Thanks. @andrewgodwin [email protected]