Connect to WordPress
You can connect to WordPress using Retool's REST API integration and make it available as a resource. Once complete, you can write queries to interact with the WordPress API.
Requirements
All users for Retool organizations on Free or Team plans have global Edit permissions and can add, edit, and remove resources. If your organization manages user permissions for resources, you must be a member of a group with Edit all permissions.
To create your WordPress resource, you need:
- REST API connection details.
- Basic Auth authentication details.
WordPress uses Basic authentication. You must provide a username and password for Retool to authorize requests. Refer to the WordPress documentation on authenticating requests to learn how to obtain the username and password.
If WordPress is behind a firewall, you must also allow access from Retool's IP addresses. Add these IP addresses to your firewall's allowlist before you create the resource.
1. Create a new resource
Sign in to your Retool organization and navigate to the Resources tab. Click Create new, then select Resource.
Retool can connect to almost any API or database, and has built-in integrations for popular data sources. Select the REST API integration.
2. Configure the resource
Provide the necessary details to configure the resource so Retool can connect to WordPress. Not all settings are required but refer to the WordPress documentation to learn what is needed.
General
These settings configure the name and location of the resource within Retool.
Name
The name to use for the resource (e.g., WordPress).
Folder
The folder in which to save the resource.
Description
A brief description of the resource (e.g., WordPress data).
Credentials
These settings configure how Retool connects to WordPress.
Base URL
The base URL for the WordPress API. This must be an absolute URL. Use https://example.com/wp-json/wp/v2/
.
URL parameters
Key-value pairs to include as URL parameters with WordPress API requests. No additional URL parameters are required.
Headers
Key-value pairs to include as headers with WordPress API requests. No additional header values are required.
Body
Key-value pairs to include in the body of WordPress API requests. No additional body values are required.
Cookies
Cookies to include with WordPress API requests. No cookies are required.
Authentication
The method of authentication to use with WordPress. Select Basic Auth
.
Setting | Description |
---|---|
Username | The username for authentication. |
Password | The password for authentication. |
Forward all cookies
Whether to forward all cookies. This is useful if you have dynamic cookie names.
3. Save the resource
Click Create resource to complete the setup. You can then click either Create an app to immediately start building a Retool app or Back to resources to return to the list of resources.
Wrap up
Your WordPress resource is now ready to use. You write queries to make API requests by specifying the request method and endpoint, additional parameters to include, and the request body.
To verify you can successfully interact with WordPress, write a test query to retrieve some data. The following example retrieves a single page's data.
- Request
- Response
GET https://example.com/wp-json/wp/v2/pages/1
{
"id": 1,
"date": "2023-01-30T12:57:34",
"date_gmt": "2023-01-30T20:57:34",
"guid": {
"rendered": "https://example.com/?page_id=1"
},
"modified": "2023-05-08T07:14:22",
"modified_gmt": "2023-05-08T14:14:22",
"slug": "activities",
"status": "publish",
"type": "page",
"link": "https://example.com/activities/",
"title": {
"rendered": "Activities"
},
"content": {
"rendered": "\n<h3 class=\"wp-block-heading\">Regular activities</h3>",
"protected": false
}
...
}