# HN/Reddit Sentiment Analyzer (`darknezz/sentiment-analyzer`) Actor

Fetch posts from Hacker News and Reddit, run VADER sentiment analysis, and output structured results with sentiment scores, keywords, and metadata. Perfect for brand monitoring, trend detection, and market research.

- **URL**: https://apify.com/darknezz/sentiment-analyzer.md
- **Developed by:** [Oaida Adrian](https://apify.com/darknezz) (community)
- **Categories:** AI, Marketing
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 post analyseds

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/platform/actors/running/actors-in-store#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

## HN / Reddit Sentiment Analyzer — Community Mood, Structured

Pull posts from **Hacker News** and **any subreddit**, score each one with VADER sentiment analysis, and get back one clean JSON item per post — sentiment label, numeric scores, top keywords, and engagement. Perfect for tracking how a technology, product, or topic is being received across the two most influential tech communities.

### Why this Actor?

- **Two sources, one schema** — Hacker News (Firebase API) and Reddit, normalised into identical records.
- **Real sentiment, not guesses** — VADER gives calibrated `compound`, `positive`, `negative`, and `neutral` scores tuned for social/short-form text.
- **Filter at the source** — return only `positive`/`negative`/`neutral` posts, or only those above a minimum upvote count.
- **Keyword extraction** — top terms per post so you can pivot straight into topic analysis.

### Who is this for?

- **Brand & product teams** — monitor how your launch, feature, or company is being discussed.
- **Founders & PMs** — read the room on a technology before betting on it.
- **Market & trend researchers** — quantify community mood over time from a scheduled run.
- **Content curators & newsletters** — surface the most positive (or most heated) threads automatically.

### How it works

1. Fetches top/new HN stories and/or hot/new/top/rising posts from the subreddits you list.
2. Runs VADER on each title (and body text where available).
3. Extracts keywords and applies your sentiment / minimum-score filters.
4. Writes one dataset item per post.

### Input

```json
{
  "sources": "both",
  "subreddit": "technology, programming",
  "sortBy": "hot",
  "hnSort": "top",
  "maxPosts": 100,
  "sentimentFilter": "",
  "minScore": 10
}
```

| Option | Description |
|--------|-------------|
| `sources` | `hackernews`, `reddit`, or `both` |
| `subreddit` | Comma-separated subreddits (required when `sources` includes reddit) |
| `sortBy` | Reddit sort: `hot`, `new`, `top`, `rising` |
| `hnSort` | HN sort: `top` or `new` |
| `maxPosts` | Max posts to analyse (default 50, up to 500) |
| `sentimentFilter` | Return only `positive`, `negative`, or `neutral` posts |
| `minScore` | Minimum upvotes required |

### Output (one item per post)

```json
{
  "source": "reddit",
  "title": "Our team switched to Rust and shipped 40% fewer bugs",
  "author": "somedev",
  "postedAt": "2026-07-18T14:22:05.000Z",
  "sentiment": "positive",
  "compound": 0.6486,
  "positive": 0.4521,
  "neutral": 0.5479,
  "negative": 0.0,
  "score": 1250,
  "keywords": ["rust", "team", "bugs", "shipped"],
  "analysedAt": "2026-07-19T20:00:00.000Z"
}
```

### Run it on a schedule or from your app

```bash
curl -X POST "https://api.apify.com/v2/acts/darknezz~sentiment-analyzer/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "sources": "reddit", "subreddit": "startups", "sortBy": "new", "maxPosts": 100 }'
```

Schedule a daily run in the Apify Console and read new items straight from the dataset to build a sentiment time series.

### Pricing

Pay per event — a small fee **per post analysed**. No subscription: scan 20 posts or 500 and pay only for what you process.

### FAQ

**What sentiment model is used?** VADER (Valence Aware Dictionary and sEntiment Reasoner), which is purpose-built for social-media and short-form text and returns a normalised `compound` score from -1 (most negative) to +1 (most positive).

**Do I need Reddit or HN API keys?** No. It uses the public Hacker News Firebase API and Reddit's public JSON endpoints. Enable the Apify proxy (default) to avoid rate limits on large runs.

**Can I track sentiment over time?** Yes — schedule the Actor and each run appends fresh, timestamped items (`analysedAt`) to the dataset, ready to chart as a trend.

**How are keywords chosen?** The top content terms per post after stop-word removal, so you can group and filter posts by topic without extra processing.

# Actor input Schema

## `sources` (type: `string`):

Data sources to fetch from.

## `subreddit` (type: `string`):

Comma-separated subreddit names (e.g. technology, programming). Required if sources includes reddit.

## `sortBy` (type: `string`):

Sort order for Reddit posts.

## `hnSort` (type: `string`):

Sort order for Hacker News stories.

## `maxPosts` (type: `integer`):

Maximum number of posts to analyse.

## `sentimentFilter` (type: `string`):

Only return posts matching this sentiment.

## `minScore` (type: `integer`):

Only return posts with at least this many upvotes.

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

Use Apify proxy to avoid rate limits.

## Actor input object example

```json
{
  "sources": "hackernews",
  "subreddit": "",
  "sortBy": "hot",
  "hnSort": "top",
  "maxPosts": 50,
  "sentimentFilter": "",
  "minScore": 0,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `id` (type: `string`):

No description

## `source` (type: `string`):

No description

## `title` (type: `string`):

No description

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

No description

## `author` (type: `string`):

No description

## `score` (type: `string`):

No description

## `commentsCount` (type: `string`):

No description

## `sentiment` (type: `string`):

No description

## `sentimentScores` (type: `string`):

No description

## `keywords` (type: `string`):

No description

## `postedAt` (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 = {
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("darknezz/sentiment-analyzer").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 = { "proxyConfiguration": { "useApifyProxy": True } }

# Run the Actor and wait for it to finish
run = client.actor("darknezz/sentiment-analyzer").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call darknezz/sentiment-analyzer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=darknezz/sentiment-analyzer",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/d6cFTYbSAsP6xD6cE/builds/nuxWaKWHmTP76Ju1R/openapi.json
