Custom API - get singletons by slug

This is not possible by default. If you want to filter them, use collections instead.

But you could create a custom api endpoint and fiddle with the results:

<?php

// custom api endpoint in `/config/api/singletons/find.php`

// Your Singletons with a field named "title"
// Search all Singletons with the title "test"
// tested with SQLite - I don't know, if it works with Mongo, too

$options = [
    'filter' => [
        'val.title' => 'test',
    ],
];

$singletons = $this->storage->find('singletons', $options);

return $singletons;

1 Like