Skip to content

Commit 66252ec

Browse files
committed
Added singular fetch_eventsub_subscription
1 parent e8d74f7 commit 66252ec

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

twitchio/client.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
from .http import HTTPAsyncIterator
6060
from .models.clips import Clip
6161
from .models.entitlements import Entitlement, EntitlementStatus
62-
from .models.eventsub_ import EventsubSubscriptions
62+
from .models.eventsub_ import EventsubSubscription, EventsubSubscriptions
6363
from .models.search import SearchChannel
6464
from .models.streams import Stream, VideoMarkers
6565
from .models.videos import Video
@@ -2502,6 +2502,44 @@ async def fetch_eventsub_subscriptions(
25022502
status=status,
25032503
)
25042504

2505+
async def fetch_eventsub_subscription(
2506+
self,
2507+
subscription_id: str,
2508+
*,
2509+
token_for: str | PartialUser | None = None,
2510+
) -> EventsubSubscription | None:
2511+
"""|coro|
2512+
2513+
Fetches a specific Eventsub Subscription for either webhook or websocket.
2514+
2515+
.. note::
2516+
This endpoint returns disabled WebSocket subscriptions for a minimum of 1 minute as compared to webhooks which returns disabled subscriptions for a minimum of 10 days.
2517+
2518+
Parameters
2519+
-----------
2520+
subscription_id: str
2521+
The specific subscription ID to fetch.
2522+
token_for: str | PartialUser | None
2523+
By default, if this is ignored or set to None then the App Token is used. This is the case when you want to fetch webhook events.
2524+
2525+
Provide a user ID here for when you want to fetch websocket events tied to a user.
2526+
2527+
Returns
2528+
--------
2529+
EventsubSubscription
2530+
"""
2531+
2532+
data = await self._http.get_eventsub_subscription(
2533+
type=None,
2534+
max_results=None,
2535+
token_for=token_for,
2536+
subscription_id=subscription_id,
2537+
user_id=None,
2538+
status=None,
2539+
)
2540+
sub = await data.subscriptions
2541+
return sub[0] if sub else None
2542+
25052543
async def delete_eventsub_subscription(self, id: str, *, token_for: str | PartialUser | None = None) -> None:
25062544
"""|coro|
25072545

0 commit comments

Comments
 (0)