Helidon: Microservice REST API


Writing REST API with the Helidon framework is not a hard job since it is compliant with Microprofile specification. The good part is that we don’t need to learn any new technology or annotation to achieve this. In this example below I am going to explain how to write REST API by following Helidon MP.

The code is as follows,

public class Country {
    private String code;
    private String name;
    private String capital;

    public Country() {}

    public Country(String code, String name, String capital) {
        this.code = code;
        this.name = name;
        this.capital = capital;

    public String getCode() {
        return code;

    public String getName() {
        return name;

    public String getCapital() {
        return capital;
public class CountryManager {
    public List<Country> all() {
        return CollectionsHelper
                        new Country("IND", "India", "New Delhi"),
                        new Country("AUS", "Australia", "Canberra")
public interface ICountryApi {
    Response all();
public class CountryApi implements ICountryApi {
    CountryManager manager;

    public Response all() {
        System.out.println("Enters Country api");
        return Response
//Finally add an entry into the application
public class DailyApiApplication extends Application {

    public Set<Class<?>> getClasses() {
        return CollectionsHelper.setOf(
Finally access the API using,

The code is so simple and straight forward. The entire code follows the annotation of JAX-RS specification which is part of our Microprofile specification. So the learning curve is nothing and no code is specific with Helidon. This is the beauty of Microprofile and the compliant frameworks. We can simply move this code to different Microprofile vendors based on our organization strategy changes. No code change is required to move between vendors.

{ Happy coding }