---
description: https://developer.wordpress.org/rest-api/frequently-asked-questions/
---

# \[API] Can I make API requests from PHP within a plugin? (ok)

![](https://2370029328-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWPtKFbhw0XehxVuoiZ%2F-MOBCRxMqQ9umHRJ8eyF%2F-MOBhVpzOlE6V9jen4f7%2FScreenshot_1.png?alt=media\&token=47b89a7d-6f1d-4e84-9014-e087b25dd852)

C:\xampp\htdocs\api\wp-content\themes\twentyseventeen\header.php

```
<?php  
	$request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
	// Set one or more request query parameters
	$request->set_param( 'per_page', 20 );
	$response = rest_do_request( $request );
	echo '<pre>';
		print_r($response);
	echo '</pre>';
?>
```
