Answers.Body: <p>Use the config setting <code>'first' =&gt; true</code> and wrap the endpoint in a function</p>
  
  <p>like this:</p>
  
  <pre><code>'api/link' =&gt; function() {
      return [
          'elementType' =&gt; 'Entry',
          'first' =&gt; true,
          'criteria' =&gt; ['section' =&gt; 'mysecton'],
          'paginate' =&gt; false,
          'transformer' =&gt; function(EntryModel $entry) {
              return $something;
          }
      ];
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-19T15:12:41.807Z
Answers.LastActivityDate: 2016-12-19T18:49:54.323Z
Answers.LastEditDate: 2016-12-19T18:49:54.323Z
Answers.UserDisplayName: Maarten Heideman
Body: <p>By default the Element API plugin all endpoints in a data object like this:</p>
  
  <pre><code>{ "data": [ { "key" : "value", "key2": "value2" } ]}
  </code></pre>
  
  <p>But i don't want to wrap this in the data object but like this:</p>
  
  <pre><code>{ "key" : "value", "key2": "value2" }
  </code></pre>
  
Tags: <plugin-elementapi>
Title: How to use the Element API endpoint without wrapping it in data object
ThreadText: # How to use the Element API endpoint without wrapping it in data object
  
  (Asked by: username_0 on 2016-12-19)
  
  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:
  
  ```
  { "key" : "value", "key2": "value2" }
  
  ```
  
  **Tags:** plugin-elementapi
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-12-19. Score: 1
  
  Use the config setting `'first' => true` and wrap the endpoint in a function
  
  like this:
  
  ```
  'api/link' => function() {
      return [
          'elementType' => 'Entry',
          'first' => true,
          'criteria' => ['section' => 'mysecton'],
          'paginate' => false,
          'transformer' => function(EntryModel $entry) {
              return $something;
          }
      ];
  }
  
  ```
  
  
  ---
  
  