- Home
- API Design
- What Is The HTTP GET Request?
GET Method
GET is an HTTP method used to request data from a specified resource. The GET request should only receive data or fetch data. The GET method is used to retrieve data from the given server using a given URI.
The HTTP GET request is a method used to retrieve data from a specified resource. It is one of the most common HTTP methods, along with POST, PUT, and DELETE.
Syntax
Below example, a client makes a GET request to the following URI to retrieve a list of orders from an API:
GET https://api.example.com/orders # Retrieves a list of orders GET https://api.example.com/orders/1 # Retrieves a specific order 1
The server will then return a list of orders or a specific order in the requested format (such as JSON or XML).
Example
In the GET method, the query string (field/value pairs) is sent in the URL of a GET request. Usually, a string of name and value pairs is separated by ampersands (&). In general, a URL with getting data will look like this:
Request
curl --location --request GET 'https://api.postcodes.theapibridge.com/v1/udprn/54782785?x-api-key={api_key}'
Response
{ "status": 200, "message": "Success", "result": { "building_number": " ", "premise": "", "building_name": "", "sub_building_name": "", "organisation_name": "Aberdeen Airport Engineering", "line_1": "Aberdeen Airport Engineering", "line_2": "Ninian Road", "line_3": "Dyce", "postcode": "AB21 0PD", "thoroughfare": "Ninian Road", "post_town": "ABERDEEN", "po_box": "", "ward": "Dyce/Bucksburn/Danestone", "district": "Aberdeen City", "county": "Scotland", "country": "Scotland", "udprn": "54782785", "address": "Aberdeen Airport Engineering, Ninian Road, Dyce, ABERDEEN, AB21 0PD", "postcode_incode": "0PD", "postcode_outcode": "AB21", "postcode_compact": "AB210PD", "postcode_type": "S", "department_name": "", "su_organisation_indicator": "Y", "double_dependant_locality": "", "dependant_thoroughfare": "", "dependant_locality": "Dyce", "delivery_point_suffix": "1H", "geocode": { "eastings": "387515", "northings": "0812566", "lattitude": "57.203686", "longitude": "-2.208289" } } }
Characteristics
- GET requests are only used to request data (not modify).
- GET requests should never be used when dealing with sensitive data
- GET requests can be cached.
- GET requests to have length restrictions.
- GET requests can be bookmarked
- GET requests to remain in the browser history.
- GET requests should be idempotent, meaning that multiple identical GET requests should produce the same result as a single request.