HTTP / Network
Make HTTP GET and POST requests from Lua scripts. Requests have a 30-second timeout.
local res = pl.http_get("https://api.example.com/data")Returns:
| Field | Type | Description |
|---|---|---|
status | number | HTTP status code (200, 404, etc.) |
body | string | Response body |
ok | bool | true if status is 2xx |
Example
Section titled “Example”local res = pl.http_get("https://httpbin.org/json")if res.ok then pl.log("Got: " .. res.body)else pl.log("Error: HTTP " .. res.status)endlocal res = pl.http_post(url, body, contentType?)Content type defaults to "application/json".
Example
Section titled “Example”local payload = '{"prompt": "Generate a chord progression"}'local res = pl.http_post("https://api.example.com/generate", payload)if res.ok then pl.log(res.body)endForm data
Section titled “Form data”local res = pl.http_post( "https://api.example.com/upload", "name=test&value=42", "application/x-www-form-urlencoded")Domain Allowlist
Section titled “Domain Allowlist”HTTP requests are restricted to approved domains for security. Requests to unlisted domains are blocked with an error.
Allowed domains:
| Category | Domains |
|---|---|
| Plinken | plinken.com, api.plinken.com, app.plinken.com |
| AI | api.openai.com, api.anthropic.com, generativelanguage.googleapis.com, api.replicate.com, api.fal.ai |
| Music | api.spotify.com, api.soundcloud.com, freesound.org |
| Dev | api.github.com, raw.githubusercontent.com, httpbin.org |
| Local | localhost, 127.0.0.1 |
Subdomains of allowed domains are also permitted (e.g. v1.api.plinken.com).
Practical Example: Call OpenAI
Section titled “Practical Example: Call OpenAI”local res = pl.http_post( "https://api.openai.com/v1/chat/completions", '{"model":"gpt-4","messages":[{"role":"user","content":"Write a 4-bar melody"}]}', "application/json")if res.ok then pl.log(res.body)end