# Zip Download And Extraction Scraper (`himalyancoder/zip-download-and-extraction-scraper`) Actor

Download a zipped file and extract it right away, no extra moves required.

- **URL**: https://apify.com/himalyancoder/zip-download-and-extraction-scraper.md
- **Developed by:** [Sameer Pun](https://apify.com/himalyancoder) (community)
- **Categories:** Automation, Developer tools
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.20 / 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

## Zip Download And Extraction Scraper

Apify Actor that:

1. Downloads direct ZIP URLs.
2. Validates ZIP signature (`PK\x03\x04`) and size limit.
3. Extracts files safely (Zip Slip protection).
4. Stores ZIP and extracted files to Key-Value Store (unless `listOnly=true`).
5. Pushes file metadata to Dataset.
6. Writes run summary to KV key `OUTPUT`.

### Quick start (Apify Console)

1. Open your Actor.
2. Go to the **Input** tab.
3. Fill **ZIP URLs** with one or more direct `.zip` links.
4. Keep defaults or adjust optional fields.
5. Click **Start**.

After run:

- Dataset items are in **Storage -> Dataset**.
- Stored files are in **Storage -> Key-value store**.
- Summary is in KV key: `OUTPUT`.

### Quick start (local)

```bash
npm install
apify run
```

If you need a local input file:

```json
{
  "urls": [
    "https://github.com/githubtraining/hellogitworld/archive/refs/heads/master.zip"
  ],
  "timeoutSecs": 120,
  "maxRetries": 3,
  "overwrite": false,
  "kvPrefix": "extracted/",
  "maxZipSizeMB": 200,
  "listOnly": false
}
```

Save it as `storage/key_value_stores/default/INPUT.json` before `apify run`.

### Input fields

- `urls` (required): Array of direct ZIP URLs.
- `timeoutSecs` (default `120`): HTTP timeout per request attempt.
- `maxRetries` (default `3`): Retry count with exponential backoff.
- `overwrite` (default `false`): If `false`, duplicate keys from the same run are skipped.
- `kvPrefix` (default `"extracted/"`): Logical prefix used for ZIP/file keys.
- `maxZipSizeMB` (default `200`): Reject ZIPs above this size.
- `listOnly` (default `false`): If `true`, only list entries to Dataset and do not save ZIP/files to KV.

### Output

#### Dataset item (`listOnly=false`)

```json
{
  "sourceUrl": "https://example.com/archive.zip",
  "zipKey": "extracted!zips!archive-a1b2c3d4.zip",
  "entryPath": "folder/file.txt",
  "kvKey": "extracted!files!archive-a1b2c3d4!folder!file.txt",
  "sizeBytes": 1234,
  "sha256": "abc123...",
  "mimeType": "text/plain"
}
```

#### Dataset item (`listOnly=true`)

```json
{
  "entryPath": "folder/file.txt",
  "sizeBytes": 1234
}
```

#### Summary key

- KV key: `OUTPUT`
- Includes totals, per-URL status, and errors.

### Notes

- Apify KV keys cannot contain `/`, so stored keys are converted to safe format with separators like `!`.
- `content-type` header is checked when available, but ZIP validation is based on file signature.
- ZIP size is enforced via `Content-Length` when present, and streaming byte limit when not.

### Troubleshooting

- `Input schema is not valid`: pull latest source and ensure `.actor/input_schema.json` matches this repo.
- `not logged in` warning in local runs is normal unless you need Apify account features.
- If run fails, open KV key `OUTPUT` and check `errors` plus per-URL status.

# Actor input Schema

## `urls` (type: `array`):

Direct HTTP(S) URLs to ZIP files.

## `timeoutSecs` (type: `integer`):

HTTP request timeout for each download attempt.

## `maxRetries` (type: `integer`):

Maximum retries per URL after a failed attempt.

## `overwrite` (type: `boolean`):

If false, duplicate keys in the same run are skipped.

## `kvPrefix` (type: `string`):

Prefix prepended to ZIP and extracted file keys.

## `maxZipSizeMB` (type: `number`):

Reject ZIP files larger than this size.

## `listOnly` (type: `boolean`):

If true, only list ZIP entries and do not write files to key-value store.

## Actor input object example

```json
{
  "urls": [
    "https://example.com/archive.zip"
  ],
  "timeoutSecs": 120,
  "maxRetries": 3,
  "overwrite": false,
  "kvPrefix": "extracted/",
  "maxZipSizeMB": 200,
  "listOnly": false
}
```

# Actor output Schema

## `resultsOverview` (type: `string`):

No description

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

No description

## `summary` (type: `string`):

No description

## `zipFiles` (type: `string`):

No description

## `extractedFiles` (type: `string`):

No description

# 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 = {
    "urls": [
        "https://example.com/archive.zip"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("himalyancoder/zip-download-and-extraction-scraper").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 = { "urls": ["https://example.com/archive.zip"] }

# Run the Actor and wait for it to finish
run = client.actor("himalyancoder/zip-download-and-extraction-scraper").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 '{
  "urls": [
    "https://example.com/archive.zip"
  ]
}' |
apify call himalyancoder/zip-download-and-extraction-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,himalyancoder/zip-download-and-extraction-scraper"
        }
    }
}

```

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/1RVSm2Hz0yb9bbcLy/builds/c2IMdaIGLlbQ2QHYq/openapi.json
