# Quick api question

**URL:** <https://discourse.getcockpit.com/t/quick-api-question/1097>\
**Category:** General\
**Created:** [November 22, 2019, 12:27pm UTC](https://discourse.getcockpit.com/t/quick-api-question/1097 "2019-11-22T12:27:32Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [November 22, 2019, 5:30pm UTC](https://discourse.getcockpit.com/t/quick-api-question/1097/2 "2019-11-22T17:30:50Z")

</div>

You can create a custom api endpoint.

> [@How to create custom API Endpoints](https://discourse.getcockpit.com/t/how-to-create-custom-api-endpoints/202/5):
>
> In Cockpit you can create a custom api entry point pretty easy: Create the following file /config/api/custom.php we now do a custom query in that file: \<?php // very simple code here $test = $this-\>param('test'); if (!$test) { return false; } return $test; now you can query /api/custom?token=xxx&test=foo,bar,baz if you want to have the api public (without token) then create the file in a subfolder named public: /config/api/public/custom.php now you can query /api/public/custom?tes…

with some code like this (not tested):

```php
$collection1 = cockpit('collections')->find('collection1');
$collection2 = cockpit('collections')->find('collection2');
return compact('collection1', 'collection2');

```

---

_[View the full topic](https://discourse.getcockpit.com/t/quick-api-question/1097)._
