The videos below demonstrate how to create mock API endpoints to handle HTTP GET requests
In this video, we will be creating an HTTP GET API, save & publish it, and then call the API from the web browser. The API returns a list of 3 countries from the North America.
API Request
Request Path: /continent/north-america
HTTP Method: GET
API Response
Response Code: 200
Response Content-Type: application/json
Response Body:
[
{
"country": "Canada",
"country-alpha2-code": "CA",
"captial": "Ottawa",
"continent": "North America",
"continent-code": "NA"
},
{
"country": "United States of America",
"country-alpha2-code": "US",
"captial": "Washington, D.C.",
"continent": "North America",
"continent-code": "NA"
},
{
"country": "Mexico",
"country-alpha2-code": "MX",
"captial": "Mexico City",
"continent": "North America",
"continent-code": "NA"
}
]
We will be creating an HTTP GET API in this video, save and publish it, and then later we will launch a Linux Terminal and use cURL to call the newly created API and view the response returned by the newly created API
API Request
Request Path: /continent/north-america
HTTP Method: GET
API Response
Response Code: 200
Response Content-Type: application/json
Response Body:
[
{
"country": "Canada",
"country-alpha2-code": "CA",
"captial": "Ottawa",
"continent": "North America",
"continent-code": "NA"
},
{
"country": "United States of America",
"country-alpha2-code": "US",
"captial": "Washington, D.C.",
"continent": "North America",
"continent-code": "NA"
},
{
"country": "Mexico",
"country-alpha2-code": "MX",
"captial": "Mexico City",
"continent": "North America",
"continent-code": "NA"
}
]
In this third video, we will be creating an API that will service HTTP GET requests, save and publish it, and then later we will launch the API testing functionality that is built-into the Online API Editor to call the API and view its response code, response content-type and the response body
API Request
Request Path: /continent/north-america
HTTP Method: GET
API Response
Response Code: 200
Response Content-Type: application/json
Response Body:
[
{
"country": "Canada",
"country-alpha2-code": "CA",
"captial": "Ottawa",
"continent": "North America",
"continent-code": "NA"
},
{
"country": "United States of America",
"country-alpha2-code": "US",
"captial": "Washington, D.C.",
"continent": "North America",
"continent-code": "NA"
},
{
"country": "Mexico",
"country-alpha2-code": "MX",
"captial": "Mexico City",
"continent": "North America",
"continent-code": "NA"
}
]
In this tutorial, we will be creating an API that will handle HTTP GET requests. We will demonstrate how to use an asterisk (*) in the API Path as a placeholder for the single path variable we would like to have in the API Path. The asterisk in the API Path instructs the API Server to accept any value passed by the API Caller in its place
API Request
Request Path: /data/employee/*
HTTP Method: GET
API Response
Response Code: 200
Response Content-Type: application/json
Response Body:
{
"employeeId": 111,
"firstName": "John",
"lastName": "Smith",
"hireDate": "2015-01-15",
"status": "active",
"title": "Engineer Level 3",
"team": "Team J",
"department": "New Services"
}