Skip to content

Latest commit

 

History

History
309 lines (201 loc) · 19.3 KB

File metadata and controls

309 lines (201 loc) · 19.3 KB

Communities

Overview

Available Operations

members

Get community members

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.communities.members(community_id="<id>", target_count=298640)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
community_id str ✔️ N/A
target_count int ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.SearchUserResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*

members_page

Retrieve a paginated list of community members using cursor-based pagination. Each page returns up to 20 members. Pass next_cursor from the previous response to continue. Pricing: $0.10 per 1,000 members.

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.communities.members_page(community_id="<id>", next_cursor="1234567890")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
community_id str ✔️ The ID of the community to get members from.
next_cursor OptionalNullable[str] Cursor returned by the previous page. Leave empty to fetch the first page. 1234567890
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetCommunityMembersCursorResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*

tweets

Get community tweets

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.communities.tweets(community_id="<id>", tweet_type="Media", target_count=682850)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
community_id str ✔️ N/A
tweet_type models.CommunitiesTweetsTweetType ✔️ N/A
target_count int ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.CommunityTweetsResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*

tweets_page

Retrieve a paginated list of community tweets using cursor-based pagination. Each page returns up to 20 tweets. Pass next_cursor from the previous response to continue. Pricing: $0.10 per 1,000 tweets.

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.communities.tweets_page(community_id="<id>", tweet_type="Top", next_cursor="1234567890")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
community_id str ✔️ The ID of the community to get tweets from.
tweet_type models.TweetType ✔️ The type of tweets to get.
next_cursor OptionalNullable[str] Cursor returned by the previous page. Leave empty to fetch the first page. 1234567890
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetCommunityTweetsCursorResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*

search

Search community

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.communities.search(query="<value>", target_count=761546)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
query str ✔️ The query to search for.
target_count int ✔️ The number of communities to search.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.SearchCommunityResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*

get

Get community

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.communities.get(community_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
community_id str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetCommunityResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*

search_tweets

Search community tweets

Example Usage

import os
from x_api_scraper import XapiScraper


with XapiScraper(
    bearer_auth=os.getenv("X_API_SCRAPER_BEARER_AUTH", ""),
) as xapi_scraper:

    res = xapi_scraper.communities.search_tweets(community_id="<id>", target_count=687977, query="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
community_id str ✔️ The ID of the community.
target_count int ✔️ The number of tweets to search.
query str ✔️ The query to search for.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.CommunityTweetsResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.XapiScraperDefaultError 4XX, 5XX */*