Skip to content

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:

FieldTypeDescription
statusnumberHTTP status code (200, 404, etc.)
bodystringResponse body
okbooltrue if status is 2xx
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)
end

local res = pl.http_post(url, body, contentType?)

Content type defaults to "application/json".

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)
end
local res = pl.http_post(
"https://api.example.com/upload",
"name=test&value=42",
"application/x-www-form-urlencoded"
)

HTTP requests are restricted to approved domains for security. Requests to unlisted domains are blocked with an error.

Allowed domains:

CategoryDomains
Plinkenplinken.com, api.plinken.com, app.plinken.com
AIapi.openai.com, api.anthropic.com, generativelanguage.googleapis.com, api.replicate.com, api.fal.ai
Musicapi.spotify.com, api.soundcloud.com, freesound.org
Devapi.github.com, raw.githubusercontent.com, httpbin.org
Locallocalhost, 127.0.0.1

Subdomains of allowed domains are also permitted (e.g. v1.api.plinken.com).


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