Mass deletion of eventsub subscriptions/connections

Small quality of life script for anyone using Python to mess around with Twitch API and need to delete all their connections after testing connection scripts with a live channel.

This script is for a specific case where you use Twitch CLI and have configured your client ID and secret beforehand.

use it to your heart’s content.

import json
import subprocess
import asyncio


async def deleteConnections():
    x = await asyncio.create_subprocess_shell(
        "twitch api get /eventsub/subscriptions",
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
    )
    stdout, stderr = await x.communicate()
    stdout = stdout.decode("utf-8")
    x = json.loads(stdout)
    for i in x["data"]:
        print(i["id"])
        await asyncio.create_subprocess_shell(
            f"twitch api delete /eventsub/subscriptions -q id={i['id']}",
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )


async def main():
    await deleteConnections()


if __name__ == "__main__":
    asyncio.run(main())

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