Get Channel Community breaks if the channel doesn't have a community

https://api.twitch.tv/kraken/channels/<channel ID>/community
When going to some (maybe all) users that aren’t a part of a community, nothing is returned, not even an error or HTTP code.

I know my channel id causes this bug for sure:
https://api.twitch.tv/kraken/channels/71619374/community?client_id=3s27p59atb0bwu6vkh2rnrxeqx3dn3h&api_version=5

But when I join a community, that exact link properly returns my community information.

It doesn’t show anything in the browser for me, but that seems like correct behaviour. It returns a 204 response code, which means no content. This doesn’t seem to be documented for this endpoint though.

@tduva is correct. It just returns a 204 No Content. It isn’t a bug, but it is confusing. I’ll chat with the team about returning something like a 404 (since there is no community found).

It might be confusing, but it does seem correct. It’s not an error if a channel has no community set, so it should be a 2xx code. I would understand a 404 as “that channel doesn’t exist”, although currently that seems to be 400. I think it’s more important to actually document all the possible response codes for all endpoints.

If it does get changed it should be communicated/documented as well, otherwise it could lead to problems when clients suddenly receive an error instead of an “All good, just nothing here” response (or just a changed/unexpected response in general).

A problem is handling 204 responses via JSONP. There’s no real way to handle HTTP codes unless it’s returning data too.

That’s a good point. It should definitely be made to return data for jsonp, but XHR should be preferred for new development.

1 Like

Does v5 api have CORS? Otherwise there’s still the problem of browser security (correctly) blocking cross-site XHR.

Kraken has had CORS support for a good while now.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.