This is a session given by Zane Claes at Nordic APIs 2016 Platform Summit on October 25th, in Stockholm Sweden.
Description:
Too often, APIs are only consumed by mobile apps and external services. This leads to inconsistencies between web and API implementations of core business logic. This talk will discuss how Airbnb created an API infrastructure that also powers our website, to create a single source of truth.
11. • Duplicated Work: Web. Mobile Apps. MoWeb. Lantern. Etc.
• Inconsistent Behavior: Entirely different code paths.
Payments on mobile, different than payments on web.
• Difficult to Scale: Direct data access prevents moving to
Service-oriented Architecture. Monorail contains too many
tables.
• Poor Security: Access enabled by default. Leaks PII. Difficult
to have good security policy.
• No Type Safety: Crashes app, due to unpredictable types in
returned fields.
• More Website Downtime: Due to cascading updates, and
service entanglement.
Problems
14. • Code Reusability: Write once. Share with web, mobile, etc.
• Consistency: Everything works the same across platforms.
• Security: Security is at the forefront: do not leak sensitive data.
• Performance: Process more stuff, faster.
API v2 is continuously improved and optimized.
• Scalability: Easier to move to Service-oriented Architecture.
Free to change and improve underlying functionality.
• Better Debugging: Now you can actually debug.
Benefits
of API v2 (“Graphist”)
15. • Hundreds of Developers
• Thousands of Endpoints
• Dozens of Services
Where it’s Used
19. Client-Centric
Shifts the impetus of
“formats” to the client;
no more dev back-
and-forth.
Efficient
Solves over-fetching,
under-fetching, even
versioning; cross-
platform tools.
Community
Ready-made
developer tools:
sandbox,
documentation
explorer.
Flexible
Allows for arbitrary
functions, renamed
attributes, and more.
Why GraphQL?
Hope to inspire
What we’ve done, what we’re working on
We have many platforms
Where did the Airbnb API come from?
(We don’t have a public API)
I was an iOS engineer
We have many platforms
Where did the Airbnb API come from?
(We don’t have a public API)
The mobile apps depending on API v1, which was built in a rush, back in 2012, so that we could release the first version of the mobile app. The API allows the apps to have a structured way to access our data, and make bookings.
And then there was our website, which also used rails controllers to access data. These two were different, to allow them to iterate rapidly and independently. API code didn’t share much in common with web, and features and changes for web, would have to be re-written for mobile. Unfortunately, it wasn’t just mobile and web. There was mobile web, other services, lantern our cx tool. As we grew, this became more of a problem.
To address these problems, we started moving to a new system in early 2015
3 years in development
API v2, also known as the ruby gem “Graphist”
REST can be limiting.
What is GraphQL? A Query language? It is NOT client or server side.
It has things like introspection built in