Skip to main content

Questions tagged [plugin-elementapi]

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

Filter by
Sorted by
Tagged with
2 votes
1 answer
476 views

Element API Fetch Entries URL Within Matrix

I have a matrix with a field to set a Entries URL. Unfortunately the entry is not being returned, only an empty object. Here are my field settings below and element api code. See below for the ...
Filth's user avatar
  • 153
1 vote
0 answers
191 views

Craft 3 Element Api when system status is disabled

Using Craft 3 RC14 System status is set to off Wondering if anyone has approached the same problem as I did. If there is a way to use element api while the system status is disabled? I have tried ...
Jarek's user avatar
  • 11
1 vote
0 answers
445 views

What are my caching options when using CraftQL and React?

I’m experimenting with the CraftQL plugin and React with Craft 3, and I’m really liking the similar syntax to standard Twig element queries, and the fact I don't need to manually configure API ...
Alex H's user avatar
  • 955
3 votes
1 answer
2k views

Element API display entries by category

With v2 of the Element API plugin, I'm having issues with working out how to return entries that are in a particular category. I've got the slug in the API route but can't work out what the query ...
jamie's user avatar
  • 133
1 vote
1 answer
331 views

Get PDF file from Assets Folder - Element API

I have a PDF folder within assets and having trouble accessing the file path once chosen by the user. To get something like an image from assets within a matrix I do something like this which works: ...
Filth's user avatar
  • 153
1 vote
2 answers
845 views

Image transform with focal point - in Element API

I can call predefined image transforms no problem - $image->getUrl('small') but cropped mobile transforms need to use the image asset's set focal point (from the Image Editor). I can't find any ...
Spotd's user avatar
  • 123
1 vote
1 answer
200 views

Using elements-api, how do i create a geojson structure with Features within a FeatureCollections

I am trying to output, from a single request, a geojson structure like so: "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": {}, ...
BillyMedia's user avatar
1 vote
1 answer
296 views

element-api plugin / get entry total in section in Craft 3

What is the best way to get only the total entry number from a section with the least overhead, in the element-api.php? Thanks Mark
Spotd's user avatar
  • 123
5 votes
3 answers
2k views

How to render a Twig template in the element-api plugin (v2.5)

I want to render a Twig template in an API endpoint. Specifically I need HTML for the JSON Feed field "content_html". My attempts until now (inside the transformer function): $view = Craft::$app->...
zauni's user avatar
  • 53
3 votes
1 answer
215 views

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 ...
jondotblack's user avatar
1 vote
0 answers
150 views

Using target element criteria to filter results

I'm using the Element API plugin to try and search for addresses using minimum and maximum lat & lng values and then using target element within the criteria parameters to filter the results ...
user311's user avatar
  • 21
1 vote
1 answer
681 views

Element API with multiple categories gives back error 500

This works fine on localhost but crashes on remote Server. I can return one category, but it will crash when I try to display multiple categories. I also tried to save the categories in a variable and ...
user2190590's user avatar
1 vote
0 answers
839 views

How to get list of category groups?

Is it possible to get a list of category groups without having to loop through all categories to get their parent group name? UPDATE: Just making this question clearer, as it's related to using ...
samput's user avatar
  • 51
1 vote
1 answer
71 views

Authorization fail

I am trying to being authorized at Chanel Adviser but it's showing error, "invalid_client". I am invoking this URL : https://api.channeladvisor.com/oauth2/token?client_id=...
kazi's user avatar
  • 11
1 vote
0 answers
414 views

Using element API to query a matrix field

I'm using the Element API to grab entries and their data (via this answer). What I want to do is accept a URL parameter (eg. ?location=foo) and filter the returned entries by a Matrix field called ...
Matt Andrews's user avatar
1 vote
1 answer
292 views

getting the current user entries from elementapi

How do I use the elementapi to get the list of entries for the logged in user? I've tried a couple of options to no avail, like 'api/v1/user/<userId:\d+>.json' => function($userId) { ...
Steven Grant's user avatar
  • 1,855
2 votes
1 answer
216 views

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 ...
kotyy's user avatar
  • 101
4 votes
1 answer
482 views

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. "...
michael_r's user avatar
1 vote
1 answer
853 views

Element API access param in transformer

Each of my entries has multiple categories (e.g. series, disciplines, and stages). I can get a list of elements related to a single category but I'd also like to get the category information as well (...
samput's user avatar
  • 51
1 vote
1 answer
830 views

Element API: Remove additional set of square brackets from JSON-String

We're currently having an Android-App access some of the entries of our Craft-based website. We are currently still using a self built API, and for easier creation of new API-Calls we are trying to ...
justussimon91's user avatar
1 vote
1 answer
43 views

MySQL ColumnType::Time does does not populate model from setAttribute()

I have a record with a time field set like this: 'startTime' => array(AttributeType::DateTime, 'column'=>ColumnType::Time, 'required' => true), 'endTime' => array(...
Rick Kukiela's user avatar
3 votes
2 answers
345 views

How do I sort and paginate a JSON feed by a key from a transformer?

I need to sort the entries for an Element API endpoint by a value calculated in a custom transformer. Is this possible? The use case is this: We're dealing with Events/Courses that have multiple ...
GTerrill's user avatar
  • 311
1 vote
1 answer
411 views

How do I retrieve tags and tag data for an entry in Element API?

In Element API v1, I am setting up an endpoint that is trying to expose a news entry including the tags (title, id, slug) associated with it. Thought it could be set up similarly to how you can ...
Nomad Guy's user avatar
  • 135
1 vote
0 answers
254 views

Craft CMS Integration with Node

Question 1 I have a Node/Express application where the users are registered and are using some kind of service. I want to have a list of the registered users and their info inside Craft CMS admin ...
Radoslav Julic's user avatar
2 votes
1 answer
520 views

Check for logged in user with the Element API plugin

Working on a SPA with Vue and Craft and looking to check if a user is logged in to run some Vue conditional logic. I imagine that will then enable me to check if the logged in user owns content to ...
Steven Grant's user avatar
  • 1,855
2 votes
1 answer
1k views

Element API + JSON data in template

Is there any way to include the JSON response from element API in a template. Let's take the following example: /case-studies.json returns: { data: [ { title: "American ...
sreucherand's user avatar
1 vote
1 answer
573 views

Element API: how can I return entries via username?

Struggling to get this feed work with Element API. I'm trying to return all entries created by a specific username. I've tried several different methods, but none of them work. Here is the latest ...
Noah Yamen's user avatar
1 vote
1 answer
503 views

Changing the output of ElementAPI

Wondering if it's possible to change the output that I'm getting from ElementAPI. I'm using the API to preload assets, and this is the output I'm getting. { "data": [ { "title"...
Jesse Winton's user avatar
1 vote
1 answer
234 views

Configuring Element API 1.2.1 Plugin

I'm running Craft CMS 2.6.2972 so I had to use the older Element API plugin. I have downloaded the zip and then copied just the "elementapi" file in the zip to the plugin's folder. Then I installed ...
Tim's user avatar
  • 355
4 votes
0 answers
877 views

How to handle Craft 3 events in a plugin? Element API is returning null data

The below refers to Craft 3 and the Element API plugin for Craft 3. I would like to do something when the Element API plugin fires its onBeforeSendData event, I can see in the controller for element ...
Paul Blundell's user avatar
1 vote
2 answers
2k views

ElementAPI: How to order and/or limit results?

Currently collaborating on a site with another developer, which is using ElementAPI pretty heavily for content delivery. Is there a way to limit the number of returns on any given json feed? Say; ...
Noah Yamen's user avatar
2 votes
1 answer
125 views

List Orders with datePaid is within last 14 days using the Element API plugin

I want to list the orders with datePaid is within last 14 days. But I cannot workout the correct criteria, and I don't know if isPaid works correctly as well: 'criteria' => [ 'dateUpdated' =&...
idolab's user avatar
  • 112
3 votes
2 answers
602 views

How to skip the first X entries using ElementAPI

I'm looking how to use the .offset(x) parameters of craft.entries inside the ElementAPI. I tried to add 'offset' => 1 before, after and inside the criteria array, but the x first entries are still ...
Romain P.'s user avatar
  • 1,917
0 votes
2 answers
189 views

Access handle value using element API

I'm using the Element API and would like to return content based on it's handle. The two handles I am trying to return are called appLogo and appVideo: 'api/featured-apps.json' => [ 'elementType'...
Molly Harper's user avatar
1 vote
1 answer
284 views

how can I filter to get only root categories in elementapi.php

I tried to build JSON-API which returns all categories, whose result will be cascaded like "nav" tag with craft twig templating (see: https://craftcms.com/docs/templating/craft.categories ). to get ...
Yoshito Maeoka's user avatar
2 votes
1 answer
78 views

ElementAPI: Include author/user data with entry?

Searched around online and couldn't find an answer to this question. I want to be able to include some data from the author/user account associated with an entry. Here is the basic working version ...
Noah Yamen's user avatar
3 votes
2 answers
338 views

Get 'purchasable' from ElementAPI

The elementApi docs state you can use custom elementTypes via plugins. I am using craft commerce which states it creates the custom elementType 'purchasable' I've tried: return [ 'endpoints' => [...
Chilly's user avatar
  • 53
2 votes
1 answer
81 views

Update content inside cache tag

Hello I am building a system in craft cms using the getharvest api. I have 'translated' the php api to support twig. The problem is the getharvest api is really slow (10+ seconds loading time) I have ...
Branko's user avatar
  • 497
1 vote
1 answer
709 views

Element API: return a related entry's asset data with entry data

I'm producing a list of entries that each use an image asset from a related entry. I see in this ticket how to get an asset's data, and I've combined that with how I learned to output an object's ...
Ryan's user avatar
  • 1,972
1 vote
1 answer
481 views

How delete a user session with the element api?

I need a function to logout a craft user and delete the session of that user. This must take place in the element API plugin as an endpoint. Something like this: function userLogout(){ if (craft()...
Maarten Heideman's user avatar
1 vote
1 answer
142 views

Element API: PHP Error: Fatal error: Allowed memory size of 33554432 bytes exhausted

Trying to get this json api to work for us and keep running into issues. Here, when trying to list all items, it throws the following PHP error: Fatal error: Allowed memory size of 33554432 bytes ...
Noah Yamen's user avatar
3 votes
1 answer
371 views

ElementAPI: Error's out if entry doesn't have assets

These keeps erroring out if any of the entries' do not have any assets in the 'listingPhotos' field. However, IF all entries have at least 1 photo in the 'listingsPhotos' field, it works. The Error ...
Noah Yamen's user avatar
2 votes
1 answer
1k views

Mixed relation criteria operator in Element API

I have a bit complex filtering system that I try to replicate using Element API. So far I have this which works to a degree: Example url: training.json?reg=124&cat=99&prod=129&erp= '...
Lukigi's user avatar
  • 565
2 votes
1 answer
223 views

Limit the entries element API will return based on the post date

I'm looking to only return entries that were published in the last 90 days.
Steven Grant's user avatar
  • 1,855
1 vote
1 answer
245 views

Complex Conditionals with ElementCriteriaModel / Element API

Working with the Element API for the first time and I'm having a bit of a hard time finding any kind of documentation regarding writing more complex conditionals using the ElementCriteriaModel. What ...
Michael Witwicki's user avatar
1 vote
1 answer
158 views

How do you use the Venti Calendar plugin with the Element API plugin?

I want an endpoint in the Element API plugin that shows the last event entries from the Venti Calendar plugin. The Element API guide tells that's possible to use the plugin with custom element types. ...
Maarten Heideman's user avatar
1 vote
1 answer
989 views

Element API CORS issue

I'm running into this effectively https://github.com/pixelandtonic/ElementAPI/issues/4 and I'm not quite sure how I'd integrate this change with https://gist.github.com/stevieg83/...
Steven Grant's user avatar
  • 1,855
1 vote
3 answers
705 views

Get repeated events with the Solspace Calendar and Element API plugins

When looping through all events in Twig, repeated events will continuously come in. On a weekly event, for instance, it pulls one for this week, one for next week, etc. Lets say I have a meeting event ...
aw04's user avatar
  • 185
1 vote
1 answer
345 views

How to use the Element API endpoint without wrapping it in data object

By default the Element API plugin all endpoints in a data object like this: { "data": [ { "key" : "value", "key2": "value2" } ]} But i don't want to wrap this in the data object but like this: { "...
Maarten Heideman's user avatar
0 votes
1 answer
820 views

Getting categories in elementAPI performance issues and help required

I am using elementAPI to get data from a directory. The items listed in the directory have two categories assigned: Category level 1 country Category level 2 region Below is how I am getting the data ...
joomkit's user avatar
  • 2,082