File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed
Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ export interface CommunityV2 {
2+ id : string ;
3+ name : string ;
4+ created_at : string ;
5+ }
6+
7+ export interface CommunityErrorV2 {
8+ title : string ;
9+ type : string ;
10+ detail ?: string ;
11+ status ?: number ;
12+ }
13+
14+ export interface CommunityV2Result {
15+ data : CommunityV2 ;
16+ errors ?: CommunityErrorV2 [ ] ;
17+ }
18+
19+ export interface CommunitiesV2Result {
20+ data : CommunityV2 [ ] ;
21+ errors ?: CommunityErrorV2 [ ] ;
22+ meta : { next_token ?: string } ;
23+ }
24+
25+ export interface CommunityByIDV2Params {
26+ id : string ;
27+ }
28+
29+ export interface CommunitySearchV2Params {
30+ query : string ;
31+ max_results ?: number ;
32+ next_token ?: string ;
33+ pagination_token ?: string ;
34+ }
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ export * from './tweet.definition.v2';
44export * from './user.v2.types' ;
55export * from './spaces.v2.types' ;
66export * from './list.v2.types' ;
7+ export * from './community.v2.types' ;
Original file line number Diff line number Diff line change @@ -56,6 +56,10 @@ import {
5656 TweetV2HomeTimelineResult ,
5757 TweetUsageV2Params ,
5858 TweetV2UsageResult ,
59+ CommunityV2Result ,
60+ CommunitiesV2Result ,
61+ CommunityByIDV2Params ,
62+ CommunitySearchV2Params ,
5963} from '../types' ;
6064import {
6165 TweetSearchAllV2Paginator ,
@@ -875,4 +879,20 @@ export default class TwitterApiv2ReadOnly extends TwitterApiSubClient {
875879 public async usage ( options : Partial < TweetUsageV2Params > = { } ) {
876880 return this . get < TweetV2UsageResult > ( 'usage/tweets' , options ) ;
877881 }
882+
883+ /**
884+ * Returns a variety of information about a single Community specified by ID.
885+ * https://docs.x.com/x-api/communities/communities-lookup-by-community-id
886+ */
887+ public community ( communityId : string , options : Partial < CommunityByIDV2Params > = { } ) {
888+ return this . get < CommunityV2Result > ( 'communities/:id' , options , { params : { id : communityId } } ) ;
889+ }
890+
891+ /**
892+ * Search for Communities based on keywords.
893+ * https://docs.x.com/x-api/communities/search-communities
894+ */
895+ public searchCommunities ( query : string , options : Partial < CommunitySearchV2Params > = { } ) {
896+ return this . get < CommunitiesV2Result > ( 'communities/search' , { query, ...options } ) ;
897+ }
878898}
You can’t perform that action at this time.
0 commit comments