online / endpoints 62 / categories 10 / rate 60/min/ip /

GET /jsonapi

GET /jsonapi alias: /jsonapi

Returns a well-formed JSON:API response: single resource object with `type`, `id`, `attributes`, and `relationships`; all `included` resources referenced by a relationship. Served as application/vnd.api+json. Counterpart to the chaos /jsonapi endpoint.

expect: 200 OK with Content-Type: application/vnd.api+json. Spec-compliant resource object with type, id, attributes, relationships, and a correctly linked included array. Build clients against this, then flip hostname to chaos.catastrophic.io to test adversity.

bash
curl -si 'https://not.catastrophic.io/jsonapi' | grep -E '^(HTTP|content-type|x-chaos)'
import urllib.request, json
resp = urllib.request.urlopen("https://not.catastrophic.io/jsonapi")
print("Content-Type:", resp.headers.get("Content-Type"))
print("X-Chaos-Jsonapi-Mode:", resp.headers.get("X-Chaos-Jsonapi-Mode"))
body = json.loads(resp.read())
data = body.get("data")
print("data is array:", isinstance(data, list))
if isinstance(data, dict):
    print("id present:", "id" in data)
    print("type present:", "type" in data)
print("note:", body.get("note"))
const res = await fetch("https://not.catastrophic.io/jsonapi");
const body = await res.json();
console.log("Content-Type:", res.headers.get("content-type"));
console.log("X-Chaos-Jsonapi-Mode:", res.headers.get("x-chaos-jsonapi-mode"));
console.log("data is array:", Array.isArray(body.data));
if (!Array.isArray(body.data)) {
  console.log("id present:", "id" in body.data);
  console.log("type present:", "type" in body.data);
}
console.log("note:", body.note);
package main

import (
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    resp, _ := http.Get("https://not.catastrophic.io/jsonapi")
    defer resp.Body.Close()
    raw, _ := io.ReadAll(resp.Body)
    var body map[string]any
    json.Unmarshal(raw, &body)
    fmt.Println("Content-Type:", resp.Header.Get("Content-Type"))
    fmt.Println("X-Chaos-Jsonapi-Mode:", resp.Header.Get("X-Chaos-Jsonapi-Mode"))
    _, dataIsArray := body["data"].([]any)
    fmt.Println("data is array:", dataIsArray)
}
// Cargo.toml: reqwest = { version = "0.12", features = ["blocking", "json"] }
fn main() -> Result<(), Box> {
    let resp = reqwest::blocking::get("https://not.catastrophic.io/jsonapi")?;
    println!("Content-Type: {:?}", resp.headers().get("content-type"));
    println!("X-Chaos-Jsonapi-Mode: {:?}", resp.headers().get("x-chaos-jsonapi-mode"));
    let body: serde_json::Value = resp.json()?;
    println!("data is array: {}", body["data"].is_array());
    Ok(())
}
import java.net.URI;
import java.net.http.*;

public class JsonApiChaos {
    public static void main(String[] args) throws Exception {
        var client = HttpClient.newHttpClient();
        var req = HttpRequest.newBuilder(URI.create("https://not.catastrophic.io/jsonapi")).build();
        var resp = client.send(req, HttpResponse.BodyHandlers.ofString());
        System.out.println("Content-Type: " +
            resp.headers().firstValue("Content-Type").orElse(""));
        System.out.println("X-Chaos-Jsonapi-Mode: " +
            resp.headers().firstValue("X-Chaos-Jsonapi-Mode").orElse(""));
        System.out.println("Body: " + resp.body());
    }
}
using var client = new HttpClient();
var resp = await client.GetAsync("https://not.catastrophic.io/jsonapi");
Console.WriteLine($"Content-Type: {resp.Content.Headers.ContentType}");
Console.WriteLine($"X-Chaos-Jsonapi-Mode: " +
    $"{resp.Headers.GetValues("X-Chaos-Jsonapi-Mode").FirstOrDefault()}");
var body = await resp.Content.ReadAsStringAsync();
Console.WriteLine($"Body: {body}");
require "net/http"
require "json"
uri = URI("https://not.catastrophic.io/jsonapi")
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
    res = http.get(uri.request_uri)
    puts "Content-Type: #{res['Content-Type']}"
    puts "X-Chaos-Jsonapi-Mode: #{res['X-Chaos-Jsonapi-Mode']}"
    body = JSON.parse(res.body)
    puts "data is array: #{body['data'].is_a?(Array)}"
end
$r = Invoke-RestMethod -Uri 'https://not.catastrophic.io/jsonapi' -ResponseHeadersVariable h
"Content-Type: $($h['Content-Type'])"
"X-Chaos-Jsonapi-Mode: $($h['X-Chaos-Jsonapi-Mode'])"
"data is array: $($r.data -is [array])"