Questions tagged [plugin-elementapi]

Plugin that makes it easy to create a JSON API for your elements, from Pixel & Tonic.

For more information visit the plugin’s GitHub page.

229 questions
6
votes
1 answer

Is there a way to split the element-api.php file?

Is there some way I can split the element-api.php file into separate files and import them all? It's getting quite long and unwieldy.
5
votes
1 answer

Retrieve entry data from an Entries field in a Matrix Block

I'm using a Matrix field for menu section blocks that each have a name, section and menu items. The menu items for that menu section are assigned using an Entries fieldtype that displays entries from food and beverage entries. Here's a screenshot of…
5
votes
2 answers

How do you use the Element API plugin to output Matrix blocks for an entry?

I am having a hard time trying to figure out how to pull matrix blocks within an entry into the single entry's endpoint with the Element API plugin. Is this possible? Or do I need to output the blockId's and then create another API endpoint to query…
Paulo
  • 209
  • 2
  • 7
4
votes
1 answer

With Element API, can I combine two entry types into a JSON object, keyed by type?

I need to return two types of entry to an external service, and am trying to do so in one endpoint. I am able to return all of the instances of each type, but it returns an array of mixed types. "api/myEndpoint" => function() { return [ …
michael_r
  • 61
  • 4
4
votes
1 answer

How do I use the Element API to search via entry title?

I can't seem to find this anywhere. Thanks. Update: 'api/entry/search.json' => function() { return [ 'elementType' => 'Entry', 'criteria' => [ 'search' => (craft()->request->getParam('search')) ?…
Erik
  • 306
  • 2
  • 9
3
votes
1 answer

Break-up Element API Config into partials

I'm working on a Vue SPA (single page application) for a client and my ElementAPI config file has grown to be quite large. To make it easier to maintain I was looking for suggestions of how to have each endpoint in its own file. Any feedback is…
3
votes
1 answer

How do I query data using the Element API Plugin based on a custom field?

I have a channel called "offers". My Offers channel contains a field called "Users". The Users field is the "users" field type. It allows me to select 1 or more users that the Offer is for. I want to get JSON output for this data based on the…
Sandy D.
  • 383
  • 1
  • 11
3
votes
1 answer

Why is the summary and body returning an empty object using the Element API?

I'm not sure what I'm missing, but I'm getting an empty object back from the Element API for the summary and/or body for any given entry. elementapi.php ... 'transformer' => function (EntryModel $entry) { return [ 'title' =>…
Damon
  • 4,706
  • 1
  • 20
  • 36
2
votes
1 answer

Get last change timestamp in header response

I'll be polling an endpoint created with the element-api plugin which will trigger a concourse build. I need to include a timestamp the last time any entry was changed. So I need something to go in the setHeader…
Matt Simon
  • 21
  • 4
2
votes
1 answer

Element API throws 404 when not logged into CP

My element API endpoint throws a 404 when I'm logged out of the CP, but works fine when I'm logged in. When logged out it throws a regular 404 with stack trace exactly as any other non-existing url, when logged in it spits out JSON as it should be.…
Udo
  • 607
  • 4
  • 9
2
votes
1 answer

Disable dateUpdated

I am using Craft 3 to populate content over a REST api. Now I have a use case, where I want to update an internal field of an entry without changing the dateUpdated. Otherwise the clients would get informed about an update, but it is just for…
Volker Andres
  • 232
  • 3
  • 13
2
votes
1 answer

Element-API migration - entries by category

I am having trouble getting the related category passed thru to the entry api endpoint. I cant use : $criteria = craft()->elements->getCriteria(ElementType::Category); $criteria->id = $catId; $category = $criteria->first(); What…
joomkit
  • 2,014
  • 1
  • 13
  • 24
2
votes
1 answer

Restrict access to Element API endpoint

I'd like to Restrict access to Element API endpoint by the current user's group. Is this possible Using Craft 2?
Adam Menczykowski
  • 1,390
  • 11
  • 22
2
votes
2 answers

Element API - Filter on a value from a multi value field

I am looking for some assistance with the Element API plugin. I need to filter on the bannerPageCategories field which is a multi select checkbox field. The value will be passed via a querystring value. I can filter on a field with a single value…
Ray
  • 23
  • 4
2
votes
1 answer

Element API endpoint without a resourceKey

The output of a Element API endpoint allows you to change the resourceKey which contains the json data. Is it possible to return just the data without a resourceKey at all? Values such as null, false and empty string just default to data.
kotyy
  • 101
  • 6
1
2 3