Skip to main content

Twitter API wrapper for python with **no API key required**. Fork of twikit, continuing active maintenance.

Project description

[!NOTE] https://github.com/d60/twitter_login (under development)

[!IMPORTANT] This repository is a maintained fork of the upstream project. Upstream: https://github.com/d60/twikit Maintained fork: https://github.com/inorilzy/twikit If you are looking for actively maintained fixes (for example X bundle format changes), use this fork.

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

[!NOTE] Released twikit_grok an extension for using Grok AI with Twikit.
For more details, visit: https://github.com/d60/twikit_grok.

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⭐️

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twikit_ng-2.5.0.tar.gz (43.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twikit_ng-2.5.0-py3-none-any.whl (54.1 kB view details)

Uploaded Python 3

File details

Details for the file twikit_ng-2.5.0.tar.gz.

File metadata

  • Download URL: twikit_ng-2.5.0.tar.gz
  • Upload date:
  • Size: 43.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for twikit_ng-2.5.0.tar.gz
Algorithm Hash digest
SHA256 b66832584a14862427b1b7eaf24ecb0a9752fa5bcac2cbdc7618b4bd76f0112f
MD5 eceedf6067278f741d3274e91182cb6b
BLAKE2b-256 f1e90e636f74f77dc4a979f735d3bdd8618a6454bc3219e66c4b4386c5300791

See more details on using hashes here.

File details

Details for the file twikit_ng-2.5.0-py3-none-any.whl.

File metadata

  • Download URL: twikit_ng-2.5.0-py3-none-any.whl
  • Upload date:
  • Size: 54.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for twikit_ng-2.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c900932405d923c49753328c13301710cf431ab785685dadd03caed1ec16c9f
MD5 4e3fffd16f00cf9bf7f3222aa5d21a82
BLAKE2b-256 cf65e2ae865f77087524c2bd96d775a5700d6512b3508c7897dd73b05645bff9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page