Title: wp_is_rest_endpoint
Published: April 3, 2024
Last modified: May 20, 2026

---

# wp_is_rest_endpoint(): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#description)
 * [Return](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#wp--skip-link--target)

Checks whether a REST API endpoint request is currently being handled.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#description)󠁿

This may be a standalone REST API request, or an internal request dispatched from
within a regular page load.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#return)󠁿

 bool True if a REST endpoint request is currently being handled, false otherwise.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#source)󠁿

    ```php
    function wp_is_rest_endpoint() {
    	/* @var WP_REST_Server $wp_rest_server */
    	global $wp_rest_server;

    	// Check whether this is a standalone REST request.
    	$is_rest_endpoint = wp_is_serving_rest_request();
    	if ( ! $is_rest_endpoint ) {
    		// Otherwise, check whether an internal REST request is currently being handled.
    		$is_rest_endpoint = isset( $wp_rest_server )
    			&& $wp_rest_server->is_dispatching();
    	}

    	/**
    	 * Filters whether a REST endpoint request is currently being handled.
    	 *
    	 * This may be a standalone REST API request, or an internal request dispatched from within a regular page load.
    	 *
    	 * @since 6.5.0
    	 *
    	 * @param bool $is_request_endpoint Whether a REST endpoint request is currently being handled.
    	 */
    	return (bool) apply_filters( 'wp_is_rest_endpoint', $is_rest_endpoint );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/rest-api.php#L3478)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/rest-api.php#L3478-L3500)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#hooks)󠁿

 [apply_filters( ‘wp_is_rest_endpoint’, bool $is_request_endpoint )](https://developer.wordpress.org/reference/hooks/wp_is_rest_endpoint/)

Filters whether a REST endpoint request is currently being handled.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_is_serving_rest_request()](https://developer.wordpress.org/reference/functions/wp_is_serving_rest_request/)`wp-includes/functions.php` |

Determines whether WordPress is currently serving a REST API request.

  | 
| [WP_REST_Server::is_dispatching()](https://developer.wordpress.org/reference/classes/wp_rest_server/is_dispatching/)`wp-includes/rest-api/class-wp-rest-server.php` |

Returns whether the REST server is currently dispatching / responding to a request.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#)

| Used by | Description | 
| [wp_should_load_block_assets_on_demand()](https://developer.wordpress.org/reference/functions/wp_should_load_block_assets_on_demand/)`wp-includes/script-loader.php` |

Checks whether block styles should be loaded only on-render.

  | 
| [_wp_theme_json_webfonts_handler()](https://developer.wordpress.org/reference/functions/_wp_theme_json_webfonts_handler/)`wp-includes/deprecated.php` |

Runs the theme.json webfonts handler.

  | 
| [wp_should_load_separate_core_block_assets()](https://developer.wordpress.org/reference/functions/wp_should_load_separate_core_block_assets/)`wp-includes/script-loader.php` |

Checks whether separate styles should be loaded for core blocks.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_is_rest_endpoint/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.5.0](https://developer.wordpress.org/reference/since/6.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_is_rest_endpoint%2F)
before being able to contribute a note or feedback.