Web APIs are not just useful when making headless sites in Drupal: large Drupal sites often hold valuable information that could also be useful outside the site's context. Media companies might want to expose historical media content, community sites could show data about their community activities, e-commerce sites tend to open an API for their affiliates and partners.
While it is possible to use Drupal 7 and Drupal 8 as an API backend, a lot of functionalities that describe a mature API service do not come out of the box. In this post we will explain what key concepts you have to keep in mind when designing an API service, why they are important and how APIgee Edge can make it easier to build a full-featured API webservice in Drupal successfully.
Designing APIs: the API first strategy
In a large part of the software development industry, API first thinking is replacing a user interface design approach. API first design is about planning and documenting your API before it would be implemented in code. If you set up your backend service this way, you can use it with different clients regardless of the way they were implemented. API first strategy allows you to diversify user interfaces: UI developers can work without knowing how your backend service works.
Building good backend services is not easy, there are plenty of pitfalls on the road and most of them only reveal themselves during development. Your responsibilities as a service provider grow with the number of clients:
- maintaining the security of your services (especially if you are providing paid services),
- handling compatibility problems between client apps and different app versions,
- ensuring that your services are able to handle unexpected loads.
You can’t handle all of these tasks without monitoring the services. Especially for monetization, monitoring is crucial.
Features to keep in mind for building good API backend services
Security is one of the most important trust signals of a mature API. A multi-layered protection system should be able to hide your non-public services from the public, handle the authorization processes, and protect the original resources from attackers.
Compatibility issues are the nightmares of service providers: versioning your APIs is your first step to harmony.
Successful services have to handle an enormous number of requests every second and your services have to scale with the number of your new clients. Sometimes moving your backend to better hardware does not help, because the root of the problem is in the initial architectural decisions or implementations.
You need exact analytics about the usage of your API: it is indispensable for monetization purposes, plus you could use analytics data to improve your service and to understand your users' behavior.
Good documentation is an essential part of the API service, as this is the first line of support for developers trying to understand and learn how to use the API. Developer portals often have different kinds and levels of supporting material from getting started pages to various guides, case studies, playbooks, and tutorials.
You will need an authorization and monitoring system to efficiently track and bill customers for using your services. Exposing different resources of your APIs individually or grouped, and setting up usage limits based on these “API products” can be a time consuming task.
Companies specialized in API management solutions
You can choose from many API management technologies to build an API service, but each technology stack has its own limitations. Some companies have specialized to help you solve (a part of) the problems that might occur. Our non-exhaustive list of such companies as an example (company descriptions are from Crunchbase):
- 3scale’s API management platform empowers API providers to easily package, distribute, manage and monetize APIs.
- Apiphany provides API management and delivery solutions that enable organizations to leverage the mobile, social and app economy.
- Layer 7 Technologies provides security and management products for API-driven integrations spanning the extended hybrid enterprise.
- MuleSoft provides integration software for connecting applications, data and devices. MuleSoft's software platform enables organizations to build application networks using APIs.
- Mashery is a TIBCO company providing API management services that enable companies to leverage web services as a distribution channel.
- StrikeIron offers a cloud-based data quality suite offering web-based infrastructure to deliver business data to internet-connected systems.
- Apigee is the leading provider of API technology and services for enterprises and developers.
The rest of this article will focus on Apigee (recently acquired by Google). Disclaimer: Pronovix is an Apigee partner, so we are somewhat biased. However, even if we wouldn’t be partners, we believe they are probably the best API management service provider for Drupal projects. They are not only a market leader in the space, they have also invested in a Drupal integration: Apigee Edge.
Apigee Edge: a Drupal integration for API services
Built in JAVA, Apigee Edge is able to replace or enhance complicated parts of your services. API proxies will protect your services from direct customer access (as they guard the backend code), and add the above mentioned 6 key features to your APIs. Apigee Edge manages these features in a specific way.
Apigee Edge enables you to control the behavior of your APIs (without writing a single line of code) via policies. A policy is similar to a module that implements a specific, limited function that is part of the proxy request/response flow. You can add various types of management features to an API by using policies.
Traffic management policies
With cache policies you can set up traffic quotas and concurrent rate limits on your API proxies.
Mediation policies let you do custom validation and send back custom messages and alerts to your clients, independently from your backend services. Moreover, you do not need to implement separate xml serialization in your services to accept requests or send responses in XML, because the JSON to XML and XML to JSON policies are capable to do automatic conversions between these formats.
Security policies give access control management to your APIs with different types of authorization methods and protection features.
A great developer experience is crucial for API adoption. Apigee Edge has a developer portal solution that is built in Drupal 7 with API documentation, forums and blog posts that come out of the box. API developer portals done well are your power tools to help the adoption of your API and build strong communities. Apigee's dev portals could be hosted either on cloud or on-premises with Apigee Edge for Private Cloud.
We hope this introduction gave you some insight into building high-performance API web services.
Disclaimer: When we specialised Pronovix in API documentation and developer portals we started a partnership with Apigee, and we do extensive work customising the Apigee developer portal.
Are you building a developer portal? Interested in a shortcut? As a devportal specialist, Pronovix has created developer portals for 40+ customers in the past 4 years. Talk with us to learn how our SaaS developer portal can accelerate and simplify your launch.Read More about our Devportal Solutions Contact us >