Fetch collection definitions / meta data

You can create a custom api endpoint. Just create the file /path/to/cockpit/config/api/model.php.

<?php

$modelName = $this->param('model');

if (!$modelName) {
    return $this->stop(['error' => "model parameter missing"], 412);
}

// TODO: permission checks

$model = $this->module('content')->model($modelName);

if (!$model) {
    return $this->stop(['error' => "Model <{$modelName}> not found"], 404);
}

// TODO: filter sensitive data

return $model;

Now you can access the model data via https://example.com/api/model?model=BlogPosts.

1 Like