Hang for a number of seconds, then respond
GET
https://api.testingapis.com/api/chaos/timeoutUse this to test client timeouts. The wait stops as soon as the client disconnects.
Parameters 1
| Name | Type | Description |
|---|---|---|
seconds | query · integer (int32) | How long to hang (1-60, default 30). Default: 30. |
Responses
- 200
- Response after the wait.
Example
Request
curl -X GET "https://api.testingapis.com/api/chaos/timeout?seconds=1"Response200 OK
{"message": "Responded after 1s — your client did not time out.", "seconds": 1}Code examples
JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/chaos/timeout?seconds=1");
console.log(response.status, await response.text());Python (requests)
import requests
response = requests.request(
"GET",
"https://api.testingapis.com/api/chaos/timeout?seconds=1",
allow_redirects=False,
)
print(response.status_code, response.text)Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NEVER)
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.testingapis.com/api/chaos/timeout?seconds=1"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}