Answers.Body: <p>If you set the <code>elementType</code> to <code>User</code>, then the transformer will have a <a href="https://craftcms.com/classreference/models/UserModel" rel="nofollow"><code>UserModel</code></a> object passed in like so:</p>
  
  <pre><code>&lt;?php
  namespace Craft;
  
  return [
      'endpoints' =&gt; [
          'players.json' =&gt; [
              'elementType' =&gt; 'User',
              'criteria' =&gt; ['group' =&gt; 'player'],
              'transformer' =&gt; function(\Craft\UserModel $user) {
                  return [
                      'username' =&gt; $user-&gt;username,
                      'jsonUrl' =&gt; UrlHelper::getUrl("player/{$user-&gt;id}.json")
                  ];
              },
          ]
      ]
  ];
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-18T17:47:10.970Z
Answers.Text: Thanks for getting back to me Brad: I get this:
  
  Property "Craft\UserModel." is not defined.
Answers.UserDisplayName: Graham Winston
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-18T18:01:54.557Z
Answers.Text: Did you get that error before or after my edit?
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-18T18:03:54.790Z
Answers.Text: Hi Brad, no all good, thanks a bunch for the help! It would be really helpful to see a full example with specific user profiles JSON like the entries is layed out :) Thanks again!
Answers.UserDisplayName: Graham Winston
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-18T17:45:06.370Z
Answers.LastActivityDate: 2016-04-18T17:47:47.497Z
Answers.LastEditDate: 2016-04-18T17:47:47.497Z
Answers.UserDisplayName: Brad Bell
Body: <p>I am attempting to build an application where Craft handles all of the API based data (JSON). I am using the <a href="https://github.com/pixelandtonic/ElementAPI" rel="nofollow">Element API</a>. I can't find an example anywhere online that outputs Users.</p>
  
  <p>I am trying to output some basics first before I start outputting the custom Matrix fields etc. Here is my <code>elementapi.json</code>: </p>
  
  <pre><code>&lt;?php
  namespace Craft;
  
  return [
      'endpoints' =&gt; [
          'players.json' =&gt; [
              'elementType' =&gt; 'User',
              'criteria' =&gt; ['group' =&gt; 'player'],
              'transformer' =&gt; function(EntryModel $entry){
                  return [
                      'username' =&gt; $entry-&gt;$username,
                      'jsonUrl' =&gt; UrlHelper::getUrl("player/{$entry-&gt;id}.json")
                  ];
              },
          ]
      ]
  ];
  </code></pre>
  
  <p>Any help or an example with some custom matrix user fields would be much appreciated! Thanks a bunch!</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-04-18T17:46:15.157Z
Comments.Text: Hi Brad, thanks for editing there, sorry I left the namespace out, that is actually *is* in my elementapi.php . I am just getting a blank page at the moment when I reference mysite.dev.com/players.json
Comments.UserDisplayName: Graham Winston
Tags: <plugin-elementapi><json>
Title: Element API User example
ThreadText: # Element API User example
  
  (Asked by: username_0 on 2016-04-18)
  
  I am attempting to build an application where Craft handles all of the API based data (JSON). I am using the [Element API](https://github.com/pixelandtonic/ElementAPI). I can't find an example anywhere online that outputs Users.
  
  I am trying to output some basics first before I start outputting the custom Matrix fields etc. Here is my `elementapi.json`:
  
  ```
  <?php
  namespace Craft;
  
  return [
      'endpoints' => [
          'players.json' => [
              'elementType' => 'User',
              'criteria' => ['group' => 'player'],
              'transformer' => function(EntryModel $entry){
                  return [
                      'username' => $entry->$username,
                      'jsonUrl' => UrlHelper::getUrl("player/{$entry->id}.json")
                  ];
              },
          ]
      ]
  ];
  
  ```
  
  Any help or an example with some custom matrix user fields would be much appreciated! Thanks a bunch!
  
  **Tags:** plugin-elementapi, json
  
  > **Comments:**
  > **username_0**: Hi username_1, thanks for editing there, sorry I left the namespace out, that is actually *is* in my elementapi.php . I am just getting a blank page at the moment when I reference mysite.dev.com/players.json  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-04-18. Score: 2 | Accepted answer
  
  If you set the `elementType` to `User`, then the transformer will have a [`UserModel`](https://craftcms.com/classreference/models/UserModel) object passed in like so:
  
  ```
  <?php
  namespace Craft;
  
  return [
      'endpoints' => [
          'players.json' => [
              'elementType' => 'User',
              'criteria' => ['group' => 'player'],
              'transformer' => function(\Craft\UserModel $user) {
                  return [
                      'username' => $user->username,
                      'jsonUrl' => UrlHelper::getUrl("player/{$user->id}.json")
                  ];
              },
          ]
      ]
  ];
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks for getting back to me username_1: I get this:  Property "Craft\UserModel." is not defined.  
  > **username_1**: Did you get that error before or after my edit?  
  > **username_0**: Hi username_1, no all good, thanks a bunch for the help! It would be really helpful to see a full example with specific user profiles JSON like the entries is layed out :) Thanks again!  
  
  ---
  
  