Java code for REST API GET Example
This Java code snippet was generated automatically for the REST API GET example.<< Back to the REST API GET example
What is REST API?
A REST API (Representative State Transfer) is a way of communicating two computers over the Internet. The REST API defines a set of rules that developers should follow when creating an API:
- Client-server architecture: the REST API client (website or mobile app) should be decoupled from the request processor and data storage (REST API server) so that each part can be developed, tested, and scaled individually.
- Statelessness: every request to the REST API server must be made with all the required data, and Rest API should not assume if the server has any data from previous REST API client requests (the server does not store the client context).
- Layered: the REST API client does not need to know if it communicates with a real server, proxy, or other intermediaries. These intermediate servers (proxies or load balancers) can provide the underlying REST API server with additional scalability and security.
- Cacheable: each REST API response must be defined as cacheable or not.
What is JSON?
JavaScript Object Notation (JSON) is a text-based, language-independent format for storing and transmitting data over a network. JSON is used for client/server communication in mobile and web applications written in many programming languages, including JavaScript, Python, Java, C++, C#, Go, PHP, and many others.
REST API GET Example
To get data from the REST API server, you must send an HTTP GET request with an "Accept: application/json" request header. The server informs the client that it has returned JSON by sending "Content-Type: application/json" in response. The following is an example of a REST API GET request to the ReqBin API endpoint:
The server response to our test REST API GET request: