examples Start here
basic.http
A file-wide base URL, GET and POST, a binary download, time and random data helpers, and bearer auth. Its resterm.env.json holds the environments that most files in this folder use.
runs as-is
resterm run --all _examples/basic.httpRun this from the root of a clone of the Resterm repository.
Editor
Request file anatomy docs// A setting placed before the first request applies to every request in the
// file, so the host is written once here instead of in each request line.
// A request may still override it, as the binary download below does.
# @setting base-url {{base.url}}
### Status Check
# @name getStatus
GET /status/204
User-Agent: resterm/0.1
Accept: application/json
### Download binary file
# @name downloadBinary
// GitHub returns 404 when an invalid Authorization header is sent. The example
// environment defines global auth, so disable it for this request.
// A request setting overrides the file default. A base URL can include a path.
// Keep the trailing slash when the path is a directory, otherwise the relative
// URL replaces its final segment.
# @auth none
# @setting base-url https://raw.githubusercontent.com/unkn0wn-root/resterm/main/
GET _media/resterm_base.png
### Create Post
# @name createPost
POST /anything/posts
Content-Type: application/json
Accept: application/json
{
"title": "foo",
"body": "bar",
"userId": 1
}
### Timestamp Helpers
# @name timestampHelpers
POST /anything/time
Content-Type: application/json
Accept: application/json
{
"now_unix": "{{$timestamp}}",
"now_unix_plus_6d": "{{$timestamp + 6d}}",
"now_iso_minus_90m": "{{$timestampISO8601 - 90m}}",
"now_unix_ms": "{{$timestampMs}}"
}
### Random Data Helpers
# @name randomHelpers
POST /anything/signup
Content-Type: application/json
Accept: application/json
{
"id": "{{$uuid}}",
"name": "{{$randomName}}",
"email": "{{$randomEmail}}",
"employer": "{{$fake.company}}",
"city": "{{$fake.city}}",
"phone": "{{$fake.phone}}",
"password": "{{$randomString(24)}}",
"plan": "{{$randomChoice('free', 'pro', 'team')}}",
"seats": "{{$randomInt(1, 25)}}"
}
### Bearer Auth Example
# @name bearerEcho
# @auth bearer {{auth.token}}
GET /bearer
Accept: application/json{
"$shared": {
"auth": {
"globalToken": "demo-global-token",
"clientId": "demo-client",
"clientSecret": "demo-secret"
},
"oauth": {
"tokenUrl": "https://auth.example.com/oauth/token",
"authUrl": "https://auth.example.com/oauth/authorize",
"clientId": "demo-client",
"clientSecret": "demo-secret",
"scope": "read write analytics"
}
},
"dev": {
"base": {
"url": "https://httpbin.org"
},
"services": {
"api": {
"base": "https://httpbin.org/anything/api"
},
"billing": {
"base": "https://httpbin.org/anything/billing"
}
},
"feature": {
"name": "beta-dashboard"
},
"auth": {
"token": "dev-token-123"
},
"oauth": {
"audience": "https://api.dev.example.com",
"cacheKey": "dev:core"
},
"graphql": {
"endpoint": "https://httpbin.org/anything/graphql",
"workspaceId": "ws-dev-001"
},
"grpc": {
"host": "localhost:50051",
"authority": "analytics.dev.local"
},
"transport": {
"proxy": "http://127.0.0.1:8080"
},
"tenant": {
"id": "tenant-dev-001",
"region": "eu-west-1"
},
"meta": {
"region": "eu-west-1",
"plan": "starter",
"flags": "{\"betaAccess\":true,\"canaryFeatures\":[\"dashboards\",\"automations\"]}"
},
"features": [
"realtime-updates",
"script-hooks",
"audit-export"
],
"query": {
"expand": "settings,features,limits"
},
"limits": {
"users": 25,
"projects": 8
},
"plans": {
"primary": "scale",
"addons": [
"dashboards",
"automation"
]
},
"billing": {
"currency": "USD",
"pricing": {
"workspace": 49.0,
"seat": 15.0
},
"sampleInvoiceId": "inv-0021"
}
},
"stage": {
"base": {
"url": "https://httpbin.org"
},
"services": {
"api": {
"base": "https://httpbin.org/anything/api-stage"
},
"billing": {
"base": "https://httpbin.org/anything/billing-stage"
}
},
"feature": {
"name": "gamma-switch"
},
"auth": {
"token": "stage-token-456"
},
"oauth": {
"audience": "https://api.stage.example.com",
"cacheKey": "stage:core"
},
"graphql": {
"endpoint": "https://httpbin.org/anything/graphql-stage",
"workspaceId": "ws-stage-002"
},
"grpc": {
"host": "localhost:50052",
"authority": "analytics.stage.local"
},
"transport": {
"proxy": "http://localhost:8081"
},
"tenant": {
"id": "tenant-stage-002",
"region": "us-east-1"
},
"meta": {
"region": "us-east-1",
"plan": "growth",
"flags": "{\"betaAccess\":false,\"canaryFeatures\":[\"dashboards\"]}"
},
"features": [
"realtime-updates",
"script-hooks"
],
"query": {
"expand": "settings,features"
},
"limits": {
"users": 15,
"projects": 5
},
"plans": {
"primary": "growth",
"addons": [
"dashboards"
]
},
"billing": {
"currency": "USD",
"pricing": {
"workspace": 79.0,
"seat": 19.0
},
"sampleInvoiceId": "inv-1102"
}
},
"prod": {
"base": {
"url": "https://httpbin.org"
},
"services": {
"api": {
"base": "https://httpbin.org/anything/api-prod"
},
"billing": {
"base": "https://httpbin.org/anything/billing-prod"
}
},
"feature": {
"name": "rollout-feature"
},
"auth": {
"token": "prod-token-789"
},
"oauth": {
"audience": "https://api.example.com",
"cacheKey": "prod:core"
},
"graphql": {
"endpoint": "https://httpbin.org/anything/graphql-prod",
"workspaceId": "ws-prod-003"
},
"grpc": {
"host": "analytics.example.com:443",
"authority": "analytics.prod.local"
},
"transport": {
"proxy": ""
},
"tenant": {
"id": "tenant-prod-003",
"region": "eu-central-1"
},
"meta": {
"region": "eu-central-1",
"plan": "enterprise",
"flags": "{\"betaAccess\":false,\"canaryFeatures\":[]}"
},
"features": [
"realtime-updates"
],
"query": {
"expand": "settings"
},
"limits": {
"users": 100,
"projects": 20
},
"plans": {
"primary": "enterprise",
"addons": [
"dashboards",
"automation",
"compliance"
]
},
"billing": {
"currency": "USD",
"pricing": {
"workspace": 199.0,
"seat": 29.0
},
"sampleInvoiceId": "inv-2099"
}
}
}