WordPress at a glance
function is not described

WP_REST_Server::get_routes() public WP 4.4.0

Retrieves the route map.

The route map is an associative array with path regexes as the keys. The value is an indexed array with the callback function/method as the first item, and a bitmask of HTTP methods as the second item (see the class constants).

Each route can be mapped to more than one callback by using an array of the indexed arrays. This allows mapping e.g. GET requests to one callback and POST requests to another.

Note that the path regexes (array keys) must have @ escaped, as this is used as the delimiter with preg_match()

This is a method of the class: WP_REST_Server{}

Hooks from the method
Return

Array. '/path/regex' => array($callback,$bitmask) or '/path/regex' => array( array($callback,$bitmask), ...).

Usage

$WP_REST_Server = new WP_REST_Server();
\$WP_REST_Server->get_routes( $namespace );
$namespace(string)
Optionally, only return routes in the given namespace.
Default: ''

Changelog

Since 4.4.0 Introduced.
Since 5.4.0 Add $namespace parameter.

Code of WP REST Server::get routes: wp-includes/rest-api/class-wp-rest-server.php WP 5.4.2

<?php
public function get_routes( $namespace = '' ) {
	$endpoints = $this->endpoints;

	if ( $namespace ) {
		$endpoints = wp_list_filter( $endpoints, array( 'namespace' => $namespace ) );
	}

	/**
	 * Filters the array of available endpoints.
	 *
	 * @since 4.4.0
	 *
	 * @param array $endpoints The available endpoints. An array of matching regex patterns, each mapped
	 *                         to an array of callbacks for the endpoint. These take the format
	 *                         `'/path/regex' => array( $callback, $bitmask )` or
	 *                         `'/path/regex' => array( array( $callback, $bitmask ).
	 */
	$endpoints = apply_filters( 'rest_endpoints', $endpoints );

	// Normalise the endpoints.
	$defaults = array(
		'methods'       => '',
		'accept_json'   => false,
		'accept_raw'    => false,
		'show_in_index' => true,
		'args'          => array(),
	);

	foreach ( $endpoints as $route => &$handlers ) {

		if ( isset( $handlers['callback'] ) ) {
			// Single endpoint, add one deeper.
			$handlers = array( $handlers );
		}

		if ( ! isset( $this->route_options[ $route ] ) ) {
			$this->route_options[ $route ] = array();
		}

		foreach ( $handlers as $key => &$handler ) {

			if ( ! is_numeric( $key ) ) {
				// Route option, move it to the options.
				$this->route_options[ $route ][ $key ] = $handler;
				unset( $handlers[ $key ] );
				continue;
			}

			$handler = wp_parse_args( $handler, $defaults );

			// Allow comma-separated HTTP methods.
			if ( is_string( $handler['methods'] ) ) {
				$methods = explode( ',', $handler['methods'] );
			} elseif ( is_array( $handler['methods'] ) ) {
				$methods = $handler['methods'];
			} else {
				$methods = array();
			}

			$handler['methods'] = array();

			foreach ( $methods as $method ) {
				$method                        = strtoupper( trim( $method ) );
				$handler['methods'][ $method ] = true;
			}
		}
	}

	return $endpoints;
}