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

Operational API Design Anti-Patterns

Operational API Design Anti-Patterns

Talk from Nordic APIs Platform Summit in Stockholm, Oct 2016

Jason Harmon

October 26, 2016
Tweet

More Decks by Jason Harmon

Other Decks in Technology

Transcript

  1. Head of APIs @Typeform • Leading microservice replatform • Leading

    developer focused initiatives Previous API experience: • PayPal/Braintree • uShip • Wayport / AT&T Jason Harmon • Old blogs at: ◦ APIUX.com ◦ Pragmaticapi.com
  2. “API Design Anti-Patterns” talk from last year • https://www.youtube.com/watch?v=lotdj-ry8YA Design

    issues don’t always cause operational issues. Haven’t we already talked about this?
  3. Submit User Human Click “Back” ? Submit needs to have

    a landing (to derive “response rate”) POST /submissions (+landing_id in body)
  4. Issue: GET Caches + HTTP GET GET /landing Caching Proxy

    Or CDN Cached response X 200 OK { “Token”: “abc123” }
  5. • Identification: Unexpected cached API calls from browser/proxy/etc • Solution:

    Use POST • Live already? ◦ Just add POST ◦ Add ?cache_buster=[random] to GET Summary: GET instead of POST
  6. Polling APIs Problem Identification: • Large dataset • Expensive queries

    • Frequently changing data • Lots of clients Client app Every 5 mins Thousands of forms
  7. WHAT IF THIS IS ALREADY HAPPENING!!?! Client app Options: •

    Launch webhooks! • Caching (if possible) • Read-only DB replica • Cheaper query to check for new data before retrieval
  8. Form Structure + Backend-for-Frontend Microservices B F F AKA •

    Composition • Orchestration GraphQL is another potential option
  9. • Problem: ◦ Client performance in UX ◦ N+1 calls

    (client calls for parent, then calls for related/child items) • Identification: ◦ Data lacking in main resource, usually for UX devs. • Easy to add in live scenarios Summary: Rigid resource structure
  10. AKA RPC Commonly used in controlled state transitions: POST /forms/:id/publish

    { “comment”: “It’s the right time” } What’s an “action”
  11. Perform multiple actions with one endpoint POST /forms/:id/change-status { “action”:

    “publish”, “comment”: “My favorite version of this form” } Generic “action”
  12. Dear Product Owner. We need to build a new metrics

    system to answer that question. - Yours truly, dev team. PO
  13. Generic Actions • Identification: ◦ POST /resource/:id/generic-name + {action: process}

    • Problem: “Protocol tunneling”: ◦ Lack of traceability, more work for metrics (vs cheaper HTTP logs method) • Solution: ◦ POST /resource/:id/action-name • Already live? ◦ ?action=name in optional query parameter