Element API: Entry field inside a Channel entry being passed into JSON file Hopefully my titles makes some sense but I will try to elaborate.

I have a Channel entry called Movies that I am using the Element API to turn into JSON. There is a field inside that called Movie Genre which is an Entry type field.

When I create this transformer:

'transformer' =&gt; function(EntryModel $movie) {

                return [
                    'name' =&gt; $movie-&gt;title,
                    'genres' =&gt; $movie-&gt;movieGenre[0]-&gt;title
                ];
            },


This is the JSON I get now, which looks to me like it is gathering all entries, not just the ones inside the channel.


  {"data":[{"name":"Harry Potter and The Order of the
  Phoenix","genres":"Fantasy"},{"name":"Jurassic
  World","genres":"Science
  Fiction"},{"name":"Romance","genres":null},{"name":"Science
  Fiction","genres":null},{"name":"Comedy","genres":null},
  {"name":"Fantasy","genres":null},{"name":"Guardians
  of the Galaxy","genres":"Action"},{"name":"Horror","genres":null},
  {"name":"Action","genres":null},{"name":"Home","genres":null},
  {"name":"Thirteen Ghosts","genres":"Horror"},
  {"name":"Movies","genres":null},{"name":"Genres","genres":null}],"meta":
  {"pagination":
  {"total":13,"count":13,"per_page":100,"current_page":1,"total_pages":1,"links":[]}}}


What I need to happen is only the Movies get returned as an item in the JSON and the movieGenre entry type not as its own item.

This is the desired JSON outcome.


  {"data":[{"name":"Harry Potter and The Order of the
  Phoenix","genres":"Fantasy"},{"name":"Jurassic
  World","genres":"Science Fiction"},{"name":"Guardians of the
  Galaxy","genres":"Action"},{"name":"Thirteen
  Ghosts","genres":"Horror"}],"meta":{"pagination":{"total":13,"count":13,"per_page":100,"current_page":1,"total_pages":1,"links":[]}}}
I figured it out. Turned out I had entered the criteria incorrectly, as channel instead of section.

'criteria' =&gt; ['section' =&gt; 'movies'],


not

'criteria' =&gt; ['channel' =&gt; 'movies'],