Skip to main content

Slugify API

Turn any headline or phrase into a clean, URL-safe slug for blog posts and permalinks.

EndpointPOST https://astraltext.com/api/v1/slugify
AuthBearer token, free
Sendsinput: text
Returnsresult: text
PriceFree. 1,000 calls a day, 60 a minute.

When to call it

Slugs are generated at the moment content is created, which is usually inside a CMS, an import script or a static site build. Using one endpoint everywhere is what stops the same title producing three different URLs in three parts of the stack.

For a one-off, the browser version needs no token and never sends your data anywhere: it runs on your own machine.

Example

curl
curl -X POST https://astraltext.com/api/v1/slugify \
  -H "Authorization: Bearer ast_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"input": "L'Été 2026: 10 idées (enfin) utiles!"}'
response
{
  "tool": "slugify",
  "result": "lete-2026-10-idees-enfin-utiles",
  "chars": 31,
  "ms": 1
}

In your language

JavaScript
const res = await fetch("https://astraltext.com/api/v1/slugify", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ASTRAL_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"input": "L'Été 2026: 10 idées (enfin) utiles!"}),
});
if (!res.ok) throw new Error((await res.json()).detail);
const { result } = await res.json();
Python
import os, requests

res = requests.post(
    "https://astraltext.com/api/v1/slugify",
    headers={"Authorization": f"Bearer {os.environ['ASTRAL_TOKEN']}"},
    json={"input": "L'Été 2026: 10 idées (enfin) utiles!"},
    timeout=30,
)
res.raise_for_status()
result = res.json()["result"]

Parameters

FieldTypeNotes
inputstringRequired. Up to 200,000 characters per call.

Errors

Errors are RFC 7807 problem documents with a stable type you can branch on.

missing-token401No Authorization header.
bad-request400input missing or the wrong type.
tool-failed422The input could not be processed. detail says why.
quota-exceeded429Past 1,000 calls today.

Questions

How are accents handled?
They are folded to their base letter, so an accented title produces an ASCII slug rather than a percent-encoded one.
What happens to punctuation and spaces?
Punctuation is dropped and runs of spaces become a single hyphen. Leading and trailing hyphens are trimmed.
Is it stable?
Yes. The same title always produces the same slug, which matters because a slug that changes is a URL that breaks.

Other endpoints

A token takes thirty seconds

Free, no card, 1,000 calls a day, and the same token works on astraltext.com, astralpdf.com, astraljson.com and astralbatch.com.

Get a free token