How to Create a REST API — Spring Boot and Ballerina

Nadeeshaan Gunasinghe
Ballerina Swan Lake Tech Blog
6 min readFeb 18, 2022

--

Today, there are numerous programming languages and frameworks for creating REST APIs and Microservices. Among such frameworks, Spring Boot has become one of the most widely adopted Java frameworks.

A couple of weeks back, the Ballerina team announced the General Availability of the SwanLake version of the Ballerina Programming language, which is a general-purpose programming language designed for the cloud which allows the developers to easily write network services.

In this post, I’m going to look at how to implement a REST API with Spring Boot as well as with Ballerina. We will be looking at how both of these technologies are going to address a network service use case from different perspectives and what are the features associated with them.

You can access the full source code of the two implementations in Github

Our use case

Our use case is going to be a simple one which is a hotel reservation API with two HTTP resources as follows.

  1. GET — /bookings/{id} => Get a booking with the given ID
  2. POST — /bookings => Add a new Booking

Here I’m keeping the data in memory and in this example, no database will be used. I’ll be discussing the database access in a later post.

--

--

Nadeeshaan Gunasinghe
Ballerina Swan Lake Tech Blog

Autor, Technical Lead at WSO2, Microservices Enthusiast, Full-stack Developer, Hardcore Cricket Fan, Sci-fi Addict ;)