Rotate PDF API
Turn every page by a quarter, a half or three quarters.
| Endpoint | POST https://astralpdf.com/api/v1/rotate-pdf |
| Auth | Bearer token, free |
| Sends | input: base64 |
| Returns | result: base64 |
| option | 90 | 180 | 270 |
| Price | Free. 1,000 calls a day, 60 a minute. |
When to call it
Scanners and phone cameras produce sideways pages, and they produce them consistently, which means the fix can be applied in the same step as the ingest rather than by whoever opens the file next and tilts their head.
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://astralpdf.com/api/v1/rotate-pdf \
-H "Authorization: Bearer ast_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"input": "JVBERi0xLjcKJYGBgYEK...", "option": "90"}'response
{
"tool": "rotate-pdf",
"result": "JVBERi0xLjcKJWDjz9MKMSAwIG9iago8PC9UeXBlL0NhdGFsb2c...",
"chars": 1904,
"ms": 23
}In your language
JavaScript
const res = await fetch("https://astralpdf.com/api/v1/rotate-pdf", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ASTRAL_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"input": "JVBERi0xLjcKJYGBgYEK...", "option": "90"}),
});
if (!res.ok) throw new Error((await res.json()).detail);
const { result } = await res.json();Python
import os, requests
res = requests.post(
"https://astralpdf.com/api/v1/rotate-pdf",
headers={"Authorization": f"Bearer {os.environ['ASTRAL_TOKEN']}"},
json={"input": "JVBERi0xLjcKJYGBgYEK...", "option": "90"},
timeout=30,
)
res.raise_for_status()
result = res.json()["result"]Parameters
| Field | Type | Notes |
|---|---|---|
| input | string | Required. The file, base64 encoded. A data: URL is accepted too. Up to 6,000,000 characters per call. |
| option | string | One of: 90, 180, 270. |
Errors
Errors are RFC 7807 problem documents with a stable type you can branch on.
| missing-token | 401 | No Authorization header. |
| bad-request | 400 | input missing or the wrong type. |
| bad-option | 400 | option is not one of the listed values. |
| tool-failed | 422 | The input could not be processed. detail says why. |
| quota-exceeded | 429 | Past 1,000 calls today. |
Questions
- Is the rotation absolute or relative?
- Relative. The angle is added to whatever the page already had, so rotating by 90 and then by 270 returns the page to where it started.
- Can I rotate one page only?
- Not in a single call. Split the page out, rotate it, then merge it back. All three are endpoints here.
- Does it re-render the page?
- No. Only the page's rotation entry changes, so the content is untouched and the file does not grow.
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