Skip to main content

Number of GitHub stars GitHub commit activity Version Tweet Discord BuyMeACoffee

[日本語] [中文]

Twikit

A Simple Twitter API Scraper

You can use functions such as posting or searching for tweets without an API key using this library.

🔵 Discord

Features

No API Key Required

This library uses scraping and does not require an API key.

Free

This library is free to use.

Functionality

By using Twikit, you can access functionalities such as the following:

  • Create tweets

  • Search tweets

  • Retrieve trending topics

  • etc...

Installing

pip install twikit

Quick Example

Define a client and log in to the account.

import asyncio
from twikit import Client

USERNAME = 'example_user'
EMAIL = 'email@example.com'
PASSWORD = 'password0000'

# Initialize client
client = Client('en-US')

async def main():
    await client.login(
        auth_info_1=USERNAME,
        auth_info_2=EMAIL,
        password=PASSWORD,
        cookies_file='cookies.json'
    )

asyncio.run(main())

Create a tweet with media attached.

# Upload media files and obtain media_ids
media_ids = [
    await client.upload_media('media1.jpg'),
    await client.upload_media('media2.jpg')
]

# Create a tweet with the provided text and attached media
await client.create_tweet(
    text='Example Tweet',
    media_ids=media_ids
)

Search the latest tweets based on a keyword

tweets = await client.search_tweet('python', 'Latest')

for tweet in tweets:
    print(
        tweet.user.name,
        tweet.text,
        tweet.created_at
    )

Retrieve user tweets

tweets = await client.get_user_tweets('123456', 'Tweets')

for tweet in tweets:
    print(tweet.text)

Send a dm

await client.send_dm('123456789', 'Hello')

Get trends

await client.get_trends('trending')

More Examples: examples

Contributing

If you encounter any bugs or issues, please report them on issues.

If you find this library useful, consider starring this repository⭐️

Metadata

Release files for twikit-ng 2.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for twikit-ng 2.5.1
File Size Uploaded
twikit_ng-2.5.1.tar.gz 77.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for twikit-ng 2.5.1
File Interpreter ABI Platform
twikit_ng-2.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 166.2 kB

Release files / twikit_ng-2.5.1.tar.gz

Download URL twikit_ng-2.5.1.tar.gz
Size 77.0 kB
Tags Source
SHA-256 checksum
How to use checksums
62569104f56c4ff0d37fdabedea19d70d40794fe79585a7153ac19e9f753a0dd
BLAKE2b-256 checksum
How to use checksums
ccd4fcbd6c617a33e2945259a3a5929b9578412af903644e3529e33cef97efb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / twikit_ng-2.5.1-py3-none-any.whl

Download URL twikit_ng-2.5.1-py3-none-any.whl
Size 89.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6051618f911c59e68cf508df824bfeef7178eef8aa4da1be28f975818394067d
BLAKE2b-256 checksum
How to use checksums
47de98696e59ea1b46d7fc0e3a67583077e27332595b2431c6dec585692f6645
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

2.5.1 This release

2 release files

2.5.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page