> ## Documentation Index
> Fetch the complete documentation index at: https://docs.twitterapi.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Scheduling your jobs

> Why requests sent at the top of the hour are more likely to be slow or fail, and how to schedule jobs so they run smoothly.

Scheduled jobs (cron jobs, hourly scripts, polling loops) are common, and schedulers usually start jobs at a round time by default, so a large share of requests arrives at the same moment:

* around the **top of the hour** (`:00`), and
* around the **half hour** (`:30`).

During those moments request volume peaks. Requests sent then compete for the same capacity, so they are more likely to be slow or to return `503`. A few minutes later, the same request usually goes through normally.

## What you may notice

* Searches that normally return in 1-2 seconds take much longer, but only around `:00` or `:30`.
* Some requests return `503` with a message suggesting a retry. **Failed (`503`) requests are never charged.**
* If your job sends many requests at once, some of them return `429 Too Many Requests` because the burst goes over your [rate limit](https://docs.twitterapi.io/rate-limits.md).

If this matches what you see, adjusting your schedule usually fixes it, at no extra cost.

## How to schedule jobs

**1. Don't start jobs at `:00` or `:30`.** Pick a random minute and keep it fixed, for example `:17` or `:43`. Avoid the few minutes around the top of the hour and the half hour.

```bash theme={null}
# cron: run hourly at minute 17 instead of minute 0
17 * * * * /path/to/your_job.sh
```

**2. Add a random delay before each run.** For jobs that run every minute, wait a random 5-55 seconds before starting, instead of starting at second 0.

```python theme={null}
import random, time

time.sleep(random.uniform(5, 55))   # random start within the minute, away from second 0
run_job()
```

**3. Spread bursts out.** If one run sends many requests, send them evenly across the minute instead of all at once. A steady 10 requests per second is safer than 200 requests in the first few seconds.

```python theme={null}
import time

def send_spread(items, per_second=10):
    for item in items:
        call_api(item)
        time.sleep(1 / per_second)
```

**4. Retry `503` with a short backoff.** Wait about 5 seconds, then 10 seconds; retry the same request no more than 2 times. Don't retry immediately in a tight loop; that adds to the busy moment. See [Errors](https://docs.twitterapi.io/errors.md) for a full retry example.

```python theme={null}
import random, time, requests

def get_with_retry(url, headers, params):
    for wait in (0, 5, 10):
        if wait:
            time.sleep(wait + random.uniform(0, 2))
        r = requests.get(url, headers=headers, params=params, timeout=30)
        if r.status_code != 503:
            return r
    return r
```

## Still seeing failures?

If your jobs already run away from `:00` and `:30` and you still see frequent `503` responses, email [hello@twitterapi.io](mailto:hello@twitterapi.io) with your account email, the endpoint, and a few example times (with time zone). We'll look into it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.