QUICK START / EXAMPLES

Copy. Run. Integrate.

These examples submit 120 cartons measuring 60 × 40 × 40 cm. Expect 11.52 m³. Use the playground to generate other requests. Review errors before retrying.

cURL (Bash)

Example
curl --fail-with-body --max-time 15 -X POST 'https://stooper.co/api/v1/cbm' \
  -H 'Content-Type: application/json' \
  --data-binary '{"items":[{"length":60,"width":40,"height":40,"unit":"cm","quantity":120}]}'

Python (standard library)

Example
import json, urllib.request, urllib.error
req = urllib.request.Request('https://stooper.co/api/v1/cbm',
    data='{"items":[{"length":60,"width":40,"height":40,"unit":"cm","quantity":120}]}'.encode('utf-8'),
    headers={'Content-Type': 'application/json'}, method='POST')
try:
    with urllib.request.urlopen(req, timeout=15) as res:
        print(json.dumps(json.load(res), indent=2))
except urllib.error.HTTPError as err:
    print(err.code, err.read().decode('utf-8', errors='replace'))

JavaScript (Node.js 18+)

Example
async function main() {
  const res = await fetch('https://stooper.co/api/v1/cbm', {
    method: 'POST', headers: {'Content-Type': 'application/json'},
    body: "{\"items\":[{\"length\":60,\"width\":40,\"height\":40,\"unit\":\"cm\",\"quantity\":120}]}", signal: AbortSignal.timeout(15000)
  });
  console.log(res.status, await res.text());
}
main().catch(console.error);

PHP (cURL extension)

Example
<?php
$ch = curl_init('https://stooper.co/api/v1/cbm');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS => '{"items":[{"length":60,"width":40,"height":40,"unit":"cm","quantity":120}]}',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15
]);
$result = curl_exec($ch);
if ($result === false) { echo curl_error($ch); }
else { echo curl_getinfo($ch, CURLINFO_HTTP_CODE), PHP_EOL, $result; }
curl_close($ch);

Windows PowerShell

Example
$body = '{"items":[{"length":60,"width":40,"height":40,"unit":"cm","quantity":120}]}'
Invoke-RestMethod -Uri 'https://stooper.co/api/v1/cbm' `
    -Method Post -ContentType 'application/json' `
    -TimeoutSec 15 -Body ([Text.Encoding]::UTF8.GetBytes($body)) |
    ConvertTo-Json -Depth 20

MCP PowerShell handshake and tool call

Example
$url = 'https://stooper.co/mcp/index.php'
$headers = @{ Accept = 'application/json, text/event-stream'
    'MCP-Protocol-Version' = '2025-11-25' }
function Invoke-StooperMCP($request) {
    Invoke-RestMethod -Uri $url -Method Post -Headers $headers `
        -ContentType 'application/json' -TimeoutSec 15 `
        -Body ($request | ConvertTo-Json -Depth 20)
}
Invoke-StooperMCP @{jsonrpc='2.0'; id=1; method='initialize'; params=@{
    protocolVersion='2025-11-25'; capabilities=@{};
    clientInfo=@{name='Stooper-example'; version='1.0'} }}
Invoke-StooperMCP @{jsonrpc='2.0'; method='notifications/initialized'}
$r = Invoke-StooperMCP @{jsonrpc='2.0'; id=2; method='tools/list'; params=@{}}
$r.result.tools | Select-Object name
$r = Invoke-StooperMCP @{jsonrpc='2.0'; id=3; method='tools/call'; params=@{
    name='stooper_calculate_cbm'; arguments=@{items=@(@{
        length=60; width=40; height=40; unit='cm'; quantity=120})} }}
$r.result | ConvertTo-Json -Depth 20

Rate limits and error handling