Skip to main content

External API Requests

Guide on external API requests and what to do if external API responds slowly.

In WordPress, external API requests are connections your site makes to services outside your own server using the WordPress HTTP API (wp_remote_get(), wp_remote_post(), etc.).

Examples:

  • Checking for WordPress updates from api.wordpress.org

  • Premium plugin license validation

  • Premium plugin update checks

  • Payment gateway communications (Stripe, Klarna, etc.)

  • Sending data to CRMs, analytics, or marketing platforms

  • Fetching exchange rates, weather data, or other third-party information

What to Do if External API Responds Slowly

If an external API responds slowly, the best approach is usually to reduce the impact on the website rather than waiting longer for the API.

Common solutions:

  • Cache the API response so WordPress does not call the API on every page load

  • Run the API call asynchronously via WP-Cron, Action Scheduler, or background jobs instead of during visitor requests

  • Implement retries and graceful fallbacks if the API is temporarily unavailable

  • Monitor API response times and contact the vendor if their service is consistently slow

  • Store critical data locally and sync periodically rather than fetching it live on every request

If you have identified that slow API request is not due to conflict or slow database query on the site you should contact API provider about this issue.

WP_HTTP_BLOCK_EXTERNAL

If WP_HTTP_BLOCK_EXTERNAL is enabled outbound requests are blocked unless the target host is specifically allowed in WP_ACCESSIBLE_HOSTS. As a result, plugins or custom functionality like payment gateway APIs or SMTP that rely on external services may stop working correctly. For example this will prevent plugins from working and core functionality, if you don’t include api.wordpress.org.

Example definitions in wp-config.php:

/**
* Block WordPress external requests and allow only
* *.wordpress.org URLs for e.g. wp_remote_get function
*/
define( 'WP_HTTP_BLOCK_EXTERNAL', true );
define( 'WP_ACCESSIBLE_HOSTS', '*.wordpress.org' );

Warning!

Using WP_HTTP_BLOCK_EXTERNAL without defining all necessary WP_ACCESSIBLE_HOSTS will break plugins or custom functionality that rely on external API requests to function.

Did this answer your question?