# RedGIFs Niche and Keyword Video Fetcher (`webdesigndetail/redgifs-video-fetcher`) Actor

Fetch RedGIFs niche/keyword metadata and optionally Download MP4 Videos by Niche or Keyword.

- **URL**: https://apify.com/webdesigndetail/redgifs-video-fetcher.md
- **Developed by:** [Webdesign Detail](https://apify.com/webdesigndetail) (community)
- **Categories:**
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $40.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Authorized RedGIFs Niche Video Fetcher

An unofficial Python Apify Actor that discovers RedGIFs videos from authorized keyword/niche queries, normalizes their metadata, and can save authorized MP4 files to the run's default key-value store. It uses the Apify SDK for Python 4.x, HTTPX, the integrated Apify Proxy, bounded concurrency, and reproducible Docker builds.

This project is not affiliated with, endorsed by, or operated by RedGIFs.

### Mandatory authorization and adult-content notice

RedGIFs hosts sexually explicit 18+ material. Run this Actor only where every operator and viewer is legally permitted to access that material. Before every run, you must have all three of the following:

1. authorization from RedGIFs for the intended automated access;
2. creator/rightsholder permission to download and store every requested video; and
3. a lawful adult-use basis in every applicable jurisdiction.

Set `contentRightsAcknowledged` to `true` only when those conditions are satisfied. The checkbox records your acknowledgement; it does not create or prove permission. You remain responsible for the source's terms, privacy and publicity rights, copyright, retention, redistribution, and access controls. Do not use this Actor to bypass authentication, paywalls, technical restrictions, takedowns, or geographic/legal restrictions.

### Why HTTPX instead of BeautifulSoup or Playwright?

The niche page is a React/Vite shell, so parsing its initial HTML with BeautifulSoup does not provide the product records. The authorized data path returns structured JSON and direct media URLs, which HTTPX can fetch without rendering a browser. Leaving Playwright out keeps the image smaller, startup faster, and resource usage lower.

The RedGIFs JSON interface used here is private and undocumented. It can change without notice. All endpoint-specific behavior is isolated in the RedGIFs client so it can be updated without changing the storage contract.

### How a run works

The Actor:

1. validates the authorization acknowledgement, download budgets, and standard `proxyConfiguration` input;
2. rejects direct connections and custom proxies unless `useApifyProxy` is `true`;
3. creates one sticky Apify Proxy session and stable user agent for temporary authentication, metadata pages, and media streams;
4. resolves each keyword to a niche slug, follows one source-provided rename safely, and optionally
   falls back to general keyword search;
5. paginates with bounded retries and deduplicates records by RedGIFs video ID;
6. optionally streams each MP4 to temporary disk, validates its type/size, and streams it into the
   platform key-value store under `video-<id>-<quality>.mp4` without loading the whole file into RAM;
7. publishes each dataset record as soon as its item finishes, so an abort, a timeout, or a platform migration never discards completed work; and
8. writes `RUN_SUMMARY` telemetry plus a `RUN_STATE` migration checkpoint to the default key-value store.

Authentication tokens, proxy credentials, and media bytes are never written to logs or dataset items.

### Input

Minimal input:

```json
{
  "keywords": ["authorized-niche"],
  "contentRightsAcknowledged": true,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

Useful controls include:

| Field | Default | Purpose |
| --- | ---: | --- |
| `matchMode` | `nicheThenSearch` | Use only a niche or fall back to keyword search. |
| `sort` | `hot` | Request `hot`, `latest`, or `top` ordering. |
| `maxItemsPerKeyword` | `100` | Bound metadata results independently for each query. |
| `downloadVideos` | `true` | Store MP4 files as key-value records. |
| `videoQuality` | `best` | Prefer HD, require HD, or require SD. |
| `maxVideoBytes` | `262144000` | Stop an individual file above 250 MiB. |
| `maxTotalDownloadBytes` | `1073741824` | Stop storing files after 1 GiB in a run. |
| `downloadConcurrency` | `2` | Bound simultaneous media streams. |
| `requestTimeoutSecs` | `45` | HTTP operation timeout. |
| `maxRequestRetries` | `4` | Bounded transient retry count. |

With `nicheThenSearch`, a missing or renamed niche falls back to keyword search unless RedGIFs
provides a replacement slug, in which case the Actor follows that replacement once. `nicheOnly` is
strict: a missing or renamed niche without a usable replacement fails that keyword with an
actionable message instead of reporting a misleading empty result.

The Actor fails before source access if the rights acknowledgement is not true or the integrated Apify Proxy is not enabled. Your Apify account must also have proxy access for the requested configuration.

### Output and video downloads

Every default-dataset row contains the input query, discovery source, video ID/page URL, description, creator, tags/niches, creation time, duration, dimensions, audio/view/like metadata, thumbnail, selected quality, and download outcome. Successful downloads also include `kvsKey`, `filename`, `mime`, `size`, and `downloadUrl`. A sanitized per-item `error` is present when an item cannot be completed.

MP4 files are in the default key-value store's `videos` collection. The Output tab links to the dataset, that collection, and `RUN_SUMMARY`. A generated `downloadUrl` is subject to the key-value store's access permissions and retention; it is not a permanent hosting guarantee. Download or copy files before their storage expires.

By default, unnamed Apify datasets and key-value stores expire after seven days. Named storages can have different retention. Video downloads incur proxy traffic, platform data transfer, storage, compute, and possibly residential proxy costs. Keep item, byte, and concurrency limits conservative and review the live Apify pricing for your account before a large run.

### Local development

Prerequisites: Python 3.13, [uv](https://docs.astral.sh/uv/), the [Apify CLI](https://docs.apify.com/cli), an authenticated Apify account, and integrated-proxy entitlement.

```bash
uv sync
apify login
apify run
```

For local Apify storage emulation, place the input at `storage/key_value_stores/default/INPUT.json`. Never commit access tokens, proxy credentials, `.env` files, or local storage.

Run the focused checks with:

```bash
uv run ruff check .
uv run ruff format --check .
uv run pytest --cov --cov-report=term-missing
apify validate-schema
```

Tests run entirely against sanitized synthetic fixtures in `tests/fixtures/`. They contain no adult media and make no live RedGIFs request. Coverage is gated at 80 percent.

### Docker

The production image uses the official `apify/actor-python:3.13` base pinned to its multi-architecture manifest digest. Its uv helper image is digest-pinned as well. The build installs only packages locked in `uv.lock`, copies dependency metadata before source files for efficient layer caching, and runs as the base image's non-root `myuser` account.

```bash
docker build -t authorized-redgifs-video-fetcher:local .
```

The container entrypoint is `python -m src`. Use `apify run` for normal local execution because it configures the Actor environment and storage paths correctly.

### Deployment status

The repository contains Actor definitions suitable for CI/CD, but this README does not claim that any GitHub workflow, cloud build, production tag, or Apify Store publication has completed. Store publication remains a separate manual legal, content-policy, security, and billing review.

#### Workflows

`CI and beta deployment` runs on every pull request and every push to `main`.

- `quality`: locked dependency install, Ruff lint and format checks, byte compilation, the test suite behind an 80 percent coverage gate, and `apify validate-schema`.
- `docker`: a `linux/amd64` container build, in parallel with `quality`.
- `deploy-beta`: only on a push to `main`, only after both jobs above pass, and gated on the
  `apify-beta` GitHub environment. It pushes a build tagged `beta`, runs a one-item metadata smoke
  against that exact build number, and verifies `SUCCEEDED`, `RUN_SUMMARY`, and a non-empty dataset.

`beta` is not the tag normal runs resolve to, so a merge never changes what an existing user gets.
The beta smoke does make one authorized metadata request to the target after a successful push.

`Release latest Actor build` is manual dispatch only. It requires the exact successful beta build ID
and the `confirm_release` checkbox, and it is gated on the `apify-production` GitHub environment. It
runs a bounded one-video smoke against that exact build, verifies the MP4 record, and then moves the
`latest` tag to the already-tested build without rebuilding it. Because `latest` is the tag normal
runs resolve to, this is the step that changes production behavior.

#### First-time setup

The Actor must exist on Apify before the workflows can target it, so create it from a workstation
first with `apify push --build-tag beta`. Then create both the `apify-beta` and `apify-production`
GitHub environments and configure these repository or environment secrets:

- `APIFY_TOKEN`: token allowed to build, run, inspect, and retag this Actor;
- `APIFY_ACTOR_ID`: the Actor ID;
- `APIFY_SMOKE_KEYWORD`: an authorized query used for the metadata-only beta smoke; and
- `APIFY_VIDEO_SMOKE_KEYWORD`: an authorized query whose first result may be downloaded during the
  manual production gate.

Add required reviewers to `apify-production` if releases should need approval. The smoke keywords
are secrets so the workflow does not hardcode or expose the authorized target selection.

`.actorignore` keeps caches, virtualenvs, tests, and local storage out of what is uploaded to the platform.

### Operational limitations

- A source API change can break discovery or downloads even when the website UI still works.
- Dataset rows are written in completion order rather than discovery order, because items are published as they finish.
- On Apify, validated files are uploaded to KVS with a streaming authenticated PUT. Local storage
  emulation still uses the SDK value interface, so keep local test file limits conservative.
- This Actor deliberately does not crawl RedGIFs watch pages and does not include a browser fallback.

For Apify lifecycle, storage, proxy, and deployment behavior, see the [Apify SDK for Python documentation](https://docs.apify.com/sdk/python/docs/), [Actor definition documentation](https://docs.apify.com/actors/development/actor-definition), and [storage documentation](https://docs.apify.com/storage).

# Actor input Schema

## `keywords` (type: `array`):

One or more authorized keywords. A keyword is converted to a RedGIFs niche slug first; optional search fallback is controlled by matchMode.

## `matchMode` (type: `string`):

Use only a matching niche, or fall back to the RedGIFs keyword-search endpoint if the niche does not exist.

## `sort` (type: `string`):

Order requested from RedGIFs for every keyword.

## `maxItemsPerKeyword` (type: `integer`):

Hard cap applied independently to each keyword after deduplication.

## `downloadVideos` (type: `boolean`):

When enabled, authorized MP4 files are streamed through the same sticky Apify Proxy session into the default key-value store.

## `videoQuality` (type: `string`):

Best prefers HD and falls back to SD when HD is unavailable.

## `maxVideoBytes` (type: `integer`):

A download is stopped and recorded as skipped if it exceeds this number of bytes.

## `maxTotalDownloadBytes` (type: `integer`):

Run-wide budget for stored video bytes. Metadata collection can continue after this budget is reached.

## `downloadConcurrency` (type: `integer`):

Number of video streams allowed at once. Keep this low to control bandwidth, storage, and proxy usage.

## `requestTimeoutSecs` (type: `integer`):

Timeout in seconds for metadata and media HTTP operations.

## `maxRequestRetries` (type: `integer`):

Bounded retry count for transient timeouts, rate limits, and server failures.

## `proxyConfiguration` (type: `object`):

Required. This Actor accepts only the integrated Apify Proxy (useApifyProxy must be true); custom or direct connections are rejected at runtime.

## `contentRightsAcknowledged` (type: `boolean`):

Required and must be true. You confirm that all users are adults where required, RedGIFs has authorized this access, and you have creator/rightsholder permission to download and store every requested file.

## Actor input object example

```json
{
  "matchMode": "nicheThenSearch",
  "sort": "hot",
  "maxItemsPerKeyword": 100,
  "downloadVideos": true,
  "videoQuality": "best",
  "maxVideoBytes": 262144000,
  "maxTotalDownloadBytes": 1073741824,
  "downloadConcurrency": 2,
  "requestTimeoutSecs": 45,
  "maxRequestRetries": 4,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset items containing normalized metadata and a per-video download outcome.

## `videoFiles` (type: `string`):

The videos collection in the default key-value store.

## `runSummary` (type: `string`):

Machine-readable counts, byte totals, partial state, and sanitized errors.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("webdesigndetail/redgifs-video-fetcher").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("webdesigndetail/redgifs-video-fetcher").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call webdesigndetail/redgifs-video-fetcher --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,webdesigndetail/redgifs-video-fetcher"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/fZcDDEUFzKfuNxdxe/builds/4i9ZykUT0FBn2JfaT/openapi.json
