How to customize the data retrieved by a REST call? I've enabled the REST server (plus services) and can retrieve user profile data at www.example.com/endpoint/user/123

How can I customize the data that's being retrieve? I want to not include the email address and add a couple of other fields.

When I make a login request at www.example.com/endpoint/user/login I would like to have those additional fields included as well.
All you need is to define your Resource, take a look at files in site/all/module/services/resources, you can find some examples, but for simplicity I will take you and example:

endpoint_user moduel:

endpoint_user.info file:

name = endpoint_user
description = endpoint_user
core = 7.x


endpoint_user.module file:

&lt;?php
function endpoint_user_services_resources() {
  $endpoint_user_resource = array(
      'endpoint_user' =&gt; array(
          'retrieve' =&gt; array(
              'callback' =&gt; '_endpoint_user_resource_retrieve',
              'args' =&gt; array(
                  array(
                      'name' =&gt; 'uid',
                      'optional' =&gt; FALSE,
                      'source' =&gt; array('path' =&gt; 0),
                      'type' =&gt; 'int',
                      'description' =&gt; 'The uid of the endpoint_user to get',
                  ),
              ),
              'access callback' =&gt; '_endpoint_user_resource_access',
              'access arguments' =&gt; array('view'),
              'access arguments append' =&gt; TRUE,
          ),
      ),
  );
  return $endpoint_user_resource;
}

function _endpoint_user_resource_access($op = 'view', $args = array()) {
  return TRUE;
}

function _endpoint_user_resource_retrieve($uid) {
  $endpoint_user = user_load($uid);
  $endpoint_user-&gt;custom_field = 'Mohammad Ali Akbari';
  if ($endpoint_user) {
    $uri = entity_uri('user', $endpoint_user);
    $endpoint_user-&gt;path = url($uri['path'], array('absolute' =&gt; TRUE));
    // Unset uri as it has complete entity and this
    // cause never ending recursion in rendering.
    unset($endpoint_user-&gt;uri);
  }
  return $endpoint_user;
}


then create new Service in admin/structure/services and select endpoint_user.

open your browser and go to your service URL, like endpoint/endpoint_user/1

you will see:

&lt;custom_field&gt;Mohammad Ali Akbari&lt;/custom_field&gt;


This result comes from $endpoint_user-&gt;custom_field = 'Mohammad Ali Akbari'; in _endpoint_user_resource_retrieve