Test REST API Example [PHP Code]

To test a REST API service online, enter your REST API endpoint in the URL field and your REST data in the Content tab and click Send. The ReqBin REST API testing tool works in your browser and does not require a desktop app or browser plugin. You can test your REST API with GET, POST, PUT, PATCH, and DELETE request methods, send JSON data, and custom HTTP headers. The REST API Test Tool allows you to validate API status codes, response times, and sizes and validate returned JSON and XML strings using automated code beautifiers and validators. Click Send to execute the Test Rest API example online and see the results. The PHP code was automatically generated for the Test REST API Online example.
Test REST API Example [PHP Code] Send
GET /echo/get/json HTTP/1.1
Host: reqbin.com
Accept: application/json

Updated: Viewed: 39137 times
PHP code for Test REST API Online example

PHP code for Test REST API Online Example

This PHP code snippet was generated automatically for the Test REST API Online example.
<< Back to the Test REST API Online example

What is REST API?

A REST API is an application programming interface in which the API follows REST design principles or an architectural style of representational state transfer. The REST API provides developers with a high level of flexibility and freedom, which has become the standard way to connect components and applications in a microservice architecture. The REST API is the browser and programming language independent. REST API clients communicate via HTTP protocol to perform standard CRUD operations within a resource.

What is API?

An Application Programming Interface (API) is a computational interface that describes how multiple software components interact with each other and allows applications to exchange data between them. The APIs are standard-compliant (REST and HTTP), developer and automation-friendly, and easy to test. APIs are usually well documented to use and suitable for version control.

What is REST?

REpresentational State Transfer is an architectural style that enforces standards compliance between computer systems to make it easier for systems to interact with each other. REST has its own set of rules and constraints, just like other architectural styles.

How to test a REST API?

To test a REST API service using the ReqBin REST API testing tool, follow these steps:

  1. Enter the REST API URL for testing;
  2. Select the HTTP method;
  3. Specify a set of header;
  4. Set the required body content;
  5. Send data to start the test.
Test REST API Example
GET /echo/get/json HTTP/1.1
Host: reqbin.com
Accept: application/json

You will receive a response from the server:

Response REST API Example
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19
Connection: keep-alive

{"success":"true"}

See also

Generate code snippets for PHP and other programming languages

Convert your Test REST API Online request to the PHP, JavaScript/AJAX, Node.js, Curl/Bash, Python, Java, C#/.NET code snippets using the PHP code generator.