【问题标题】:How to use the API to get the top 20 streams如何使用 API 获取前 20 个流
【发布时间】:2020-12-09 08:56:42
【问题描述】:

我正在尝试编写一个 Python 脚本来使用 API 获取前 20 个流。但是,我在网上找不到指南。我要离开 python-twitch-client docs 但到目前为止我找不到有用的东西。我承认,这是我第一次使用这个 API。

确切地说,这就是我想要完成的:https://dev.twitch.tv/docs/api/reference#get-streams 我知道默认返回是 20 个流。

目前,这是我拥有的所有代码:

from twitch import TwitchClient
client = TwitchClient(client_id='<my client id>')

【问题讨论】:

    标签: python json api twitch


    【解决方案1】:

    欢迎使用 API - 这绝对是一场盛宴。

    在这种情况下,假设您已成功创建应用程序和retrieved your client id as outlined in the instructions,要获取最新的流,您将使用get_live_streams

    from twitch import TwitchClient
    
    client = TwitchClient(client_id='<client-id>')
    streams = client.streams.get_live_streams()
    
    print(streams)
    

    API 提供了其他函数,您可以使用它来检索其他数据,例如 get_featuredget_stream_by_user 等。你可以查看所有functions in the documentation

    【讨论】:

    • 这适用于 colab 但不适用于 IDE。我正在使用 PyCharm。
    • 另外,如何通过这个找到用户名?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-14
    • 2023-03-23
    • 2016-11-14
    • 2018-12-03
    • 1970-01-01
    相关资源
    最近更新 更多