Developers

The peyaji API

Make short links from a script, a bot or your own server with one HTTP request. It’s free, answers in JSON, and needs no sign-up or key. API keys, with higher limits, your own domain and tools to manage your links, are part of the Pro plan, coming soon.

Make a short link

Send a POST with a JSON body to https://peyaji.com/shorturl/api/shorten:

curl -X POST https://peyaji.com/shorturl/api/shorten \
  -H 'content-type: application/json' \
  -d '{"url": "https://example.com/a/very/long/address"}'

The same from JavaScript (Node.js 18 or newer, Deno, Bun or a Cloudflare Worker):

const res = await fetch('https://peyaji.com/shorturl/api/shorten', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({ url: 'https://example.com/a/very/long/address' }),
});
const link = await res.json();
if (!res.ok) throw new Error(link.error);
console.log(link.shortUrl);

What you can send:

With a key, you can also send domain (see below).

A new link is answered with 201 Created:

{
  "code": "abc1234",
  "shortUrl": "https://peyaji.com/abc1234",
  "previewUrl": "https://peyaji.com/abc1234+",
  "url": "https://example.com/a/very/long/address",
  "createdAt": "2026-11-15T09:30:00.000Z",
  "checked": true,
  ...
}

shortUrl is the link to share, and previewUrl shows where it leads without going there. checked is true when Google Safe Browsing looked at the destination and found nothing wrong. The answer may carry other fields, such as the key of the link’s private clicks page: keep those to yourself, since they are the only proof that you made the link.

With an API key

API keys are part of the Pro plan, coming soon. Keys made before plans began keep working. Make a key under API keys on your account page, and send it with every request:

curl -X POST https://peyaji.com/shorturl/api/shorten \
  -H 'authorization: Bearer pk_YOUR_KEY' \
  -H 'content-type: application/json' \
  -d '{"url": "https://example.com/a/very/long/address"}'

A key that has expired, is disabled or was removed is answered with 401 Unauthorized and an error that says which.

With a key you can also work with the links in your account. Send the key the same way with each request.

List your links

curl https://peyaji.com/shorturl/api/links \
  -H 'authorization: Bearer pk_YOUR_KEY'

The answer lists your newest links first, a page at a time, each with its code, domain (null on peyaji.com), shortUrl, url, createdAt, clicks and status ("active", "off" when you switched it off, or "disabled" when it was taken down). When there are more, cursor isn’t null: ask again with ?cursor= and that value for the next page.

Switch a link off or back on

curl -X POST https://peyaji.com/shorturl/api/links/state \
  -H 'authorization: Bearer pk_YOUR_KEY' \
  -H 'content-type: application/json' \
  -d '{"code": "abc1234", "domain": null, "on": false}'

Visitors to a link that is off are told its owner switched it off. The answer is the link’s new status. A link that was taken down for breaking the Terms of Use can’t be switched back on.

Read a link’s clicks

curl 'https://peyaji.com/shorturl/api/links/stats?code=abc1234' \
  -H 'authorization: Bearer pk_YOUR_KEY'

Add &domain=go.yourbrand.com for a link on your own domain. The answer has total (every click), days (clicks per day, oldest first and ending today, in UTC), and countries, sources and devices, each by the number of days they cover, such as "30", as a list of [name, clicks] pairs, most first. A country is two letters, "" is unknown and "*" is all the others together.

Change where a link on your own domain goes

curl -X POST https://peyaji.com/shorturl/api/links/edit \
  -H 'authorization: Bearer pk_YOUR_KEY' \
  -H 'content-type: application/json' \
  -d '{"code": "menu", "domain": "go.yourbrand.com", "url": "https://yourbrand.com/winter-menu"}'

Only links on a domain connected to your account can be changed, so a printed QR code can stay up to date. Links on peyaji.com never change. The new address goes through Google Safe Browsing first, and the link’s preview page lists every change, just as when you edit it on your account page.

A link that isn’t yours, or doesn’t exist, is answered with 404. Switching and editing share an allowance of 120 changes an hour, and reading clicks allows 300 requests an hour, both for the account and shared with your account page.

Limits

Opening short links doesn’t count towards these limits.

Errors

Every error is a JSON object with an error message written for people, and, when one field is to blame, field ("url" or "alias"):

{"error": "This alias is already taken. Try another one.", "field": "alias"}

Good to know

Built something with it?

We’d love to hear about it at support@peyaji.com. If your project has a README or a page about how it works, a link back to peyaji helps other people find the service.