Skip to main content
Since Twikit uses an unofficial API, your account may be at risk if you don’t follow proper safety guidelines. This page covers essential practices to protect your account from suspension or bans.
Twitter actively monitors for automated behavior. Following these guidelines reduces but doesn’t eliminate the risk of account suspension.

Avoid sending too many requests

Sending too many requests in a short period is one of the most common triggers for account suspension. Twitter monitors request patterns and flags suspicious behavior.

Rate limit compliance

Respect Twitter’s rate limits to avoid getting stuck or suspended. Twikit includes built-in rate limit tracking - check the rate limits documentation for details. Do not:
  • Send consecutive requests without delays
  • Max out rate limits repeatedly
  • Use tight loops for continuous scraping
Do:
  • Add delays between requests
  • Implement exponential backoff for retries
  • Monitor rate limit headers
  • Spread requests over longer time periods
import asyncio
from twikit import Client

async def safe_scraping():
    client = Client()
    await client.login(...)
    
    queries = ['python', 'javascript', 'rust', 'golang']
    
    for query in queries:
        tweets = await client.search_tweet(query, 'Latest', count=20)
        for tweet in tweets:
            print(tweet.text)
        
        # Add delay between requests
        await asyncio.sleep(10)  # Wait 10 seconds

asyncio.run(safe_scraping())
A good rule of thumb: never send more requests than a human reasonably could in the same timeframe.

Implement cooldown periods

Allow time for cooldown between batches of requests:
import asyncio
import time

async def batch_with_cooldown(items, batch_size=10, cooldown=60):
    client = Client()
    await client.login(...)
    
    for i in range(0, len(items), batch_size):
        batch = items[i:i + batch_size]
        
        # Process batch
        for item in batch:
            result = await client.search_tweet(item, 'Latest')
            # Process result...
            await asyncio.sleep(5)  # Delay between items
        
        # Cooldown between batches
        if i + batch_size < len(items):
            print(f'Cooldown for {cooldown} seconds...')
            await asyncio.sleep(cooldown)

Reuse login information

Repeated logins are closely monitored by Twitter and can quickly trigger security alerts. The act of calling the login() method repeatedly should be avoided at all costs.

Save and load cookies

Use the save_cookies and load_cookies methods to persist sessions: First time - Login and save:
from twikit import Client

client = Client()
await client.login(
    auth_info_1='username',
    auth_info_2='[email protected]',
    password='password'
)

# Save cookies for future use
client.save_cookies('cookies.json')
Subsequent times - Load saved cookies:
from twikit import Client

client = Client()

# Load saved cookies instead of logging in again
client.load_cookies('cookies.json')

# Now you can make requests without logging in
user = await client.get_user_by_screen_name('example')
See the Cookies Management guide for detailed information on session persistence.
Use the cookies_file parameter for automatic cookie management:
await client.login(
    auth_info_1='username',
    password='password',
    cookies_file='cookies.json'
)
If the cookies file exists, it will be loaded automatically. After a successful login, cookies will be saved to the file.

Do not send too many messages

Twitter monitors direct messages carefully, and excessive messaging is a major red flag for automated behavior.

Message sending guidelines

Avoid:
  • Mass messaging multiple users in quick succession
  • Sending identical or very similar messages
  • Messaging users who haven’t interacted with you
  • Automated message campaigns
Safe practices:
  • Limit daily message volume (e.g., max 50 messages per day)
  • Personalize each message
  • Only message users who have engaged with you
  • Add significant delays between messages (5-10 minutes)
  • Respond to incoming messages naturally
import asyncio

async def send_messages_safely(recipients):
    client = Client()
    client.load_cookies('cookies.json')
    
    MAX_DAILY_MESSAGES = 50
    MIN_DELAY = 300  # 5 minutes between messages
    
    for i, recipient in enumerate(recipients[:MAX_DAILY_MESSAGES]):
        # Send personalized message
        message = f"Hi {recipient}, ..."  # Personalize!
        
        # Send message (implement this based on your needs)
        # await client.send_dm(recipient, message)
        
        print(f'Sent message {i + 1}/{len(recipients)}')
        
        # Wait before next message
        if i < len(recipients) - 1:
            await asyncio.sleep(MIN_DELAY)

Don’t tweet sensitive content

Avoid tweeting content that violates Twitter’s terms of service, as this can lead to immediate suspension.

Content to avoid

The following types of content violate Twitter’s policies and may result in permanent suspension:
  • Sexual content: Explicit or adult content
  • Violence: Graphic violence, threats, or violent content
  • Political extremism: Extreme political views or misinformation
  • Discrimination: Content targeting protected groups
  • Hate speech: Hateful or abusive content
  • Spam: Repetitive, low-quality, or promotional content
  • Impersonation: Pretending to be someone else
  • Copyright violations: Using others’ content without permission

Safe tweeting practices

async def safe_tweeting():
    client = Client()
    client.load_cookies('cookies.json')
    
    # Good: Original, non-controversial content
    await client.create_tweet(
        text="Just learned about async/await in Python! 🐍 #Python #Programming"
    )
    
    await asyncio.sleep(3600)  # Wait 1 hour
    
    # Good: Informative, helpful content
    await client.create_tweet(
        text="Tip: Use list comprehensions for cleaner Python code. Example: [x*2 for x in range(10)]"
    )

What triggers Twitter’s anti-bot detection

Understanding what triggers Twitter’s security systems helps you avoid suspicious behavior.

Common triggers

1

Excessive request rates

Making requests too quickly or hitting rate limits repeatedly signals automated behavior.Solution: Add delays, implement rate limiting, spread requests over time.
2

Repeated logins

Logging in multiple times per day, especially from different IPs.Solution: Save and reuse cookies, avoid calling login() repeatedly.
3

Suspicious patterns

Robotic behavior like identical actions at exact intervals.Solution: Randomize delays, vary your actions, mimic human behavior.
4

Multiple accounts from same IP

Running many accounts from a single IP address.Solution: Use proxies, limit accounts per IP, rotate IPs.
5

Mass actions

Bulk following, unfollowing, liking, or retweeting.Solution: Limit daily actions, add delays, behave naturally.
6

New account activity

Heavy automation on newly created accounts.Solution: Age accounts before automation, build history gradually.

Automation guidelines

Follow these guidelines when automating Twitter actions:

Daily limits

Stay well below these approximate daily limits:
  • Tweets: Max 50 tweets per day (including retweets)
  • Follows: Max 400 follows per day
  • Unfollows: Max 400 unfollows per day
  • Likes: Max 1,000 likes per day
  • Direct messages: Max 50 messages per day
  • API requests: Respect rate limits (see rate limits documentation)
These are conservative estimates. Your actual safe limits may be lower, especially for new accounts.

Randomization

Add randomness to avoid robotic patterns:
import asyncio
import random

async def human_like_behavior():
    client = Client()
    client.load_cookies('cookies.json')
    
    tweets = ['Tweet 1', 'Tweet 2', 'Tweet 3']
    
    for tweet_text in tweets:
        await client.create_tweet(text=tweet_text)
        
        # Random delay between 10-30 minutes
        delay = random.randint(600, 1800)
        print(f'Waiting {delay} seconds...')
        await asyncio.sleep(delay)

Account warm-up

For new accounts, gradually increase activity:
# Week 1: Very light activity
# - 2-3 tweets per day
# - 10-15 follows per day
# - Browse without interacting

# Week 2: Light activity
# - 5-10 tweets per day
# - 20-30 follows per day
# - Some likes and retweets

# Week 3+: Normal activity
# - Up to 20 tweets per day
# - Up to 50 follows per day
# - Regular engagement

Use residential proxies

When using proxies, prefer residential proxies over datacenter proxies:
from twikit import Client

# Residential proxy (better)
client = Client(
    proxy='http://residential-proxy.com:8080'
)

# Datacenter proxy (more likely to be flagged)
client = Client(
    proxy='http://datacenter-proxy.com:8080'
)
See the Proxy Configuration guide for more details.

Monitoring and safety checks

Implement monitoring to detect potential issues early:
import asyncio
import logging
from twikit import Client
from twikit.errors import TooManyRequests, AccountLocked, AccountSuspended

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

async def safe_operation():
    client = Client()
    client.load_cookies('cookies.json')
    
    try:
        result = await client.search_tweet('python', 'Latest')
        logger.info('Request successful')
        return result
        
    except TooManyRequests as e:
        logger.warning('Rate limit hit! Cooling down...')
        # Wait for rate limit reset
        await asyncio.sleep(900)  # 15 minutes
        
    except AccountLocked as e:
        logger.error('Account locked! Manual intervention required.')
        # Send alert, require CAPTCHA solving
        raise
        
    except AccountSuspended as e:
        logger.critical('Account suspended!')
        # Send critical alert
        raise

Summary checklist

Use this checklist to ensure you’re following best practices:
  • Add delays between all requests (minimum 5-10 seconds)
  • Save cookies and avoid repeated logins
  • Stay well below daily action limits
  • Randomize delays and behavior patterns
  • Use residential proxies when possible
  • Avoid sensitive or controversial content
  • Limit direct messages (max 50/day)
  • Warm up new accounts gradually
  • Monitor for rate limits and errors
  • Implement proper error handling
  • Test with a disposable account first
  • Never run multiple accounts from same IP without proxies
Please use Twikit safely in accordance with these instructions!Remember: There is no guaranteed way to prevent suspension when using unofficial APIs. These guidelines significantly reduce risk but cannot eliminate it entirely.

Build docs developers (and LLMs) love