<http://schema.org/articleBody>
"Daniel Jacobson (Twitter\u00A0|\u00A0LinkedIn), is currently director of engineering for the\u00A0Netflix\u00A0API. Prior to Netflix, Daniel ran application development for\u00A0NPR\u00A0where, among other things, he created the\u00A0NPR API. He is also the co-author of\u00A0APIs: A Strategy Guide.\r\n\r\n\r\n\r\nThe digital world is expanding at an amazing rate, giving us access to applications and content on myriad connected devices in your homes, offices, cars, pockets and on even on your body. The glue that allows all of this to happen, that connect the companies who provide these services to the devices that you use, is the API.\r\n\r\nBecause APIs have such a huge responsibility for so many people and companies, it is natural that API design is often one of the industry's liveliest discussions, touching on a range of topics including resource modeling, payload format, how to version the system, and security.\r\n\r\nWhile these are likely important areas to explore when designing virtually any API, the reality is that a much larger decision needs to be made first. That decision is based on a fundamental question: who are the primary audiences for this API and how can we optimize for those audiences?\r\n\r\nThis seems like an innocuous enough question, but don't underestimate its importance or complexity in the growing world of APIs.\r\nYears ago, this question was much simpler\r\nAt that time, many emerging APIs were being built as open or public APIs, targeting a large set of unknown developers (LSUDs) external to the providing company.\r\n\r\nBecause of the (hopefully) vast numbers of external developers using the API representing different use cases, the most sensible way to design the API for this audience is to have the providing API team design it in a very clean, concise, and resource-oriented way that closely represents the data model and/or features of its source(s).\r\n\r\nIn a previous post, I referred to these as OSFA APIs (or one-size-fits-all APIs). Allowing for such granularity in the modeling means that any developer who wishes to use the API can mix and match the elements in whatever way they choose to satisfy their application without further API team involvement.\r\n\r\nThe resource-model approach to designing an API can be very powerful, especially for this type of audience. The problem with this approach, however, is that the way that many companies use APIs today is different than described above. While many are still supporting the use cases of LSUDs, more are using their APIs to support a growing mobile or device strategy.\r\n\r\nFor some of these implementations, the engagement with the developers is different. The audience is a small set of known developers (SSKDs). They may be engineers down the hall from the API team, a contracted company hired to develop an iPhone app, or an engineering team in a partnering company. In all of these cases, however, the API team knows who these people are (at least in the abstract sense).\r\n\r\nMore importantly, however, the API team and the providing company care about the success of these implementations in a different way than they might care about the applications developed by the LSUDs. In fact, the success of the SSKDs may very well be paramount to the success of the business as a whole, a model that is becoming increasingly more pervasive.\r\n\r\nBecause of this change in audience and the deep interest in their success, there is great opportunity to change the API design.\r\n\r\nFor the SSKDs, having granular resource-based APIs that closely represent the data model works, but it just isn't as optimal as it could be. This is especially the case when you consider the growing number of device types in the world and the fact that more and more companies' business strategies are dependent on providing value to customers on such devices.\r\n\r\nSo, all it takes is a couple of devices with diverging needs and/or capabilities, each of great import to the company, for the resource-based API to start to show some warts. Making the API better, more optimized, for each of these target applications is the next logical, and most critical, step.\r\nEnter the Orchestration Layer\r\nAn API Orchestration Layer (OL) is an abstraction layer that takes generically-modeled data elements and/or features and prepares them in a more specific way for a targeted developer or application\r\nTo address this opportunity, more companies are employing orchestration layers into their API infrastructure. While there are many ways in which to implement this architectural construct, the concept remains the same across all of them.\r\n\r\nBelow, I will describe a few of the more common patterns that I have seen (and/or been involved in implementing). But first, here are a few key principles that need to be considered when building an OL:\r\n\r\n1. Most APIs are designed by the API provider with the goal of maintaining data model purity. When building an OL, be prepared to sometimes abandon purity in favor of optimizations and/or performance.\r\n\r\n2. Many APIs are designed by API teams to make it easier for the API team to support. When building an OL, be prepared to potentially add complexity for the API team (or other teams, depending on the way it is implemented).\r\n\r\nWhile this sounds undesirable, the goal here is to dramatically improve efficiency and/or simplicity for other people at some mild cost to the API team. Also keep in mind that such costs can potentially be programmed away over time.\r\n\r\n3. It is important to understand the breadth of the audiences for the API. Depending on those constituents, you may only need the OL. In other cases, you may need the OSFA foundation in addition to the OL.\r\n\r\nHere are a few examples of how some OLs have been approached:\r\nDevice-specific wrappers\r\nThis is the most common pattern that I have seen because most companies that are experiencing the distress referenced above already have APIs that they still use, continue to support, and invest in. The result is to continue to offer the granular resources as they always have, but to offer a wrapper tier on top of them - with new endpoints that are tailored to specific developers, devices or device clusters.\r\n\r\nIn this model, the API team will work more closely with, for example, the iPhone team to write a custom wrapper that handles specific requests and deliver specific payloads that are optimized for the iPhone app. In this model, most often the team to build the endpoints and the wrappers is the API team although that doesn't have to be the case.\r\nQuery-based APIs\r\nIn this model, the API team is putting the power in the hands of the requesting developer, although that power is limited. The goal here is to create a more flexible way in which the requester can make requests and tailor payloads without putting additional ongoing burden on the API team, as could be the case with the Device-Specific Wrappers.\r\n\r\nThis is achieved by breaking down the resource-based APIs and allowing them to be queried against like a database through flexible parameters and payloads that can contract, expand and possibly morph based on what is needed. The benefit here is that once the query language is set, the API team does not need to keep writing wrappers as new implementations are needed for different devices.\r\n\r\nThe detriment, however, is that the query-based API is still a set of rules to which the developer needs to adhere, although these rules are much more flexible than the resource-based API model.\r\nExperienced-based APIs\r\n\r\n\r\nThis is the model that Netflix has implemented, which in some ways is a blend of the two above. In this model, we basically have device-specific wrappers but they are designed, implemented and owned by the device teams.\r\n\r\nA key concept here is that we have put the API team in the position of gathering the data in a generic, reusable way while putting the device teams in the position of owning the data formatting and delivery. After all, the formatting needs evolve in concert with the UI changes so putting that effort in the hands of those closest to the changes eliminates additional steps.\r\n\r\n(For more details on how this system operates, see the links at the bottom of the post.)\r\n\r\nAs I noted, the range of implementations is potentially much more diverse than these three, although these are some of the most consistent and interesting patterns that I have seen. Regardless of how this is achieved, however, the key is for the API team to stop supporting the API as a service that is designed independent of those SSKDs who consume it.\r\n\r\nRather, the API team needs to view the SSKDs as partners in the design with an interest in making the products as great as possible so the end-users can get the best experience possible. The API team has the opportunity to build services that help developers to be better at developing by focusing on optimizing for the developers\u2019 needs rather than how to optimize the time spent supporting the API.\r\n\r\nGiven the opportunity ahead with the potential number and diversity of connected devices, the effort to provide such optimizations is a small price to pay for the massive upside.\r\nFor more information on the Netflix use case, the problems we encountered that prompted our redesign, and how we implemented our Experienced-Based API, here are a few links:\r\n\r\n\r\n\tWhy REST Keeps Me Up At Night\r\n\tEmbracing the Differences: Inside the Netflix API Redesign\r\n\tOptimizing the Netflix API\r\n\r\nImage credit:\u00A0bloomua/Shutterstock"^^<http://www.w3.org/2001/XMLSchema#string>
<http://thenextweb.com/dd/2013/12/17/future-api-design-orchestration-layer/?_escaped_fragment_=p9h3y>