Introduction:
In modern web applications, RESTful APIs play a crucial role in enabling seamless communication between systems, applications, and services. Oracle REST Data Services (ORDS) allows developers to expose database resources through RESTful web services in a secure and scalable manner. Oracle APEX 21.2.0, tightly integrated with ORDS, empowers developers to build APIs that are not only efficient but also reusable across multiple applications or modules.
Creating a reusable API component using ORDS in Oracle APEX reduces development time, increases consistency, and enhances maintainability across projects.
The following technologies have been used to achieve the same.
Oracle APEX 21.2.0, Postman
Why we need to do: –
- Standardization: APIs ensure a standardized way of accessing and manipulating data across applications.
- Reusability: Reusable components reduce redundancy, making it easier to manage and update functionality in one place.
- Integration: REST APIs enable easy integration with external systems or front-end frameworks (e.g., React, Angular).
- Scalability: RESTful design supports stateless interaction, improving scalability and performance.
- Security: ORDS provides built-in mechanisms to secure endpoints via roles, privileges, and authentication schemes.
How do we solve:
- Navigate to RESTful Services in Oracle APEX
From the APEX home page, go to SQL Workshop → RESTful Services.
Select the appropriate schema (e.g. HR) from the dropdown.
- Create a New Module
Click on Modules in the left menu, then select the “Create Module” button.
Fill in:
- Module Name (e.g., test_api)
- Base Path (e.g., /firstApi/)
- Then click Create Module to generate the base URL which incorporates your schema alias.
- Define a Resource Template
After creating the module, click “Create Template”.
Enter the URI Template (e.g., HolidayList) — this will form the endpoint path under your module base.
Click Create Template to continue.
- Creating Handler for the template
Once the template is created, please click ‘Create Handler’ at the bottom of the screen.
- Once the handler is created, select Method as GET and Source Type as Query.
- Enter the SQL below in the Source section and set the Format to JSON.
- Finally, click Create Handler to complete the setup.
- Steps to Fetch Holiday List from API Using Postman
- Open Postman.
Set the Request Type:
- From the dropdown menu on the left of the URL field, select GET
- Enter the API Endpoint URL:
Type or paste the full URL in the request field.
https://your_ip_address/apex/hr/firstApi/HolidayList
- Click the “Send” Button:
- Hit the blue “Send” button on the right side of the URL field.
- View the Response:
- You will see a response in the Body section at the bottom of the screen.
- The status code will show as 200 OK, indicating that the request was successful.
- Response data (in JSON format) will be displayed.
Example: json
{
“items”: [
{
“festival_name”: “NEW YEAR’S DAY”,
“holiday_date”: “01/01/2025”,
“holiday_day”: “WEDNESDAY”
}
]
}
Conclusion :-
Creating APIs using ORDS in Oracle APEX offers a streamlined, secure way to expose database functionalities as reusable web services. It simplifies integration with modern applications while promoting code reusability and consistency. Using tools like Postman helps validate endpoints and ensure accurate responses. Overall, this approach accelerates development and enhances maintainability across enterprise applications.