<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nethusha Ilukpitiya</title>
    <description>The latest articles on DEV Community by Nethusha Ilukpitiya (@nethusha_ilukpitiya_f9229).</description>
    <link>https://dev.to/nethusha_ilukpitiya_f9229</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4136283%2Fd34a7129-31d6-4caf-8d99-f042fca2b75a.jpg</url>
      <title>DEV Community: Nethusha Ilukpitiya</title>
      <link>https://dev.to/nethusha_ilukpitiya_f9229</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nethusha_ilukpitiya_f9229"/>
    <language>en</language>
    <item>
      <title>Building a Cloud-Native RESTful API with Ballerina and MySQL</title>
      <dc:creator>Nethusha Ilukpitiya</dc:creator>
      <pubDate>Mon, 21 Sep 2026 18:26:46 +0000</pubDate>
      <link>https://dev.to/nethusha_ilukpitiya_f9229/building-a-cloud-native-restful-api-with-ballerina-and-mysql-1ee2</link>
      <guid>https://dev.to/nethusha_ilukpitiya_f9229/building-a-cloud-native-restful-api-with-ballerina-and-mysql-1ee2</guid>
      <description>&lt;p&gt;As distributed architectures become standard, writing integration code in traditional general-purpose languages can be repetitive and heavy on boilerplate. Ballerina, an open-source programming language developed by WSO2, is engineered specifically for cloud-native integration and network-aware services.&lt;/p&gt;

&lt;p&gt;In this project, I built a complete bookstore REST API that interfaces with a MySQL database using Ballerina.&lt;/p&gt;

&lt;p&gt;Project Architecture&lt;/p&gt;

&lt;p&gt;The application implements full CRUD operations for book inventory records (id, title, author, isbn, price, and stock):&lt;/p&gt;

&lt;p&gt;service.bal: Exposes endpoints under /api/books using Ballerina's native HTTP listener.&lt;/p&gt;

&lt;p&gt;db.bal: Handles MySQL database interactions using the ballerinax/mysql client.&lt;/p&gt;

&lt;p&gt;types.bal: Defines structured data models for payload validation and schema safety.&lt;/p&gt;

&lt;p&gt;Config.toml: Externalizes sensitive database credentials seamlessly.&lt;/p&gt;

&lt;p&gt;Service Layer &amp;amp; Native Networking&lt;/p&gt;

&lt;p&gt;Defining services and endpoints in Ballerina requires minimal boilerplate:&lt;/p&gt;

&lt;p&gt;Code snippet&lt;br&gt;
import ballerina/http;&lt;/p&gt;

&lt;p&gt;service /api on new http:Listener(8080) {&lt;br&gt;
    resource function get books() returns Book[]|http:InternalServerError {&lt;br&gt;
        Book[]|sql:Error books = getAllBooks();&lt;br&gt;
        if books is error {&lt;br&gt;
            return &lt;a href="http:InternalServerError" rel="noopener noreferrer"&gt;http:InternalServerError&lt;/a&gt;{body: {message: "Internal server error"}};&lt;br&gt;
        }&lt;br&gt;
        return books;&lt;br&gt;
    }&lt;br&gt;
}&lt;br&gt;
Returning typed records like Book[] handles JSON serialization, HTTP headers, and status codes out of the box.&lt;/p&gt;

&lt;p&gt;Database Persistence&lt;/p&gt;

&lt;p&gt;Using ballerinax/mysql, queries leverage parameterized SQL statements to guard against SQL injection while mapping result sets into structured records.&lt;/p&gt;

&lt;p&gt;Source Code&lt;/p&gt;

&lt;p&gt;Full code and setup instructions are available on GitHub:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Nethusha2007/ballerina-bookstore-api" rel="noopener noreferrer"&gt;https://github.com/Nethusha2007/ballerina-bookstore-api&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
