URL Shortener API

A simple, fast URL shortener built with Cloudflare Workers and D1.

Endpoints

1. Create Short URL

POST /api/shorten

Send a JSON body with the target url. The slug field is optional.

Option A: Custom Slug

If you provide a slug, we will try to use it. Returns 409 Conflict if already taken.

curl -X POST https://u.hijitoko.com/api/shorten \\
  -H "Content-Type: application/json" \\
  -d '{"url": "https://example.com", "slug": "my-link"}'
        

Option B: Random Slug

If you omit the slug, we will generate a random 6-character code for you.

curl -X POST https://u.hijitoko.com/api/shorten \\
  -H "Content-Type: application/json" \\
  -d '{"url": "https://example.com"}'
        

Response Example (Success 201)

{
  "slug": "my-link",
  "short_url": "https://u.hijitoko.com/my-link",
  "original_url": "https://example.com"
}
      

Response Example (Error 409)

{
  "error": "Slug already in use"
}
      

2. View Stats Dashboard

GET /stats/:slug

Visit https://u.hijitoko.com/stats/your-slug in your browser to see detailed analytics.

Expiration Policy

Links that have not been accessed in the last 30 days will be automatically deleted.