Skip to content

Latest commit

 

History

History
520 lines (350 loc) · 79.1 KB

File metadata and controls

520 lines (350 loc) · 79.1 KB

Tweets.Actions

Overview

Available Operations

like

Likes a specific tweet on behalf of the user associated with the provided cookie,$0.001 per call.

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.tweets.actions.like(tweet_id="<id>", cookie="ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7", proxy="http://username:password@ip:port")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_id str ✔️ The numeric ID of the tweet to like.
cookie str ✔️ Twitter authentication cookie or Twitter auth_token, how-to-get-twitter-cookie ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7
proxy OptionalNullable[str] The proxy to use.Please use high-quality residential proxies and avoid free proxies.Required.Example: http://username:password@ip:port . You can get proxy from: https://app.proxy-cheap.com/r/qiMxub http://username:password@ip:port
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.TweetActionResponse

Errors

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

unlike

Unlike a tweet, $0.001 per call.

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.tweets.actions.unlike(tweet_id="<id>", cookie="ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_id str ✔️ The ID of the tweet to delete.
cookie str ✔️ The user's Twitter authentication cookie or Twitter auth_token, how-to-get-twitter-cookie ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.TweetActionResponse

Errors

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

retweet

Retweets a specific tweet on behalf of the user associated with the provided cookie,$0.001 per call.

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.tweets.actions.retweet(tweet_id="<id>", cookie="ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7", proxy="http://username:password@ip:port")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_id str ✔️ The ID of the tweet to retweet.
cookie str ✔️ Twitter authentication cookie or Twitter auth_token, how-to-get-twitter-cookie ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7
proxy OptionalNullable[str] The proxy to use.Please use high-quality residential proxies and avoid free proxies.Required.Example: http://username:password@ip:port . You can get proxy from: https://app.proxy-cheap.com/r/qiMxub http://username:password@ip:port
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.TweetActionResponse

Errors

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

unretweet

Delete a retweet, $0.001 per call.

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.tweets.actions.unretweet(tweet_id="<id>", cookie="ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_id str ✔️ The ID of the tweet to delete.
cookie str ✔️ The user's Twitter authentication cookie or Twitter auth_token, how-to-get-twitter-cookie ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.TweetActionResponse

Errors

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

create_thread

Create a tweet thread from an ordered list of texts, $0.001 per call.

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.tweets.actions.create_thread(items=[
        "1/ hello",
        "2/ world",
    ], cookie="ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7", proxy="http://username:password@ip:port")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
items List[str] ✔️ JSON array of tweet texts, e.g. ["1/ hello","2/ world"]. [
"1/ hello",
"2/ world"
]
cookie str ✔️ Twitter authentication cookie or Twitter auth_token, how-to-get-twitter-cookie ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7
proxy OptionalNullable[str] Optional HTTP proxy. Example: http://username:password@ip:port http://username:password@ip:port
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.CreateThreadResponse

Errors

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

create

Posts a new tweet. To create a reply, provide the reply_tweet_id. This endpoint does not handle quote tweets,$0.001 per call.

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.tweets.actions.create(tweet_content="Hello, Twitter! 🐦", cookie="ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7", media_url="https://example.com/image.jpg", media_urls=[
        "https://example.com/image1.jpg",
        "https://example.com/image2.jpg",
    ], delegated_account_username="elonmusk", schedule="2024-01-01T12:00:00Z", reply_tweet_id="1234567890123456789", community_name="Python Developers or 1234567890123456789", proxy="http://username:password@ip:port")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_content str ✔️ Content of the tweet to post Hello, Twitter! 🐦
cookie str ✔️ Twitter authentication cookie or Twitter auth_token, how-to-get-twitter-cookie ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7
media_url OptionalNullable[str] Single media URL: image, GIF, or video. Prefer media_urls for multiple images. https://example.com/image.jpg
media_urls List[str] Media URLs to attach (max 4 images, or 1 GIF, or 1 video). Cannot mix GIF/video with other media. [
"https://example.com/image1.jpg",
"https://example.com/image2.jpg"
]
delegated_account_username OptionalNullable[str] delegated account username elonmusk
schedule OptionalNullable[str] Schedule time for the tweet in ISO format 2024-01-01T12:00:00Z
reply_tweet_id OptionalNullable[str] ID of tweet to reply to 1234567890123456789
community_name OptionalNullable[str] Name of Twitter community to post in or community id Python Developers or 1234567890123456789
proxy OptionalNullable[str] The proxy to use.Please use high-quality residential proxies and avoid free proxies.Required.Example: http://username:password@ip:port . You can get proxy from: https://app.proxy-cheap.com/r/qiMxub http://username:password@ip:port
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PostTweetResponse

Errors

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

quote

Posts a new tweet that quotes an existing tweet. Requires the URL of the tweet to be quoted and the new content,$0.001 per call.

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.tweets.actions.quote(tweet_content="Hello, Twitter! 🐦", cookie="ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7", media_url="https://example.com/image.jpg", media_urls=[
        "https://example.com/image1.jpg",
        "https://example.com/image2.jpg",
    ], delegated_account_username="elonmusk", community_name="Python Developers or 1234567890123456789", quote_tweet_url="https://twitter.com/user/status/1234567890123456789", proxy="http://username:password@ip:port")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_content str ✔️ Content of the tweet to post Hello, Twitter! 🐦
cookie str ✔️ Twitter authentication cookie or Twitter auth_token, how-to-get-twitter-cookie ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7
media_url OptionalNullable[str] Single media URL: image, GIF, or video. Prefer media_urls for multiple images. https://example.com/image.jpg
media_urls List[str] Media URLs to attach (max 4 images, or 1 GIF, or 1 video). Cannot mix GIF/video with other media. [
"https://example.com/image1.jpg",
"https://example.com/image2.jpg"
]
delegated_account_username OptionalNullable[str] delegated account username elonmusk
community_name OptionalNullable[str] Name of Twitter community to post in or community id Python Developers or 1234567890123456789
quote_tweet_url OptionalNullable[str] URL of tweet to quote https://twitter.com/user/status/1234567890123456789
proxy OptionalNullable[str] The proxy to use.Please use high-quality residential proxies and avoid free proxies.Required.Example: http://username:password@ip:port . You can get proxy from: https://app.proxy-cheap.com/r/qiMxub http://username:password@ip:port
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PostTweetResponse

Errors

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

create_without_cookie

Post a tweet using a random cookie from the pool, cookie management $0.001 per call.

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.tweets.actions.create_without_cookie(tweet_content="Hello, Twitter! 🐦", media_url="https://example.com/image.jpg", media_urls=[
        "https://example.com/image1.jpg",
        "https://example.com/image2.jpg",
    ], schedule="2024-01-01T12:00:00Z", reply_tweet_id="1234567890123456789", community_name="Python Developers or 1234567890123456789", quote_tweet_url="https://twitter.com/user/status/1234567890123456789")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_content str ✔️ Content of the tweet to post Hello, Twitter! 🐦
media_url OptionalNullable[str] Single media URL: image, GIF, or video. Prefer media_urls for multiple images. https://example.com/image.jpg
media_urls List[str] Media URLs to attach (max 4 images, or 1 GIF, or 1 video). Cannot mix GIF/video with other media. [
"https://example.com/image1.jpg",
"https://example.com/image2.jpg"
]
schedule OptionalNullable[str] Schedule time for the tweet in ISO format 2024-01-01T12:00:00Z
reply_tweet_id OptionalNullable[str] ID of tweet to reply to 1234567890123456789
community_name OptionalNullable[str] Name of Twitter community to post in or community id Python Developers or 1234567890123456789
quote_tweet_url OptionalNullable[str] URL of tweet to quote https://twitter.com/user/status/1234567890123456789
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PostTweetResponse

Errors

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

bookmark

Adds a specific tweet to the bookmarks of the user associated with the provided cookie,$0.001 per call.

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.tweets.actions.bookmark(tweet_id="<id>", cookie="ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7", proxy="http://username:password@ip:port")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_id str ✔️ The ID of the tweet to bookmark.
cookie str ✔️ Twitter authentication cookie or Twitter auth_token, how-to-get-twitter-cookie ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7
proxy OptionalNullable[str] The proxy to use.Please use high-quality residential proxies and avoid free proxies.Required.Example: http://username:password@ip:port . You can get proxy from: https://app.proxy-cheap.com/r/qiMxub http://username:password@ip:port
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.TweetActionResponse

Errors

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

unbookmark

Delete a bookmark, $0.001 per call.

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.tweets.actions.unbookmark(tweet_id="<id>", cookie="ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
tweet_id str ✔️ The ID of the tweet to delete.
cookie str ✔️ The user's Twitter authentication cookie or Twitter auth_token, how-to-get-twitter-cookie ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.TweetActionResponse

Errors

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

delete_batch

Deletes one or more tweets from a specified user account. This endpoint supports two modes:

  1. Single Tweet Deletion: Provide a target_id to delete a specific tweet.
  2. Bulk Deletion: Omit the target_id to delete all tweets from the user's account.

Warning: The bulk deletion mode is irreversible and will permanently remove all tweets from the account. Use with extreme caution.

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.tweets.actions.delete_batch(cookie="ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7", username="myusername", target_id="1234567890123456789")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
cookie str ✔️ Twitter authentication cookie or Twitter auth_token, how-to-get-twitter-cookie ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7
username str ✔️ Twitter username whose tweets to delete myusername
target_id OptionalNullable[str] Specific tweet ID to delete (if not provided, deletes all user tweets) 1234567890123456789
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.DeleteTweetResponse

Errors

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