Code examples
Both endpoints take the same request shape: a X-Api-Key header and a JSON body with one
code field. Below is the exact same call in cURL, PHP, Node.js and a browser, plus what
the response looks like. Don't have a key yet? Create an account.
# minify
curl -X POST https://obix.dev/v1/minify \
-H "X-Api-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"code":"function hi ( n ) { return \"hey \"+n }"}'
# mangle
curl -X POST https://obix.dev/v1/mangle \
-H "X-Api-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"code":"function hi(n){return \"hey \"+n}"}'
<?php
// swap /minify for /mangle - same shape, no config field
$ch = curl_init('https://obix.dev/v1/mangle');
curl_setopt_array($ch,[
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_POST=>true,
CURLOPT_HTTPHEADER=>['X-Api-Key: YOUR_KEY','Content-Type: application/json'],
CURLOPT_POSTFIELDS=>json_encode(['code'=>$js]),
]);
$r = json_decode(curl_exec($ch),true);
echo $r['ok'] ? $r['code'] : "error: $r[err]";
// minify a bundle before shipping
let r = await fetch('https://obix.dev/v1/minify',{
method:'POST',
headers:{'X-Api-Key':'YOUR_KEY','Content-Type':'application/json'},
body:JSON.stringify({code:src})
});
let d = await r.json();
if(d.ok) fs.writeFileSync('app.min.js',d.code);
else console.error(d.err);
let r = await fetch('https://obix.dev/v1/mangle',{
method:'POST',
headers:{'X-Api-Key':'YOUR_KEY','Content-Type':'application/json'},
body:JSON.stringify({code:editor.getValue()})
});
let d = await r.json();
output.textContent = d.ok ? d.code : d.err;
{
"ok": 1,
"code": "function hi(n){return\"hey \"+n}",
"bytesIn": 214,
"bytesOut": 47,
"ms": 6
}
That's the whole surface - no SDK, no build step. Full details on every field, header and error code are in the API reference.
