6 min read
Integrating External Services With WordPress APIs
Last updated: 7 November 2026
WordPress talks to other software through APIs, both its own and other people’s. A payment gateway, a CRM, a map service or an automation tool usually connects to a WordPress site in one of a few ways, and picking the right one decides how secure and how fast the integration is.
Quick answer: To integrate an external service with WordPress, either call the service from WordPress with the HTTP API (wp_remote_get() and wp_remote_post()), or let the service call WordPress through the REST API, authenticated with application passwords or a nonce. Always check capabilities and cache responses with transients.
The three directions an integration can take
Before writing code, decide which way data moves. Most integrations fall into one of three patterns.
WordPress calls an external API. Your plugin or theme requests data from a third-party service, such as a map, a shipping rate or a translation, and uses the response on the page. This is the HTTP API.
An external service calls WordPress. A mobile app, a script or a no-code tool such as Zapier or Make reads or writes content on your site. This is the REST API, usually with application passwords.
A service pushes an event to WordPress. A payment processor or form tool sends a webhook (an HTTP POST) when something happens. WordPress core does not ship a generic webhook receiver, so you register a custom REST route that validates the request and acts on it.
Calling external APIs with the WordPress HTTP API
The HTTP API wraps PHP’s HTTP methods and selects the most suitable transport for each request. Prefer it over calling cURL directly, so your code works across hosting setups.
The main functions are wp_remote_get() to retrieve data, wp_remote_post() to send it, wp_remote_head() to check headers without downloading the body, and wp_remote_request() for other methods such as DELETE. According to the handbook, the defaults include a 5-second timeout and 5 redirects.
Read the result with the helper functions: wp_remote_retrieve_response_code() for the status code, wp_remote_retrieve_body() for the body, and wp_remote_retrieve_headers() for headers. Check is_wp_error() on the return value first, because a failed connection returns a WP_Error object instead of a response array.
When the URL comes from user input or a setting, use wp_safe_remote_get() instead. The function reference says it validates the requested URL and each redirect with wp_http_validate_url() to guard against server-side request forgery (SSRF), and allows only http and https.
Cache what you fetch
External calls slow your pages down and many APIs rate-limit requests. The handbook recommends caching API responses with transients: set_transient() stores a value for a number of seconds, get_transient() reads it and delete_transient() clears it. Do not cache real-time data or responses the API marks as uncacheable.
A small example: show a weather or exchange-rate widget by fetching once an hour, storing the decoded response in a transient, and serving visitors from that copy.
Letting outside services reach WordPress with the REST API
The REST API is an interface that lets applications interact with a WordPress site, and it exchanges data as JSON. Posts, pages, users and media are available at routes under /wp-json/wp/v2/, and you can add your own.
Authentication: cookies, nonces and application passwords
The authentication chapter of the handbook covers two approaches you will use most.
Cookie authentication with a nonce is for code running inside the logged-in WordPress dashboard or front end. Because of CSRF risk, the REST API requires a nonce created with the action wp_rest, sent in the X-WP-Nonce header or the _wpnonce parameter. Without it, the request is treated as unauthenticated (current user 0), even if you are logged in. The built-in JavaScript client handles this for you.
Application passwords are for external clients. Introduced in WordPress 5.6, they are generated on the Edit User screen and sent with HTTP Basic Authentication over HTTPS. One advantage is that you can create one password per integration and revoke it without changing the user’s login password. The handbook recommends them over the separate Basic Authentication plugin, which it describes as meant only for development and testing.
Build a custom endpoint safely
To expose your own data, register a route on the rest_api_init hook with register_rest_route(). The custom endpoints guide sets out the rules worth following.
Use a namespace such as your-plugin/v1 so routes do not clash with other plugins, and bump the version when you break compatibility. Set a permission_callback on every route. Since WordPress 5.5, leaving it out triggers a _doing_it_wrong notice, and a genuinely public endpoint should say so explicitly with __return_true.
Inside the permission callback, call current_user_can() with the narrowest capability that fits, for example edit_posts or a custom capability, rather than checking only that someone is logged in. Validate and sanitize inputs with the validate_callback and sanitize_callback options in args.
Webhooks, Zapier and Make
No-code tools are the quickest way to connect WordPress to dozens of other apps without writing PHP. In practice they use the same two mechanisms above: they call your REST API using an application password, or they send a webhook to a URL you provide.
If you receive webhooks, treat every request as untrusted. Register a REST route, verify the sender before acting (most services sign their requests with a shared secret; check the vendor’s documentation for the exact header and method), validate the payload, and respond quickly with the correct HTTP status. Do the heavy work in a background job rather than during the request.
For a worked example of an external API feeding WordPress, see how to use the Google Indexing API to get jobs listed on Google Jobs, and our notes on Google API configuration.
Security and performance checklist
A short list to run through before shipping any integration:
- Store API keys outside your theme files, for example in options with restricted access or in environment constants, and never print them in page output.
- Use HTTPS for every request, and for application passwords it is required.
- Check capabilities in every REST permission callback, and verify nonces on any admin-side form or AJAX action you write.
- Set explicit timeouts, handle
WP_Errorresults and show visitors a fallback when the service is down. - Cache responses with transients, and respect the provider’s rate limits.
- Keep a note of each integration’s API version so you notice when the vendor changes it.
Store security is part of the same discipline, as our guide Is WooCommerce safe? shows for payment integrations.
Summary
Use the HTTP API when WordPress needs data from another service, and the REST API when another service needs WordPress. Authenticate with nonces or application passwords, check capabilities on every route, and cache what you fetch. Get those four things right and most integrations stay secure and fast.
Frequently asked questions
How do I call an external API from WordPress?
Use wp_remote_get() or wp_remote_post() from the HTTP API, then read the result with wp_remote_retrieve_body() and check for errors with is_wp_error(). Set a timeout and cache the response in a transient.
What are WordPress application passwords?
They are per-integration passwords generated from a user’s Edit User screen, available since WordPress 5.6. External clients send them with HTTP Basic Authentication over HTTPS, and you can revoke one without changing the account password.
Do I need a nonce for the REST API?
For cookie-authenticated requests, yes: send a nonce for the wp_rest action in the X-WP-Nonce header. Without it, WordPress treats the request as unauthenticated. External clients using application passwords do not use nonces.
What should a permission_callback do?
It runs before your endpoint callback and returns true, false or a WP_Error. Use current_user_can() inside it to check the right capability, and use __return_true only for endpoints that are truly public.
Can WordPress receive webhooks?
Yes, through a custom REST route. Core has no generic webhook receiver, so you register the route, verify the sender, validate the payload and return a proper status code.
Are Zapier and Make safe to connect to WordPress?
They connect through the REST API with an application password or through a webhook URL. Create a dedicated user with a limited role for the integration so a leaked password exposes as little as possible.
Related reading

