RESTful Web APIs are one of the many tools that a developer has at their disposal in the modern development world. As such there are many ways of creating these web APIs and many frameworks to assist you in creating them. At OptimalBI we have a sudden need for a RESTful API and have decided to sort the men from the boys in the RESTful framework world.
So what is a RESTful API anyway?
“In computing, representational state transfer (REST) is an architectural style consisting of a coordinated set of components, connectors, and data elements within a distributed hypermedia system, where the focus is on component roles and a specific set of interactions between data elements rather than implementation details. Its purpose is to induce performance, scalability, simplicity, modifiability, visibility, portability, and reliability. REST is the software architectural style of the World Wide Web.” – Representational state transfer, Wikipedia
That’s cleared things up right, thanks, Wikipedia! No? Well, that’s because in practice a RESTful API implies much more than anything that has been written in a specification or design document for RESTful. When developers think RESTful API they think of an HTTP endpoint with a certain set of possible HTTP methods and resources that can provide data or functionality depending on their design and implementation. Hmm, that description didn’t clear much up either. Let’s show an example!
For this example, we will try and get a users email when we have their username from a made-up REST API and in a made up language.
With a typical RESTful interface, this process is very simple. With our made up address for our API being http://api.coolapis.com we can try to receive some information about a certain user by calling methods on this endpoint. We have the username, and in API-land, there are two common ways to ask the server a question using this.
We could get the information stored at http://api.coolapis.com/users/bobdylan/ (where bobdylan is the user we are interested in), which would typically return all the information available on the user in a handy JSON or similar format. Once we have the information from that endpoint all we need to do is extract the email from that field. This method is referred to as a GET request.
Another way of asking for the information is via a POST request, the main difference being is that the outgoing (client -> server) information in a GET request is visible to everyone even in https, whereas POST stores this information in a more hidden fashion. For POST the endpoint would be something like http://api.coolapis.com/user/ but then the body would include {user:”bobdylan”} so that server still knew about which user we wanted to retrieve.
What is a RESTful API Going To Do For Us?
At OptimalBI we use RESTful APIs to provide a go-to connection point for securely accessing our services. This acts as both a secure interaction layer and a single abstraction point where we can hide multiple services behind one simpler and easier to use interface. For Optimal the list of things that a web service must connect to are as follows:
- Optimal Data Engine (ODE) running under SQL Server 2014.
- DynamoDB
- Redshift
- S3 via the AWS SDK
- AWS Lambda
- Neo4J
- Other HTTP Endpoints
If a web framework can connect to all these services than we can integrate our system easier. If not then that makes the architecture more difficult but not impossible.
The framework must be able to sit behind an AWS Elastic Load Balancer. We will not investigate that in this process, but there might be a follow-up blog further down the line.
The Process of Elimination
For this particular piece of research into the RESTful API space, we are going to be following stages where one capability of each of the frameworks as assessed. At the end of each stage, any framework that performs poorly will be eliminated. The further a framework gets the more in-depth the testing at each stage becomes, up to the last stage where a short example of a restful API will be created in that framework.
The Frameworks
This is the list of contenders. Please note this is not an exhaustive list of frameworks, but a list of mature well-formed frameworks that could fit the current development processes at OptimalBI.
- ASP.Net
- AWS API Gateway with AWS Lambda
- Spring (Java)
- Express (Node.js)
- Loopback (Node.js)
- Restify (Node.js)
- Django (Python)
- Flask (Python)
- Rails (Ruby)
Did I miss any big ones? Please leave a comment and tell us so that we can include it in the great framework showdown.
Next Time
In-depth requirements for REST, and Stage One: Platform Analysis
Coffee to Code – Tim Gray
Tim blogs about the sharp end of code and the languages it is written in.
You can read Tim’s “What’s The Best Restful Web API Framework” Part 2, Part 3, Part 4, Part 5 and Part 6 to get the whole picture.