# Format a concise time range

`GET /v1/dates/range`

Free during preview · test keys only

Turn two times into a compact English label: 10 - 11am, 1:30 - 6:15pm, or 10am - 12pm. The 12-hour clock drops leading zeros and :00 minutes. Equal times at hour:minute collapse to one label, such as 1:30pm; seconds are ignored for display and ordering.

Datetimes normalize to UTC. Returned start and end use RFC 3339 with Z at whole-second precision. Two clock-only inputs use 1970-01-01 UTC; a single clock borrows the dated side’s UTC date. Leap seconds are not supported.

Different UTC dates prefix each side with month and day, without a year: Oct 13, 10pm - Oct 14, 2am. Use dated inputs for overnight ranges; an earlier end is refused. Scoped test keys must allow dates.range. No balance or payment is required.

## Parameters

| Parameter | In | Type | Required | Default | Description |
| --- | --- | --- | --- | --- | --- |
| start | query | string | yes | — | RFC 3339 datetime with an offset, or HH:MM[:SS] in UTC. |
| end | query | string | yes | — | Same formats as start. Must not precede start at minute precision. |
| locale | query | string | no | "en" | English only. Other values return unsupported_locale. |
| separator | query | string | no | " - " | Literal text between the times. Whitespace and empty strings are preserved. |

## Examples

### curl

```sh
curl --request GET 'https://api.butter.pub/v1/dates/range?start=10%3A00&end=11%3A00&locale=en&separator=%20-%20' \
  --header "Authorization: Bearer $APIBUTTER_TEST_KEY"
```

### PHP

```php
use Illuminate\Support\Facades\Http;

$response = Http::withToken($key)
    ->get('https://api.butter.pub/v1/dates/range', ['start' => '10:00', 'end' => '11:00', 'locale' => 'en', 'separator' => ' - ']);

$result = $response->throw()->json();
```

### JavaScript

```js
const url = new URL('https://api.butter.pub/v1/dates/range');
url.search = new URLSearchParams({
    "start": "10:00",
    "end": "11:00",
    "locale": "en",
    "separator": " - "
}).toString();

const response = await fetch(url, {
  method: 'GET',
  headers: { Authorization: `Bearer ${key}` },
});
if (!response.ok) throw await response.json();
const result = await response.json();
```

## MCP equivalent

Call `dates_range` at https://mcp.butter.pub/mcp.

```json
{
    "name": "dates_range",
    "arguments": {
        "start": "10:00",
        "end": "11:00",
        "locale": "en",
        "separator": " - "
    }
}
```

## Responses

### 200 · application/json

The concise label and normalized UTC inputs. Nothing is charged.

Shared am/pm

```json
{
    "object": "time_range",
    "text": "10 - 11am",
    "start": "1970-01-01T10:00:00Z",
    "end": "1970-01-01T11:00:00Z",
    "locale": "en"
}
```

Across noon

```json
{
    "object": "time_range",
    "text": "10am - 12pm",
    "start": "1970-01-01T10:00:00Z",
    "end": "1970-01-01T12:00:00Z",
    "locale": "en"
}
```

Keep nonzero minutes

```json
{
    "object": "time_range",
    "text": "1:30 - 6:15pm",
    "start": "1970-01-01T13:30:00Z",
    "end": "1970-01-01T18:15:00Z",
    "locale": "en"
}
```

A single time

```json
{
    "object": "time_range",
    "text": "1:30pm",
    "start": "1970-01-01T13:30:00Z",
    "end": "1970-01-01T13:30:00Z",
    "locale": "en"
}
```

Different UTC dates

```json
{
    "object": "time_range",
    "text": "Oct 13, 10pm - Oct 14, 2am",
    "start": "2026-10-13T22:00:00Z",
    "end": "2026-10-14T02:00:00Z",
    "locale": "en"
}
```

### 401 · application/problem+json

Missing, invalid, or revoked bearer key.

unauthorized

```json
{
    "type": "https://apibutter.com/docs/errors/unauthorized",
    "title": "Unauthorized",
    "status": 401,
    "detail": "A valid, unrevoked bearer API key is required.",
    "code": "unauthorized",
    "param": null,
    "errors": null,
    "request_id": "req_01jbz8c6m3x4v9t2q7w5n8r0ka"
}
```

### 403 · application/problem+json

Live keys are refused during preview; scoped test keys must allow dates.range.

test_keys_only

```json
{
    "type": "https://apibutter.com/docs/errors/test_keys_only",
    "title": "Forbidden",
    "status": 403,
    "detail": "This operation is free during preview and accepts abk_test_ keys only.",
    "code": "test_keys_only",
    "param": null,
    "errors": null,
    "request_id": "req_01jbz8c6m3x4v9t2q7w5n8r0ka"
}
```

forbidden

```json
{
    "type": "https://apibutter.com/docs/errors/forbidden",
    "title": "Forbidden",
    "status": 403,
    "detail": "The API key does not allow this operation.",
    "code": "forbidden",
    "param": null,
    "errors": null,
    "request_id": "req_01jbz8c6m3x4v9t2q7w5n8r0ka"
}
```

### 422 · application/problem+json

Invalid input. The detail names the parameter to correct.

end_before_start

```json
{
    "type": "https://apibutter.com/docs/errors/end_before_start",
    "title": "Unprocessable Content",
    "status": 422,
    "detail": "The end parameter must not precede start at minute precision.",
    "code": "end_before_start",
    "param": "end",
    "errors": {
        "end": [
            "The end parameter must not precede start at minute precision."
        ]
    },
    "request_id": "req_01jbz8c6m3x4v9t2q7w5n8r0ka"
}
```

invalid_parameter

```json
{
    "type": "https://apibutter.com/docs/errors/invalid_parameter",
    "title": "Unprocessable Content",
    "status": 422,
    "detail": "The start parameter must be a valid RFC 3339 datetime or HH:MM[:SS].",
    "code": "invalid_parameter",
    "param": "start",
    "errors": {
        "start": [
            "The start parameter must be a valid RFC 3339 datetime or HH:MM[:SS]."
        ]
    },
    "request_id": "req_01jbz8c6m3x4v9t2q7w5n8r0ka"
}
```

unsupported_locale

```json
{
    "type": "https://apibutter.com/docs/errors/unsupported_locale",
    "title": "Unprocessable Content",
    "status": 422,
    "detail": "The locale parameter supports en only.",
    "code": "unsupported_locale",
    "param": "locale",
    "errors": {
        "locale": [
            "The locale parameter supports en only."
        ]
    },
    "request_id": "req_01jbz8c6m3x4v9t2q7w5n8r0ka"
}
```

## Errors

| Code | Status | Meaning |
| --- | --- | --- |
| unauthorized | 401 | A valid, unrevoked bearer API key is required. |
| test_keys_only | 403 | This operation is free during preview and accepts abk_test_ keys only. |
| forbidden | 403 | The API key does not allow this operation. |
| end_before_start | 422 | The end parameter must not precede start at minute precision. |
| invalid_parameter | 422 | The start parameter must be a valid RFC 3339 datetime or HH:MM[:SS]. |
| unsupported_locale | 422 | The locale parameter supports en only. |
