Make Statamic entries available through API, but limit which fields #12759
Closed
mgussekloo
started this conversation in
General
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'd like to make Entries available through a REST-api. Statamic has a built-in implementation, but I'd like to output only a few fields for each entry, for security and privacy purposes. Can this be done?
If not, how would I implement a custom API for this purpose? I can do something like
$entries = Entry::query()
->where('collection', 'languages')
->whereStatus('published')
->get();
But then I'm not sure how to select the fields I want ("id", "title", "uri_prefix"). Is there a way to use something like only() or pluck() on Entries?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions