REST API
link.bbnerds.com API
Create and query short links programmatically. Simple REST, JSON in, JSON out.
Introduction
The API lives at https://link.bbnerds.com/api. All requests and responses use JSON. There are two endpoints: one to create a short link and one to look up an existing one by code.
Base URL
https://link.bbnerds.com/api
Authentication
Every request must include an Authorization header with your API key as a Bearer token. You set the key yourself as a Vercel environment variable named API_SECRET_KEY.
Header
Authorization: Bearer YOUR_API_KEY
Errors
All errors return a JSON object with a single error string and a standard HTTP status code.
| Status | Meaning |
|---|---|
400 | Bad request - missing or invalid fields. |
401 | Unauthorised - missing or invalid API key. |
404 | Not found - no link exists for that code. |
405 | Method not allowed. |
409 | Conflict - slug is already taken. |
500 | Server error. |
POST
/api/shorten
Creates a new short link. Returns the full link object on success.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | The destination URL. Must include http:// or https://. |
slug | string | No | Custom short code. Letters, numbers, and hyphens only. Random if omitted. |
expires_at | string | No | ISO 8601 expiry datetime. Link returns a dead page after this. |
password | string | No | Require visitors to enter this password before redirecting. |
click_cap | integer | No | Disable the link after this many clicks. |
Response 201 Created
JSON
{
"short_code": "aB3xYz",
"short_url": "https://link.bbnerds.com/aB3xYz",
"original_url": "https://example.com/some/long/path",
"clicks": 0,
"click_cap": null,
"expires_at": null,
"password_protected": false,
"created_at": "2025-01-01T12:00:00.000Z"
}
GET
/api/lookup?code=aB3xYz
Returns the link object for a given short code.
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
code | string | Yes | The short code to look up. |
Response 200 OK
JSON
{
"short_code": "aB3xYz",
"short_url": "https://link.bbnerds.com/aB3xYz",
"original_url": "https://example.com/some/long/path",
"clicks": 42,
"click_cap": 100,
"expires_at": "2026-12-31T23:59:59.000Z",
"password_protected": false,
"created_at": "2025-01-01T12:00:00.000Z"
}
cURL
Create a link
curl -X POST https://link.bbnerds.com/api/shorten \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/very/long/path",
"slug": "my-link",
"click_cap": 50
}'
Look up a link
curl https://link.bbnerds.com/api/lookup?code=my-link \ -H "Authorization: Bearer YOUR_API_KEY"
JavaScript
fetch
const res = await fetch('https://link.bbnerds.com/api/shorten', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://example.com/very/long/path',
expires_at: '2026-12-31T23:59:59Z',
}),
});
const data = await res.json();
console.log(data.short_url);
Python
requests
import requests
res = requests.post(
'https://link.bbnerds.com/api/shorten',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
json={
'url': 'https://example.com/very/long/path',
'password': 'secret',
},
)
data = res.json()
print(data['short_url'])