POST /api/v1/echo • HTTP 200 OK
JSON Echo & Inspection API Example — Request & Response Example
An invaluable learning and debugging API call that reflects the client payload, demonstrating how HTTP headers, IP addresses, and request bodies are seen by the server.
1. HTTP Client Request (POST)
POST /api/v1/echo HTTP/1.1
{
"Content-Type": "application/json",
"X-Client-Version": "2.4.0"
}
{
"test_message": "Testing API connectivity from browser",
"client_timestamp": 1728211400,
"debug_flag": true
}
2. Server JSON Response (HTTP 200 OK)
{
"echoed_body": {
"test_message": "Testing API connectivity from browser",
"client_timestamp": 1728211400,
"debug_flag": true
},
"headers_received": {
"content-type": "application/json",
"x-client-version": "2.4.0"
},
"client_ip": "198.51.100.42",
"roundtrip_status": "verified"
}
Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)
curl -X POST "https://cometflow.space/api/v1/echo" \
-H "Content-Type: application/json" \
-d '{"test_message": "Testing API", "debug_flag": true}'
fetch('https://cometflow.space/api/v1/echo', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ test_message: 'Testing API', debug_flag: true })
})
.then(res => res.json())
.then(echo => console.log(echo));
import requests
data = {"test_message": "Testing API", "debug_flag": True}
res = requests.post("https://cometflow.space/api/v1/echo", json=data)
print(res.json())
How This API Call Works Step-by-Step
- 1. Client POSTs arbitrary data payload in JSON format.
- 2. Server parses the HTTP request headers, body, and remote socket address.
- 3. Server echoes back the exact parsed structure inside an echoed_body wrapper.
- 4. Developer inspects the response to verify that network serialization and headers transmitted accurately.
Backend API Functions: The API function echoHandler(req, res) acts as an inspector, collecting req.body, req.headers, and req.ip, and serializing them into an echo response.
Frequently Asked Questions
Why are echo APIs useful?
They allow software engineers and QA testers to inspect exactly how the server interprets their headers, encodings, and parameters without modifying database state.