Title: WP_REST_Server::__construct
Published: December 9, 2015
Last modified: April 28, 2025

---

# WP_REST_Server::__construct()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_server/__construct/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rest_server/__construct/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_server/__construct/?output_format=md#changelog)

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

Instantiates the REST server.

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

    ```php
    public function __construct() {
    	$this->endpoints = array(
    		// Meta endpoints.
    		'/'         => array(
    			'callback' => array( $this, 'get_index' ),
    			'methods'  => 'GET',
    			'args'     => array(
    				'context' => array(
    					'default' => 'view',
    				),
    			),
    		),
    		'/batch/v1' => array(
    			'callback' => array( $this, 'serve_batch_request_v1' ),
    			'methods'  => 'POST',
    			'args'     => array(
    				'validation' => array(
    					'type'    => 'string',
    					'enum'    => array( 'require-all-validate', 'normal' ),
    					'default' => 'normal',
    				),
    				'requests'   => array(
    					'required' => true,
    					'type'     => 'array',
    					'maxItems' => $this->get_max_batch_size(),
    					'items'    => array(
    						'type'       => 'object',
    						'properties' => array(
    							'method'  => array(
    								'type'    => 'string',
    								'enum'    => array( 'POST', 'PUT', 'PATCH', 'DELETE' ),
    								'default' => 'POST',
    							),
    							'path'    => array(
    								'type'     => 'string',
    								'required' => true,
    							),
    							'body'    => array(
    								'type'                 => 'object',
    								'properties'           => array(),
    								'additionalProperties' => true,
    							),
    							'headers' => array(
    								'type'                 => 'object',
    								'properties'           => array(),
    								'additionalProperties' => array(
    									'type'  => array( 'string', 'array' ),
    									'items' => array(
    										'type' => 'string',
    									),
    								),
    							),
    						),
    					),
    				),
    			),
    		),
    	);
    }
    ```

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

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

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

Gets the maximum number of requests that can be included in a batch.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rest_server/__construct/?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%2Fclasses%2Fwp_rest_server%2F__construct%2F)
before being able to contribute a note or feedback.