Types Of User Objects


There are two different objects that represent a user in the API, the full user object and the smaller shallow_user object. Which is returned depends on the method being called, methods that are focused on users return the full object while others return the shallow one.

By way of example, /users returns full user objects but /questions returns shallow_users in question.owner.

When constructing filters, you need to be aware of this distinction as excluding properties on user does not exclude then on shallow_users , and vice versus.

While it is a rare occurrence, users can be deleted on Stack Exchange sites. Users can also never have existed, such as when a question is migrated between sites as there is no guarantee the asking user exists on both. When a user does not exist there is no way to get a full user object for them. However, in some cases a shallow_user record with user_type: "does_not_exist" can be returned; such as when a question with a deleted owner is fetched. Be aware that no fields other than user_type on a shallow_user are guaranteed to be set when the user does not exist, applications should deal gracefully with this case.