Is it possible to return value for api key only if param is given?

#1

Is it possible to return value for API key only if param is given? I want to create a new API key, that will allow grabbing only collection items when a specified parameter is included in a call.
Or is there any way to send id of a collection item & password and then get a null response or collection item if data was correct?

0 Likes

#2

You could create a custom endpoint in config/api/myendpoint.php, create an api key, that only allows /api/myendpoint and do you custom checks. Something like this:

<?php

if ('123qwe' !== $this->param('pwd', null)) return false;

if (!$id = $this->param('id', null)) return false;

return $this->module('collections')->findOne('pages', ['_id' => $id]);
0 Likes