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:
url(required): the address to shorten, starting withhttp://orhttps://.alias(optional): your own ending, such asmy-eventfor peyaji.com/my-event. 5 to 30 letters, numbers or dashes.
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"}'
- Higher limits: 60 links an hour and 300 a day for the account, wherever the requests come from.
- Your links stay together: links made with the key are in your account, with their clicks, and you can manage them with the key too. They count toward your plan’s number of links.
- Your own domain: add
"domain": "go.yourbrand.com"to the body to make the link on a domain connected to your account. - Tags: add
"tags": ["sale", "q4"](at most 5) to find the link by them in your account’s list. - It works for as long as you choose: 7, 30, 180 or 365 days (30 unless you pick another), or until a date of your own within the next 365 days. Your account page shows when it ends; make a new key before then.
- One key for each app: an account can have up to 10 keys, each with its own name and end date. The account page shows when each was last used, and disabling or removing one leaves the others working.
- What a key looks like:
pk_followed by 40 letters, digits,-and_. It is shown once, when you make it: the site keeps only a fingerprint of it (a SHA-256 hash), so a lost key can't be shown again; make a new one. - Keep it secret, like a password, and never put it in a web page. A key that leaked can be removed at once.
A key that has expired, is disabled or was removed is answered with 401 Unauthorized and an error that says which.
Manage your links
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
- Without a key: 20 links an hour and 100 a day for each IP address (for IPv6, each /64 network). The count is shared with the form on the home page.
- With a key: 60 links an hour and 300 a day for the account, shared with the links it makes on the site.
- Over a limit, the answer is
429 Too Many Requestswith aRetry-Afterheader: the number of seconds until you may try again. The windows are whole hours and whole days in UTC. - A
429can also mean that the site as a whole is busy. Wait forRetry-Afterand try again rather than retrying at once.
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"}
400: the address or alias isn’t valid, or the body isn’t JSON.401: the API key has expired, is disabled or was removed.404: the link isn’t one of yours.403: your plan doesn’t include this or its links are all used (the answer then has"plan": true), the destination is flagged as unsafe, the request came from a web page on another site (see below), or the site is asking for an “I am human” check and there is no key (see below).409: the alias is already taken.410: peyaji isn’t making new links at the moment.429: a limit was reached (see above).503: something peyaji needs can’t be reached right now. Try again later.
Good to know
- Call it from a server, not from a web page. Browsers send the page’s address with every request, and requests from pages on other sites are refused, so that nobody’s visitors use up a shared allowance without knowing it.
- Links on peyaji.com can’t be changed. Where a link leads never changes after it has been made. To point somewhere else, make a new link. Links on your own domain can be changed with a key.
- Use a key if your project depends on it. At times of heavy abuse peyaji can ask everyone who isn’t signed in to pass an “I am human” check, which a script can’t do. While it does, requests without a key are answered
403. Requests with a key always skip the check. - The Terms of Use apply to links made through the API just as to links made on the site. Links to phishing, malware or spam are switched off.
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.