Before you can display API data on your WordPress site, you need to configure the API connection. This article walks you through configuring the API endpoint, HTTP method, authentication, and request details.
Overview
When you create a new API, you are essentially setting up a connection profile that defines:
- Where the data comes from (the API endpoint URL)
- How to request it (HTTP method like GET or POST)
- Any credentials or authentication required
- Additional parameters, headers, or request body data
- How to format the response from the API – this is the display part
Basic Configuration
API Name
Give your API a short, but descriptive name that helps you remember what this API does. Examples: “Weather Data API”, “Product Listings”, “Blog Posts from External Source”. This name appears in your WordPress admin and helps you identify which API to use when displaying data.
Endpoint URL
Enter the complete URL of the API endpoint you want to connect to. This should be the full URL including the protocol (http:// or https://).
Example: https://api.example.com/v1/products
The endpoint URL is where your WordPress site will send requests to retrieve data. Make sure you have the correct URL from the API provider’s documentation.
HTTP Method
Select the appropriate HTTP method for your API request.
For displaying API data on your site, you will typically use GET. If the API documentation says “fetch” or “retrieve”, use GET.
| Method | Use When | Description |
|---|---|---|
| GET | Retrieving data (most common) | Used to fetch data from the API. Does not modify anything on the server. |
| POST | Sending data or creating records | Used when you need to send data in the request body. |
| PUT | Updating existing records | Used to modify existing data on the server. |
| DELETE | Deleting records | Used to remove data from the server. |
| PATCH | Partial updates | Similar to PUT but typically for partial modifications. |
Request Details
Query Parameters
Query parameters are values appended to the URL to filter or customize the API response. They appear after the ? symbol in a URL.
Example URL with parameters: https://api.example.com/products?limit=10&category=electronics&sort=price
In API Press, you can add parameters in key-value pairs:
- limit = 10
- category = electronics
- sort = price
Check the API documentation to see what parameters are available. Common parameters include:
limitorper_page– Maximum number of resultsoffsetorpage– Which page of results to retrievesortororderby– How to sort the resultsfilterorsearch– Filter results
Headers
HTTP headers provide additional metadata for your request. They allow you to specify the format of data you are sending/receiving and can include API keys or other important information.
Common headers include:
| Header | Purpose |
|---|---|
Content-Type |
Specifies the format of data in the request body (usually application/json) |
Accept |
Tells the API what format you want the response in (usually application/json) |
User-Agent |
Identifies your application to the API server |
X-Custom-Header |
API-specific headers that the provider may require |
Most APIs use standard headers by default, but some may require custom headers. Check the API documentation for specific requirements.
Request Body (POST/PUT/PATCH)
If you are using POST, PUT, or PATCH methods, you may need to send data in the request body. The body contains the actual data you want to send to the API.
Body Type: Choose how you want to format the request body:
- form-data – Traditional form submission format (key-value pairs)
- raw JSON – Send data as JSON (useful for APIs that expect JSON)
Add your body parameters as key-value pairs. The format depends on the API documentation and your selected body type.
Authentication
Many APIs require authentication to verify that your requests are legitimate. API Press supports multiple authentication methods:
No Authentication
Some APIs are public and do not require authentication. Leave the authentication settings empty.
Bearer Token
This is the most common authentication method. You receive a token from the API provider and include it in your requests.
How to use:
- Select Bearer Token as the authentication type
- Paste your token into the Bearer Token field
- API Press automatically adds the header:
Authorization: Bearer [your-token]
Basic Authentication (Username/Password)
Some APIs use traditional username and password authentication.
How to use:
- Select Basic Auth as the authentication type
- Enter your username and password
- API Press automatically encodes and sends these credentials with your request
Custom Header Authentication
Some APIs may use custom authentication schemes. For these cases:
- Add the required header in the Headers section
- Use key names provided by your API documentation (for example:
X-API-Key) - Set the value to your authentication credential
OAuth 2.0
This is available in the PRO plugin.
Advanced Settings
Response Format
Select how the API returns data:
- JSON – Most common format. API Press automatically parses this.
- PHP Array – Less common; used when API returns PHP serialized data.
Nearly all modern APIs use JSON format. Check your API documentation if you are unsure.
Timeout
Set the maximum number of seconds to wait for the API to respond. If the API does not respond within this time, the request is cancelled.
Recommended value: 10-30 seconds. Set to 0 to use WordPress default timeout (usually 5 seconds).
Cache Duration
Tell API Press to cache the API response for a specified number of seconds. This improves page load speed and reduces the number of requests to the API.
How it works:
- Set to 0 (default) to fetch fresh data on every request
- Set to 3600 to cache results for 1 hour
- Set to 86400 to cache results for 1 day
When to use caching:
- Data does not change frequently (use longer cache durations)
- The API charges $$ per request (use longer cache durations)
- You want to reduce server load
When not to use caching:
- Data changes very frequently (stock prices, weather, real-time data)
- You are testing the API integration
SSL Certificate Bypass (Advanced)
By default, API Press verifies SSL certificates when connecting to HTTPS URLs. This ensures secure communication. In rare cases, you may need to disable this verification (for example, if the API uses a self-signed certificate in a development environment).
Next Steps
Once your API is configured:
- Test the connection by clicking the Test button to preview the API response
- Move to the next step: Choosing a Display Template to decide how to present the data
- Set up field mapping to connect API response fields to display elements
- Add the API data to your pages using shortcode or template tags
Common Issues and Troubleshooting
Connection Failed
Solution: Check that the endpoint URL is correct, the API is online, and your server can access the internet. Test the URL directly in your browser.
Authentication Failed / 401 Error
Solution: Verify your authentication credentials (token, username/password). Make sure they are correct and not expired. Regenerate the token if needed.
Empty Response / No Data
Solution: Check that your query parameters are correct. The API may be returning an empty result set. Verify parameters match the API documentation.
Invalid JSON Response
Solution: Ensure the response format is set correctly. Some APIs may return XML or other formats that require different handling.
