# Threads Media and Metadata Retriever (`gratenes/threads-media-and-metadata-retriever`) Actor

An api for gathering media and metadata from any Threads url, supports threads.com and threads.net.

- **URL**: https://apify.com/gratenes/threads-media-and-metadata-retriever.md
- **Developed by:** [C](https://apify.com/gratenes) (community)
- **Categories:** Social media, Developer tools, Videos
- **Features:** Full permissions
- **Stats:** 23 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$5.00 / 1,000 actor starts

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?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Threads Media and Metadata Extractor

Extract media files and comprehensive metadata from Threads posts with high reliability and structured output. This Apify actor handles Threads URLs and provides detailed information about posts, images, videos, user profiles, and engagement statistics.

### Features

- 🧵 **Media Extraction**: Download high-quality videos and images from Threads posts
- 📊 **Rich Metadata**: Get comprehensive post information including user details, statistics, and content descriptions
- 🔍 **Flexible URLs**: Support for all Threads URL formats (threads.com)
- 📱 **Raw Data Option**: Access to complete Threads API response for advanced use cases
- ⚡ **Fast & Reliable**: Built on proven extraction technology with robust error handling
- 💰 **Cost-Effective**: Pay-per-use pricing at just $0.005 per extraction

### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `url` | string | ✅ | Threads post URL (supports threads.com/@username/post/POST_ID format) |
| `raw` | string | ❌ | Include raw Threads API response with extended metadata (default: undefined) |

#### Example Input

```json
{
  "url": "https://www.threads.com/@username/post/DKUq2_EgVUF",
  "raw": "raw"
}
```

### Supported URL Formats

This actor supports Threads URL variations:

- `https://www.threads.com/@username/post/POST_ID`
- `https://threads.com/@username/post/POST_ID`

#### Example URLs:

- Text posts: `https://www.threads.com/@texasbluesalley/post/DKUq2_EgVUF`
- Image posts: `https://www.threads.com/@dcfilmnews/post/DKTQvOotZdp`
- Video posts: `https://www.threads.com/@mariners/post/DKTSy7DN1eN`
- Multiple images: `https://www.threads.com/@unmethodicall/post/DKS_8q1SBzt`
- Quote posts: `https://www.threads.com/@slev_kelevra/post/DKVCLrURTTF`

### Output Format

The actor returns structured data containing:

#### User Information

- Profile name and display name
- Profile picture URL
- Verification status
- Username and user ID

#### Content Details

- Post link and unique identifier
- Post text/description with proper formatting
- Publication timestamp
- Media files (videos/images) with download URLs
- Post type and thread information

#### Engagement Statistics

- Like count
- Comment count (direct replies)
- Share/repost count
- Quote count

#### Example Output

```json
{
  "type": "threads",
  "user": {
    "name": "texasbluesalley",
    "displayName": "Texas Blues Alley",
    "pictures": {
      "url": "https://scontent-atl3-1.cdninstagram.com/v/t51.2885-19/..."
    },
    "verified": true
  },
  "content": {
    "link": "https://threads.com/@texasbluesalley/post/DKUq2_EgVUF",
    "description": "Last night's \"Cold Shot\" lesson was DOA on YouTube...",
    "title": null,
    "postedDate": "2025-01-27T20:14:37.000Z",
    "adult": false,
    "media": [
      {
        "type": "photo",
        "url": "https://external-atl3-2.xx.fbcdn.net/...",
        "thumbnail": "https://external-atl3-2.xx.fbcdn.net/...",
        "size": {
          "width": 612,
          "height": 612
        }
      }
    ],
    "statistics": {
      "likes": 4,
      "comments": 3,
      "shares": 0
    }
  }
}
```

### Content Types Supported

- **Text Posts**: Pure text content with mentions and links
- **Image Posts**: Single images with captions
- **Video Posts**: Video content with thumbnails
- **Carousel Posts**: Multiple images in a single post
- **Quote Posts**: Posts that quote other Threads posts
- **Link Previews**: Posts with external link previews (YouTube, etc.)

### Error Handling

The actor handles common Threads-related errors gracefully:

| Error | Description | HTTP Status |
|-------|-------------|-------------|
| Invalid URL | The provided URL is not a valid Threads link | 400 |
| Post Not Found | The Threads post has been deleted or doesn't exist | 404 |
| Private Post | The post is from a private account | 404 |
| Rate Limited | Too many requests to Threads servers | 429 |
| Network Error | Connection issues or Threads downtime | 500 |

### Technical Details

This actor is built using:

- **Apify SDK v3** for robust actor framework
- **Custom Threads Extractors** with advanced HTML parsing
- **Cheerio** for HTML parsing and data extraction
- **Axios** for reliable HTTP requests
- **Node.js Runtime** for optimal performance

The extraction process parses Threads' embedded JSON data from the HTML response to extract comprehensive post information.

### Use Cases

- **Social Media Analytics**: Track Threads performance metrics
- **Content Aggregation**: Collect Threads content for platforms or dashboards
- **Market Research**: Analyze trending content and user engagement
- **Media Archival**: Backup Threads content with metadata
- **Academic Research**: Study social media trends and behavior
- **Content Creation**: Gather inspiration and analyze successful posts

### Support

For questions, bug reports, or feature requests:

- Create an issue in the actor's repository
- Contact support through Apify Console
- Check the [Apify documentation](https://docs.apify.com/) for general usage help

### License

This actor is provided as-is for legitimate use cases. Please respect Threads' Terms of Service and applicable data protection regulations when using this tool.

***

**Ready to extract Threads data?** Run this actor now or integrate it into your application using the examples above.

### Related Actors

Explore our other social media extraction actors:

- **[TikTok Media and Metadata Retriever](https://apify.com/gratenes/tiktok-media-and-metadata-retriever)** - Extract videos, images, and metadata from TikTok posts with support for all TikTok URL formats (vm.tiktok.com, vt.tiktok.com, www.tiktok.com)

# Actor input Schema

## `url` (type: `string`):

Threads post URL in the format threads.com/@username/post/POST_ID or threads.net/@username/post/POST_ID

## `raw` (type: `string`):

Include raw Threads API response with extended metadata (pass 'raw' to enable).

## Actor input object example

```json
{
  "url": "https://www.threads.com/@timbersfc/post/DMj0QoCueqk?hl=en"
}
```

# 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 = {
    "url": "https://www.threads.com/@timbersfc/post/DMj0QoCueqk?hl=en"
};

// Run the Actor and wait for it to finish
const run = await client.actor("gratenes/threads-media-and-metadata-retriever").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 = { "url": "https://www.threads.com/@timbersfc/post/DMj0QoCueqk?hl=en" }

# Run the Actor and wait for it to finish
run = client.actor("gratenes/threads-media-and-metadata-retriever").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 '{
  "url": "https://www.threads.com/@timbersfc/post/DMj0QoCueqk?hl=en"
}' |
apify call gratenes/threads-media-and-metadata-retriever --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,gratenes/threads-media-and-metadata-retriever"
        }
    }
}
```

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/k1ck9MexNalzdLFZw/builds/fxp0oa8CRePqTVKzE/openapi.json
