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.

StatusMeaning
400Bad request - missing or invalid fields.
401Unauthorised - missing or invalid API key.
404Not found - no link exists for that code.
405Method not allowed.
409Conflict - slug is already taken.
500Server error.
POST /api/shorten

Creates a new short link. Returns the full link object on success.

Request body

FieldTypeRequiredDescription
urlstringYesThe destination URL. Must include http:// or https://.
slugstringNoCustom short code. Letters, numbers, and hyphens only. Random if omitted.
expires_atstringNoISO 8601 expiry datetime. Link returns a dead page after this.
passwordstringNoRequire visitors to enter this password before redirecting.
click_capintegerNoDisable 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

ParameterTypeRequiredDescription
codestringYesThe 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'])