Title: rest_api_init
Published: December 9, 2015
Last modified: May 20, 2026

---

# rest_api_init()

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/rest_api_init/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/rest_api_init/?output_format=md#see-also)
 * [Source](https://developer.wordpress.org/reference/functions/rest_api_init/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/rest_api_init/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/rest_api_init/?output_format=md#changelog)

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

Registers rewrite rules for the REST API.

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

### 󠀁[See also](https://developer.wordpress.org/reference/functions/rest_api_init/?output_format=md#see-also)󠁿

 * [rest_api_register_rewrites()](https://developer.wordpress.org/reference/functions/rest_api_register_rewrites/)

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

    ```php
    function rest_api_init() {
    	rest_api_register_rewrites();

    	global $wp;
    	$wp->add_query_var( 'rest_route' );
    }
    ```

[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#L208)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/rest-api.php#L208-L213)

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

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

Adds REST rewrite rules.

  | 
| [WP::add_query_var()](https://developer.wordpress.org/reference/classes/wp/add_query_var/)`wp-includes/class-wp.php` |

Adds a query variable to the list of public query variables.

  |

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

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

## User Contributed Notes

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