13.3 Using REST APIs as Data Sources
To work with data from REST APIs, use a REST Data Source. Each one
you create can support one or more standard REST operations to GET,
PUT, POST, PATCH, or
DELETE data from a REST API whose endpoint URL you
configure.
At runtime, APEX automatically uses the web credential you associate with it to authenticate access. If the service supports returning data in pages, you can choose from a number of common pagination strategies.
You can specify various kinds of parameters at the service or operation level to get data into and out of an API call. To simplify using the data the API returns in your pages, you specify Data Profile columns that let APEX treat the data as a rowset. In many cases, App Builder can discover these column descriptions automatically, which you can then further adjust to fit your requirements.
Once you've defined a REST Data Source, you can use it almost anywhere in your application. This means in any APEX region, List of Values, or other dynamic list use cases. You do this by choosing a source Location of REST Source. When useful, you can easily augment the data retrieved from the REST API to perform additional filtering, ordering, and joins to combine remote data with local data. To improve performance, you can take advantage of various caching options as well as local synchronization of less-frequently-changing data on a schedule you define.
If your REST Data Source supports appropriate operations enabling insert, updates, and deletes, your pages can also use it to create and modify data as well. Some API suites define convention-based enhancements for filtering, sorting, and modifying data. APEX natively supports these features for Oracle Fusion Applications, Oracle REST Data Services, and OData. For other situations, you can create a custom REST adapter plug-in to provide the same seamless, extended data access for any other API suite you may need to integrate with.
- Using a Simple HTTP REST Data Source
The Simple HTTP service is the most generic and flexible REST Data Source type APEX offers. By understanding its capabilities and how to configure them, you can confidently integrate with any necessary API. - Service URL Uses Remote Server
When working with REST APIs, you often use several endpoints from the same remote server. These service URLs share a base URL, including the domain name and any common path segments. Only the trailing part of the Service URL differs. - Data Profile Helps Turn JSON Into Rows
Each REST Data Source includes a Data Profile. Its details let APEX automatically convert a REST API's JSON response into rows like a database query returns. - Retrieving Remote Data Page by Page
To configure pagination behavior on your Simple HTTP REST Data Source, use the Settings tab on the edit page. - REST Operations and Database Actions
You can define one or more operations for each REST Data Source. APEX queries, inserts, updates, or deletes rows using the operation whose Database Action is appropriate to each task. It uses the operation's HTTP Method when sending the HTTP request to the REST API endpoint URL. - Configuring a Request Body Template
Your operations for Insert row and Update row need to send data to the REST API in the request body. - Supply and Return Values with Parameters
Just as PL/SQL procedures can defineIN,OUT, andIN/OUTparameters, so can REST Data Sources. Define a parameter at the operation level if it's specific to that action, or at the data source level if it's relevant to all operations.
Parent topic: Integrating Remote Data