Code and data

Code groups

The same example in several languages, one tab each.

A code group puts several code blocks behind tabs with their titles. Readers pick their language once and copy what they need.

cURL

curl https://your-domain.example/api/v1/runs \
  -H "Authorization: Bearer $TOKEN"

PHP

$runs = Http::withToken($token)
    ->get('https://your-domain.example/api/v1/runs')
    ->json();

JavaScript

const response = await fetch('https://your-domain.example/api/v1/runs', {
  headers: { Authorization: `Bearer ${token}` },
});
const runs = await response.json();

Python

import requests

runs = requests.get(
    "https://your-domain.example/api/v1/runs",
    headers={"Authorization": f"Bearer {token}"},
).json()

Code group or tabs?

  • A code group when every tab is code: the same call in different languages.
  • Tabs when the options mix text, lists and code, such as setup steps per system.