justintv / Twitch-API

A home for details about our API
www.twitch.tv
1.72k stars 379 forks source link

User object from channels/:channel/subscriptions differs from users/:user #368

Closed DorCoMaNdO closed 8 years ago

DorCoMaNdO commented 9 years ago

The user object that is returned from channels/:channel/subscriptions differs from the object returned in users/:user.

Both "bio" and "type" are missing in channels/:channel/subscriptions and a "staff" boolean appears.

Below is a user object from users/:user:

{
    display_name: "DorCoMaNdO",
    _id: 37135375,
    name: "dorcomando",
    type: "user",
    bio: null,
    created_at: "2012-10-23T22:10:11Z",
    updated_at: "2015-04-24T15:18:16Z",
    logo: null,
    _links: {
    self: "https://api.twitch.tv/kraken/users/dorcomando"
    }
}

And this is a user object from channels/:channel/subscriptions

{
    display_name: "DorCoMaNdO",
    _id: 37135375,
    name: "dorcomando",
    staff: false,
    created_at: "2012-10-23T22:10:11Z",
    updated_at: "2015-04-24T15:18:16Z",
    logo: null,
    _links: {
    self: "https://api.twitch.tv/kraken/users/dorcomando"
    }
}

While this is not that big of an issue, it might help tracking down other API mismatches and issues that were mentioned before such as issue #274

urgrue commented 9 years ago

This is a caching bug from Twitch. Sometimes users will respond the way the documentation currently describes (v3 user objects) and others will respond with the old format (v2 user objects).

For reference, see: https://github.com/justintv/Twitch-API/blob/master/v2_resources/users.md#get-user It describes the v2 user object like you are seeing in your response's.

Technically the documentation is correct for the expected v3 user object responses. The current work around is to support both v2 and v3 user objects in your app. Easiest would probably to detect v2 user objects and convert them to a v3 user object during parsing.