Ocalt for Custom APIs
Turn a script into an endpoint. A file on a subdomain answers HTTP directly — you set the status, the headers and the body, read the query string, the post body and the cookies, and return JSON, HTML, an image or a file. No framework, no router, no deployment pipeline, and no server to keep patched.
The file is the route
A path maps to a file and an extensionless path falls back to .oql, so /orders runs orders.oql. Adding an endpoint is adding a file.
The request arrives intact
Method, query string, body and cookies reach your script unchanged, whether the caller is a browser, a phone, a webhook or another script. Sessions work the way they would anywhere else.
You own the response
Content type, status code, redirects and cookies are statements. An endpoint that must return an image returns an image; one that must return 404 returns 404. Nothing is wrapped in an envelope you did not ask for.
It is already scaled and already secured
TLS, the certificate, the process, the restarts and the patching are not yours. What is yours is the logic, and the bill is the queries it costs.
In practice
IF !REQUEST("method") IS IDENTICAL TO "POST"
OPEN
INSERT INTO DB "app" TABLE "signups" ROW "email" AS !POST("email")
AFTER STATUS 201
AFTER EMIT "created"
CLOSE
OR
OPEN
STATUS 405
AFTER EMIT "POST only"
CLOSE
Publish an endpoint
- Claim a subdomain.
SUBDOMAIN ADD "api"gives youapi.ocalt.siteimmediately, or point your own domain instead. - Write the handler. An
.oqlfile in that site is the endpoint.!GET,!POST,!REQUESTand!COOKIEcarry the caller's request. - Choose what you return.
HEADERsets the content type andSTATUSsets the code, so JSON, HTML, an image or a file are all just what you emit. - Test it with curl before anything depends on it.
HEADER "Content-Type" AS "application/json"
AFTER NEW OBJECT SET ?out
AFTER SET ?out("ok") AS true
AFTER SET ?out("echo") AS !GET("q")
AFTER EMIT ?outEvery plan, including Free, carries the whole language. Open the console, read the documentation, or see what a plan costs.