Metadata-Version: 2.5
Name: cliqtomedia-apify
Version: 0.1.0
Summary: Run any public Apify Actor from the command line or Python and get its dataset items. No dependencies.
Project-URL: Homepage, https://cliqtomedia.com/actors/?utm_source=pypi&utm_medium=template&utm_campaign=promo-2026-11
Project-URL: Documentation, https://docs.apify.com/api/v2
Author: Cliqto Media
Maintainer: Cliqto Media
License-Expression: MIT
License-File: LICENSE
Keywords: api-client,apify,automation,data-extraction,lead-generation,scraper,web-scraping
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# cliqtomedia-apify: run any Apify Actor from Python or the command line

![Cliqto Media](https://cliqtomedia.com/assets/img/logo-512.png)

Run any public Apify Actor and get its dataset items as JSON, JSONL or CSV. One command, no dependencies.

[![PyPI version](https://img.shields.io/pypi/v/cliqtomedia-apify.svg)](https://pypi.org/project/cliqtomedia-apify/)
[![Python versions](https://img.shields.io/pypi/pyversions/cliqtomedia-apify.svg)](https://pypi.org/project/cliqtomedia-apify/)
[![License: MIT](https://img.shields.io/pypi/l/cliqtomedia-apify.svg)](https://pypi.org/project/cliqtomedia-apify/)

## What you get

- A `cliqtomedia-apify run` command that starts an Actor, waits for it to finish and prints the results.
- A `run_actor()` function that returns the dataset items as a Python list.
- Output as `json`, `jsonl` or `csv`.
- Clear errors and exit codes for a missing token, a wrong Actor name and a failed run.
- Standard library only. It needs Python 3.9 or newer and installs no other packages.

The package works with any public Actor on Apify, not only ours. It reads dataset items with `clean=true`, so hidden helper fields are dropped.

## Install

```bash
pip install cliqtomedia-apify
```

## Get your Apify token

The package uses your own Apify account. It never ships a token.

1. Create a free account at [apify.com](https://apify.com).
2. In Apify Console, open Settings, then API & Integrations. Copy the Personal API token ([how to find it](https://docs.apify.com/platform/integrations/api#api-token)).
3. Set it as the `APIFY_TOKEN` environment variable:

```bash
export APIFY_TOKEN=your_token_here
```

You can also pass the token with `--token` on the command line or `token=` in Python.

## Quick start: command line

```bash
cliqtomedia-apify run cliqtomedia/youtube-transcript-scraper \
  --input '{"videoUrls": ["jNQXAC9IVRw"]}' --format json
```

Read the input from a file:

```bash
cliqtomedia-apify run cliqtomedia/youtube-transcript-scraper --input-file input.json --format jsonl > items.jsonl
```

| Option | Meaning |
|---|---|
| `--input` | Actor input as a JSON string |
| `--input-file` | Path to a JSON file with the Actor input |
| `--limit N` | Fetch at most N items |
| `--format` | `json` (default), `jsonl` or `csv` |
| `--timeout SECONDS` | How long to wait for the run (default 300) |
| `--token` | Apify token (default: `APIFY_TOKEN`) |
| `--version` | Print the package version |

Exit codes: `0` success, `1` Apify or run error, `2` usage error such as a missing token or bad input JSON.

`python -m cliqtomedia_apify run ...` works the same way.

## Quick start: Python

```python
from cliqtomedia_apify import run_actor

items = run_actor(
    "cliqtomedia/youtube-transcript-scraper",
    {"videoUrls": ["jNQXAC9IVRw"]},
    limit=10,
)
print(items[0]["status"], items[0]["text"][:80])
```

`run_actor(actor, run_input=None, *, token=None, limit=None, timeout=300)` returns a list of dicts. It raises `ApifyError` (or the subclasses `ApifyHTTPError` and `MissingTokenError`) on failure.

## Example

Input for the [YouTube Transcript Scraper](https://cliqtomedia.com/actors/youtube-transcript-scraper/?utm_source=pypi&utm_medium=template&utm_campaign=promo-2026-11) Actor:

```json
{
  "videoUrls": ["jNQXAC9IVRw"]
}
```

Output, shortened to the main fields of the first dataset item:

```json
[
  {
    "status": "SUCCEEDED",
    "complete": true,
    "videoId": "jNQXAC9IVRw",
    "canonicalUrl": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
    "track": {
      "sourceLanguageCode": "en",
      "sourceIsGenerated": false,
      "isTranslated": false
    },
    "segments": [
      {
        "sequence": 0,
        "text": "All right, so here we are, in front of the elephants",
        "startSeconds": 1.2,
        "durationSeconds": 2.16
      }
    ],
    "segmentCount": 6
  }
]
```

Each Actor has its own input and output fields. Read them on the Actor page.

## Pricing

This package is free (MIT license). Apify charges only for your own runs, under your account. The exact price of each Actor is on its Apify page. Check it before you start.

## Limits

- It runs one Actor per call and returns when the run ends. It does not stream partial results.
- It waits up to `--timeout` seconds (default 300). If the run is not done by then, the package aborts it and reports an error.
- It reads at most the first `--limit` dataset items. Without `--limit`, it reads the whole dataset.
- It does not manage tasks, schedules, webhooks or key-value stores. Use the full [Apify API](https://docs.apify.com/api/v2) for those.
- The run must succeed. If the Actor fails, you get an error, not partial items.

## FAQ

**Does it work with Actors from other authors?**
Yes. Use any Actor name in the form `username/actor-name`.

**Where does the token go?**
Into the `APIFY_TOKEN` environment variable, or `--token` / `token=`. The package sends it only to `api.apify.com`.

**Why do I get HTTP 401?**
Apify rejected the token. Copy it again from Console, Settings, API & Integrations.

**Why do I get HTTP 404?**
The Actor name is wrong or the Actor is private. Check the spelling, for example `cliqtomedia/youtube-transcript-scraper`.

**Can I use it in a script or a cron job?**
Yes. It prints data to stdout, errors to stderr, and sets the exit code.

## Links

- [Cliqto Media Actor catalog](https://cliqtomedia.com/actors/?utm_source=pypi&utm_medium=template&utm_campaign=promo-2026-11)
- [Apify API reference](https://docs.apify.com/api/v2)
- [Apify API token docs](https://docs.apify.com/platform/integrations/api#api-token)
