banshee is under active development: collectors will keep changing, and a version you publish will likely need adjustments. For stable use, wait for version 1.0.0.

Examples

banshee/examples-collection/examples/protocols/

http-get-headers

Example: http.get with headers=, and the headers of the answer; an API that answers JSON.

  • example
  • protocol
  • http
  • headers

by banshee1 installation1 version

v1Latest

Published on October 27, 2026. First version in this collection.

Keen 1.0.0 · 20 lines
// http.get with headers: send headers with the request with headers=, and read the headers of the answer.
// The collector checks that an API answers in JSON.
need('protocol:http');

$url = variable('example:api:url', 'text', array(
    'label' => 'Address of the API',
    'help'  => 'For example https://api.example/v1/status.',
));

output('content-type', 'text', array('label' => 'Type of the answer'));

watch.expect('not-json', 'API not answering JSON', 'content-type', array('warning' => array('application/json')));

$answer = http.get($url, headers=array('Accept' => 'application/json', 'Cache-Control' => 'no-cache'));

// The headers of the answer: each name in lowercase, a header sent twice joined by ", ".
$type = list.get($answer['headers'], 'content-type', 'none');
// "application/json; charset=utf-8": the part before the ; only.
$parts = text.split($type, ';');
value('content-type', text.trim($parts[0]));