Skip to main content

Mock Distributed Trace and Span API

MOCK DATA

Generate coherent mock distributed traces and individual spans with bounded timing, parentage, service filters and reproducible failures.

Generated test data for fixtures and development

Base URL
/api/traces
Capabilities
2 routes Seedable
Last updated
July 29, 2026

GET /api/traces

Live requestRuns against the public API
No key required
GET/api/traces?service=checkout&spanCount=6&count=10&seed=42

Request parameters

Constrain the trace's root service. Omit for a mix.

Constrain trace status. Error guarantees at least one failed span.

Inclusive minimum total trace duration in milliseconds.

Inclusive maximum total trace duration; must be at least minDurationMs.

Exact number of spans nested in every generated trace.

Trace start is sampled within this many minutes at or before resolved asOf.

Window end. Defaults to the current UTC day's final millisecond and is echoed for replay.

Advanced response options7 options

How many records to generate (1–100).

Deterministic output: the same seed always returns the same records. Omit for random (the used seed is echoed in meta.seed).

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

Return all fields except these (comma-separated).

Response format: json envelope, ndjson (one record per line) or csv.

Pretty-print the JSON response.

Drop the envelope: return the raw array/object without data/meta wrapper.

Response

Example parameters are ready. Send the request to inspect the live response.

Route reference

Code samples Ready-to-copy requests in 4 languages
Choose a code sample language
curl "https://randomapi.dev/api/traces?service=checkout&spanCount=6&seed=42&count=10"
const res = await fetch("https://randomapi.dev/api/traces?service=checkout&spanCount=6&seed=42&count=10");
const { data, meta } = await res.json();
import requests

data = requests.get("https://randomapi.dev/api/traces?service=checkout&spanCount=6&seed=42&count=10").json()["data"]
$json = json_decode(file_get_contents(
  "https://randomapi.dev/api/traces?service=checkout&spanCount=6&seed=42&count=10"
), true);
$data = $json["data"];
Parameters Route-specific request inputs 7
service enum

Constrain the trace's root service. Omit for a mix.

allowed: gateway | checkout | catalog | payments | worker
example: service=checkout
status enum

Constrain trace status. Error guarantees at least one failed span.

allowed: ok | error
example: status=error
minDurationMs int

Inclusive minimum total trace duration in milliseconds.

default: 20
allowed: 1 – 60000
example: minDurationMs=100
maxDurationMs int

Inclusive maximum total trace duration; must be at least minDurationMs.

default: 2000
allowed: 1 – 60000
example: maxDurationMs=5000
spanCount int

Exact number of spans nested in every generated trace.

default: 4
allowed: 1 – 8
example: spanCount=6
windowMinutes int

Trace start is sampled within this many minutes at or before resolved asOf.

default: 60
allowed: 1 – 1440
example: windowMinutes=120
asOf date

Window end. Defaults to the current UTC day's final millisecond and is echoed for replay.

example: asOf=2026-07-10T23:59:59.999Z
Universal parameters Shared response and formatting options 7
count int

How many records to generate (1–100).

default: 10
allowed: 1 – 100
example: count=3
seed int

Deterministic output: the same seed always returns the same records. Omit for random (the used seed is echoed in meta.seed).

example: seed=42
fields list

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

example: fields=traceId,name
exclude list

Return all fields except these (comma-separated).

example: exclude=spans
format enum

Response format: json envelope, ndjson (one record per line) or csv.

default: json
allowed: json | ndjson | csv
example: format=csv
pretty boolean

Pretty-print the JSON response.

default: false
example: pretty=true
unwrap boolean

Drop the envelope: return the raw array/object without data/meta wrapper.

default: false
example: unwrap=true
Response schema Fields returned in each record 9
traceId string

Unique fictional 32-hex trace identifier.

example: 0000000076cc47a8b2caa2cf7131537a

name string

Root operation name coherent with service.

example: create checkout

service string

Root service selected by the service filter or generator.

example: checkout

startTime string (ISO 8601)

Trace start inside the requested window at or before resolved asOf.

example: 2026-07-10T23:14:22.031Z

durationMs integer

Total duration inside the requested inclusive bounds.

example: 842

status string

ok or error, derived coherently from nested span status.

example: error

rootSpanId string

Identifier of spans[0], whose parent is null.

example: 0000000066f327f2

spanCount integer

Exact number of objects in spans.

example: 4

spans object[]

Bounded parent-first span tree with offsets, durations, status and nullable error codes.

example: [{"spanId":"0000000066f327f2","parentSpanId":null,"name":"create checkout","service":"checkout","kind":"server","startOffsetMs":0,"durationMs":842,"status":"ok","errorCode":null}]

Documented examples

Build-generated requests and complete responses
2
Checkout traces with six spans
GET /api/traces?service=checkout&spanCount=6&seed=42&count=10
{
  "data": [
    {
      "traceId": "0000000029ff11dec8095cf565312cf8",
      "name": "reserve order",
      "service": "checkout",
      "startTime": "2026-07-29T23:00:15.697Z",
      "durationMs": 1361,
      "status": "ok",
      "rootSpanId": "00000000958016cf",
      "spanCount": 6,
      "spans": [
        {
          "spanId": "00000000958016cf",
          "parentSpanId": null,
          "name": "reserve order",
          "service": "checkout",
          "kind": "server",
          "startOffsetMs": 0,
          "durationMs": 1361,
          "status": "ok",
          "errorCode": null
        },
        {
          "spanId": "00000001b6a5c85e",
          "parentSpanId": "00000000958016cf",
          "name": "validate basket",
          "service": "checkout",
          "kind": "producer",
          "startOffsetMs": 494,
          "durationMs": 377,
          "status": "ok",
          "errorCode": null
        },
        {
          "spanId": "00000002ac58cdd4",
          "parentSpanId": "00000000958016cf",
          "name": "create checkout",
          "service": "checkout",
          "kind": "server",
    …
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Slow failed traces
GET /api/traces?status=error&minDurationMs=2000&maxDurationMs=5000&windowMinutes=120&count=20
{
  "data": [
    {
      "traceId": "000000006b87c24316010d14615edf36",
      "name": "list products",
      "service": "catalog",
      "startTime": "2026-07-29T22:21:26.745Z",
      "durationMs": 4032,
      "status": "error",
      "rootSpanId": "00000000958016cf",
      "spanCount": 4,
      "spans": [
        {
          "spanId": "00000000958016cf",
          "parentSpanId": null,
          "name": "list products",
          "service": "catalog",
          "kind": "server",
          "startOffsetMs": 0,
          "durationMs": 4032,
          "status": "ok",
          "errorCode": null
        },
        {
          "spanId": "00000001b6a5c85e",
          "parentSpanId": "00000000958016cf",
          "name": "search catalog",
          "service": "catalog",
          "kind": "internal",
          "startOffsetMs": 3425,
          "durationMs": 50,
          "status": "ok",
          "errorCode": null
        },
        {
          "spanId": "00000002ac58cdd4",
          "parentSpanId": "00000000958016cf",
          "name": "load product",
          "service": "catalog",
          "kind": "client",
    …
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}

GET /api/traces/spans

Live requestRuns against the public API
No key required
GET/api/traces/spans?service=payments&kind=client&count=20&seed=42

Request parameters

Constrain every span to this service. Omit for a mix.

Constrain every span to this span kind. Omit for a mix.

Constrain every span to ok or error.

Inclusive minimum span duration in milliseconds.

Inclusive maximum span duration; must be at least minDurationMs.

Span start is sampled within this many minutes at or before resolved asOf.

Window end. Defaults to the current UTC day's final millisecond and is echoed for replay.

Advanced response options7 options

How many records to generate (1–100).

Deterministic output: the same seed always returns the same records. Omit for random (the used seed is echoed in meta.seed).

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

Return all fields except these (comma-separated).

Response format: json envelope, ndjson (one record per line) or csv.

Pretty-print the JSON response.

Drop the envelope: return the raw array/object without data/meta wrapper.

Response

Example parameters are ready. Send the request to inspect the live response.

Route reference

Code samples Ready-to-copy requests in 4 languages
Choose a code sample language
curl "https://randomapi.dev/api/traces/spans?service=payments&kind=client&seed=42&count=20"
const res = await fetch("https://randomapi.dev/api/traces/spans?service=payments&kind=client&seed=42&count=20");
const { data, meta } = await res.json();
import requests

data = requests.get("https://randomapi.dev/api/traces/spans?service=payments&kind=client&seed=42&count=20").json()["data"]
$json = json_decode(file_get_contents(
  "https://randomapi.dev/api/traces/spans?service=payments&kind=client&seed=42&count=20"
), true);
$data = $json["data"];
Parameters Route-specific request inputs 7
service enum

Constrain every span to this service. Omit for a mix.

allowed: gateway | checkout | catalog | payments | worker
example: service=payments
kind enum

Constrain every span to this span kind. Omit for a mix.

allowed: server | client | producer | consumer | internal
example: kind=client
status enum

Constrain every span to ok or error.

allowed: ok | error
example: status=ok
minDurationMs int

Inclusive minimum span duration in milliseconds.

default: 5
allowed: 1 – 60000
example: minDurationMs=20
maxDurationMs int

Inclusive maximum span duration; must be at least minDurationMs.

default: 1000
allowed: 1 – 60000
example: maxDurationMs=2000
windowMinutes int

Span start is sampled within this many minutes at or before resolved asOf.

default: 60
allowed: 1 – 1440
example: windowMinutes=240
asOf date

Window end. Defaults to the current UTC day's final millisecond and is echoed for replay.

example: asOf=2026-07-10T23:59:59.999Z
Universal parameters Shared response and formatting options 7
count int

How many records to generate (1–100).

default: 10
allowed: 1 – 100
example: count=3
seed int

Deterministic output: the same seed always returns the same records. Omit for random (the used seed is echoed in meta.seed).

example: seed=42
fields list

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

example: fields=traceId,spanId
exclude list

Return all fields except these (comma-separated).

example: exclude=attributes
format enum

Response format: json envelope, ndjson (one record per line) or csv.

default: json
allowed: json | ndjson | csv
example: format=csv
pretty boolean

Pretty-print the JSON response.

default: false
example: pretty=true
unwrap boolean

Drop the envelope: return the raw array/object without data/meta wrapper.

default: false
example: unwrap=true
Response schema Fields returned in each record 11
traceId string

Unique fictional trace id for this standalone span fixture.

example: 0000000076cc47a8b2caa2cf7131537a

spanId string

Unique fictional 16-hex span id.

example: 0000000066f327f2

parentSpanId string nullable

Null for generated server roots; otherwise a fictional parent id.

example: 00000000a2cf7131

name string

Operation coherent with service.

example: authorize payment

service string

Generated or requested service.

example: payments

kind string

server, client, producer, consumer or internal.

example: client

startTime string (ISO 8601)

Span start inside the requested sampling window.

example: 2026-07-10T23:42:10.002Z

durationMs integer

Span duration inside requested bounds.

example: 127

status string

ok or error.

example: ok

errorCode string nullable

Service-specific code for error spans; otherwise null.

example: null

attributes object

Small safe example attributes coherent with kind.

example: {"method":"POST","path":"/api/checkout","statusCode":201}

Documented examples

Build-generated requests and complete responses
2
Payment client spans
GET /api/traces/spans?service=payments&kind=client&seed=42&count=20
{
  "data": [
    {
      "traceId": "00000000a958016cfb6a5c85eac58cdd",
      "spanId": "0000000040fb1586",
      "parentSpanId": "000000013c1d1cff",
      "name": "capture payment",
      "service": "payments",
      "kind": "client",
      "startTime": "2026-07-29T23:29:42.718Z",
      "durationMs": 187,
      "status": "ok",
      "errorCode": null,
      "attributes": {
        "method": "POST",
        "path": "/api/items",
        "statusCode": 200
      }
    },
    {
      "traceId": "00000001078f248abeccba6fd45df91c",
      "spanId": "0001000036673e8f",
      "parentSpanId": "00010001cae90de6",
      "name": "authorize payment",
      "service": "payments",
      "kind": "client",
      "startTime": "2026-07-29T23:21:41.589Z",
      "durationMs": 351,
      "status": "ok",
      "errorCode": null,
      "attributes": {
        "method": "POST",
        "path": "/api/orders",
        "statusCode": 201
      }
    },
    {
      "traceId": "0000000215790902c05ac838fecf0b9c",
      "spanId": "000200004166f967",
      "parentSpanId": "000200010555a0ee",
    …
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Failed queue consumers
GET /api/traces/spans?service=worker&kind=consumer&status=error&minDurationMs=50&maxDurationMs=500&count=15
{
  "data": [
    {
      "traceId": "000000007a958016cfb6a5c85eac58cd",
      "spanId": "00000000d40fb158",
      "parentSpanId": "0000000163c1d1cf",
      "name": "retry task",
      "service": "worker",
      "kind": "consumer",
      "startTime": "2026-07-29T23:30:14.480Z",
      "durationMs": 273,
      "status": "error",
      "errorCode": "JOB_FAILED",
      "attributes": {
        "messagingSystem": "demo-broker",
        "destination": "events"
      }
    },
    {
      "traceId": "000000010078f248abeccba6fd45df91",
      "spanId": "00010000c36673e8",
      "parentSpanId": "00010001fcae90de",
      "name": "publish result",
      "service": "worker",
      "kind": "consumer",
      "startTime": "2026-07-29T23:19:40.439Z",
      "durationMs": 213,
      "status": "error",
      "errorCode": "JOB_FAILED",
      "attributes": {
        "messagingSystem": "demo-broker",
        "destination": "events"
      }
    },
    {
      "traceId": "00000002d15790902c05ac838fecf0b9",
      "spanId": "00020000c4166f96",
      "parentSpanId": "0002000170555a0e",
      "name": "retry task",
      "service": "worker",
    …
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}

About this API

Coverage & behavior

Generates compact, fictional distributed tracing fixtures for waterfall views, latency tables and observability demos. The root route returns one complete trace per record with a bounded span tree. Every child starts inside the trace, finishes no later than the trace, and references an earlier span as its parent. An error trace always contains at least one error span; an ok trace contains none.

service, status, duration bounds and spanCount genuinely constrain complete traces. /spans emits individual span records and adds kind filtering for server, client, producer, consumer and internal work. Timestamps are sampled from a window ending at resolved asOf; it defaults to the current UTC day's end and is echoed so a seeded response can be replayed later.

These records are intentionally generic mock data. Their identifiers have familiar trace/span lengths, but the endpoint does not claim OpenTelemetry, Zipkin, Jaeger or W3C propagation conformance. Attributes use safe example paths and a fictional broker; no request headers, credentials, customer data or real hosts are generated.

Use it for

  • Populate a trace waterfall with coherent parent-child spans and durations
  • Test error-only observability filters with reproducible failed spans
  • Generate safe span-table fixtures without exporting production telemetry

Frequently asked questions

Are child spans contained inside their trace duration?

Yes. Every child has a non-negative start offset and a duration that ends at or before the trace duration.

Does an error trace always include an error span?

Yes. Error traces contain at least one failed span with an error code; ok traces contain no failed spans.

Are these OpenTelemetry spans?

No. They are compact generic mock fixtures and make no telemetry-vendor or protocol-conformance claim.

Can the endpoint emit real request data?

No. Operations, paths, services, identifiers and attributes are generated fixtures with no headers, secrets or real hosts.