Advanced Analytics

Hello, colleagues!

We are currently facing an issue with accessing the necessary analytics data for our Twitch streams and would appreciate any assistance you can provide.

Our company conducts live streams across six channels on various platforms, including Twitch. To streamline our reporting processes and reduce human error, we aim to utilize the Twitch API to automatically retrieve information about our streams. However, the public API methods such as streams, games, users, and channels do not provide the required data for our archived streams, which is available on the dashboard at Creator Dashboard.

We need to export the following analytics data via the API:

  1. Stream views;
  2. Unique viewers;
  3. Watch time;
  4. Maximum number of viewers;
  5. Average number of viewers;
  6. Engaged viewers;
  7. Chat messages.

We can obtain information for points 1, 4, 5, and 7 from the Streams endpoint, but we are unable to retrieve data for the other analytics.

We have reached out to Twitch support regarding access to the Analytics endpoint, but their response was not helpful. We received a 404 error when attempting to access this endpoint. We are seeking guidance or experiences in obtaining the required data from alternative endpoints.

Any help or insights would be greatly appreciated.

Additionally, please find below the code that results in a 404 error when accessing the Analytics endpoint:

import requests

# Twitch API credentials (указываем напрямую в коде)
CLIENT_ID = 'ваш_client_id'  # Замените на ваш Client ID
CLIENT_SECRET = 'ваш_client_secret'  # Замените на ваш Client Secret

# Twitch API endpoints
AUTH_URL = 'https://id.twitch.tv/oauth2/token'
API_URL = 'https://api.twitch.tv/helix'

# Function to get access token
def get_access_token():
    response = requests.post(AUTH_URL, data={
        'client_id': CLIENT_ID,
        'client_secret': CLIENT_SECRET,
        'grant_type': 'client_credentials'
    })
    if response.status_code != 200:
        print(f"Ошибка при получении токена: {response.status_code}")
        print(response.json())
        return None
    return response.json().get('access_token')

# Function to get analytics for a video
def get_video_analytics(video_id):
    headers = {
        'Client-ID': CLIENT_ID,
        'Authorization': f'Bearer {ACCESS_TOKEN}'
    }
    params = {
        'type': 'overview_v2',
        'video_id': video_id
    }

    # Выводим информацию о запросе
    print("\nОтправляемый запрос:")
    print(f"URL: {API_URL}/analytics")
    print(f"Headers: {headers}")
    print(f"Params: {params}")

    # Отправляем запрос
    response = requests.get(f'{API_URL}/analytics', headers=headers, params=params)
    if response.status_code != 200:
        print(f"Ошибка при запросе к /analytics: {response.status_code}")
        print(response.json())
        return None
    return response.json()

# Main function
def main():
    global ACCESS_TOKEN
    ACCESS_TOKEN = get_access_token()
    if not ACCESS_TOKEN:
        print("Не удалось получить токен доступа.")
        return

    # Ввод ID видео
    video_id = input("Введите ID видео: ")

    # Получаем аналитику для видео
    analytics_data = get_video_analytics(video_id)
    if analytics_data:
        print("\nАналитика для видео:")
        print(analytics_data)
    else:
        print("Не удалось получить аналитику для видео.")

if __name__ == '__main__':
    main()

Thank you in advance for your assistance.

There is no API for this.

Please create a uservoice for this feature

it 404’s as there is no Analytics endpoint to call for user data

Analytics endpoints exist for drops/games/extensions not for streams/users

Thank you for your response!

I have created an idea on the UserVoice platform:
https://twitch.uservoice.com/forums/310213-developers/suggestions/49333124-advanced-analytics-from-dashboard-on-api

I might have misunderstood how the Analytics endpoint works. From the API documentation, I understood that this endpoint returns a report file that may include the data I am requesting:

  • Stream views;
  • Unique viewers;
  • Watch time;
  • Maximum number of viewers;
  • Average number of viewers;
  • Engaged viewers;
  • Chat messages.

If this is not the case, please explicitly clarify whether it is possible to obtain the listed data through the current endpoints (including potentially non-public ones), considering that this data is available via the Dashboard.

Thank you in advance for your assistance!

That would violate the developer agreement, and there are none that I’m aware of.

There isn’t one?! So how given it doesn’t exist not sure what you are misunderstanding from where?

What API documentation?

There is no API documentation for “streamer based analytics” as this endpoint doesn’t exist.

streamer/dashboard data doesn’t have an API, it’s just collated in the dasboard and may have a CSV download, so you could fetch that csv and process it (manually).

But then “Engaged viewers” isn’t a metric I’m aware of anyway, becuase what is an “engaged viewer”, it’s very subjective what one is.

This suggests you have misread the documentation or not reading official documentation or reading outdata documentation not that twitch has had an endpoint like this that I recal in the decade of so I’ve been poking around the API.

The only API endpoints for analytics pertains to Extension Analytics and Game Developer Analytics, for extensions you own and games your organisation owns.

There are no streamer analytic endpoints.

You just copy/pasted your OP instead of writing up what/what you need it so this is unlikely to gain any traction, in my opinion.

and/or looked at other uservoices/suggestions that exist to upvote rather than spawning a new idea, such as

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