Upgrade to Pro — share decks privately, control downloads, hide ads and more …

API Design at Eventbrite

API Design at Eventbrite

A short talk given as part of the Eventbrite "Advanced Django" workshop at Pycon 2014

Andrew Godwin

April 10, 2014
Tweet

More Decks by Andrew Godwin

Other Decks in Programming

Transcript

  1. API Design at
    Andrew Godwin
    @andrewgodwin

    View Slide

  2. The Problem

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  6. The Task
    Build a new API for the modern era

    View Slide

  7. SOA
    Match it as closely as possible

    View Slide

  8. Event service
    Venue service
    Order service
    Payment service
    SOA Client

    View Slide

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

    View Slide

  10. Future-proof
    Allow for more features easily

    View Slide

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

    View Slide

  12. The Basis

    View Slide

  13. The Basis
    Django REST Framework

    View Slide

  14. The Basis
    Django REST Framework
    Custom SOA/API coupling

    View Slide

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

    View Slide

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

    View Slide

  17. Design Principles

    View Slide

  18. JSON only
    Mapping XML ←→ JSON rarely works well

    View Slide

  19. REST (ish)
    Sensible paths, sensible verbs

    View Slide

  20. /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

    View Slide

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

    View Slide

  22. Pagination everywhere
    And standardised, so there's no surprises

    View Slide

  23. Introspectable parameters
    For our documentation and API explorer

    View Slide

  24. View Slide

  25. View Slide

  26. Always more to do
    Documentation, consistency, and new features

    View Slide

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

    View Slide

  28. Thanks.
    @andrewgodwin
    [email protected]

    View Slide