GET variables as API arguments

For security reasons the API won't automatically convert GET params into arguments, but you can of course do exactly that manually in the Wireframe element that handles the request.

There are two ways to use GET params as API arguments:

Here's an example of hooking into the prepareArgs() method and merging GET argument called "some_variable" with any existing arguments:

$api->addHookAfter('prepareArgs', function(HookEvent $event) use ($input) {
    $event->return = array_merge($event->return, [
        $input->get->bool('some_variable'),
    ]);
});

Note that while in the example above we could've also allowed all GET params simply by merging $event->return with $input->get->getArray(), allowing users to freely pass arguments of their choice to your endpoint could be potentially dangerous.

Back to top