A simple, fast URL shortener built with Cloudflare Workers and D1.
POST /api/shorten
Send a JSON body with the target url. The slug field is optional.
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"}'
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"}'
{
"slug": "my-link",
"short_url": "https://u.hijitoko.com/my-link",
"original_url": "https://example.com"
}
{
"error": "Slug already in use"
}
GET /stats/:slug
Visit https://u.hijitoko.com/stats/your-slug in your browser to see detailed analytics.
Links that have not been accessed in the last 30 days will be automatically deleted.