# Discord Public Server Scraper (`gitlab/discord-server-scraper`) Actor

Search the official public Discord server directory and retrieve read-only public invite guild metadata.

- **URL**: https://apify.com/gitlab/discord-server-scraper.md
- **Developed by:** [Gitlab](https://apify.com/gitlab) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.99 / actor start

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

## Discord Public Server Scraper

Search Discord's official public server directory and look up read-only public invite metadata. This Actor returns public guild names, descriptions, approximate member/online counts, boost metadata, categories, keywords, features, images and source provenance when published.

### Input

```json
{"query":"gaming","maxItems":10,"proxyConfiguration":{"useApifyProxy":false}}
```

`query` searches the current public website. `searchQuery` is a legacy alias used only when `query` is omitted. The editor prefills `gaming` and `maxItems: 10`. Programmatic empty input defaults to gaming. The integer limit must be 1–500.

For invite-only mode, omit both query fields or explicitly set `query` to an empty string:

```json
{"query":"","inviteCodes":["midjourney","https://discord.gg/python"],"maxItems":10}
```

Only bare invite codes and HTTPS `discord.gg/<code>` or `discord.com/invite/<code>` URLs are accepted. Tracking query strings are discarded. When both inputs are supplied, search results are saved first, then remaining invite inputs until the same global limit is reached. Guild IDs are deduplicated across modes. Fewer results are returned if the source publishes fewer matches or invites expire.

### Sources and fields

The Actor reads [the official public directory](https://discord.com/servers), including the actual search input, pagination links and each matching public guild profile. Profile pages supply metadata omitted from keyword cards. Category IDs are matched against names published in the live directory and the profile's category links. It decodes only literal serialized data using an AST allowlist; source scripts are never evaluated. Public invite enrichment uses the documented [Get Invite endpoint](https://docs.discord.com/developers/resources/invite#get-invite) with `with_counts=true`. The old Discovery Search API is no longer used.

`memberCount` and `onlineMemberCount` prefer a matching public invite response when available, then the matching public profile, then the search card. `directoryMemberCount`, `directoryOnlineMemberCount`, `directoryBoostCount`, `listingName`, and `directoryFeatures` retain the distinct search card values. `profileMemberCount`, `profileOnlineMemberCount` and `profileBoostCount` retain profile values separately. Directory counts can lag: the website states member counts may be seven days old and online counts six hours old. All counts are approximate.

`boostCount` and its compatibility alias `premiumSubscriptions` represent actual `premium_subscription_count`. `boostLevel` is the actual `premium_tier`, never inferred from boost count. Primary category follows the source's primary category ID and the same live directory's category ID/name metadata. `categories` includes known source category names and the public profile's displayed category labels; `profileDisplayedCategories` preserves those visible labels separately. Unmapped category IDs are retained with a null name in `categoryDetails`. Icons already published as full URLs remain intact; hash-based icon/banner/splash URLs follow Discord's [documented CDN paths](https://docs.discord.com/developers/reference#image-formatting).

Unavailable fields remain `null`. Public invite responses often omit directory categories, keywords, locale, emoji/sticker arrays, and some images. Empty emoji/sticker counts are zero only when the source supplies an actual empty array. An invite code is kept separately from a guild's published vanity code. The Actor does not join servers, accept invitations, read member lists or private messages, or request account credentials.

### Evidence and access limits

The default key-value store retains `directory_*` HTML, parsed data and access/query evidence, plus `invite_*` sanitized guild/count responses. Inviter, channel and target-user details are discarded. Each dataset row has source URLs, input mode, snapshot/provenance fields and extraction timestamps.

Optional `proxyConfiguration` applies to both sources. Verification prompts stop further requests. HTTP 401/403/429 stops further source work, preserves already saved public records, and records the access limitation. Expired or unavailable invites do not produce placeholder records.

### Local use

Install the locked dependencies with `npm ci`, then run `apify run --input-file input.json`. Local datasets and key-value evidence stay in local storage. No deployment is required for this check.

# Changelog

This Actor's version history is a separate document: https://apify.com/gitlab/discord-server-scraper/changelog.md

# Actor input Schema

## `query` (type: `string`):

Keyword search on the official public Discord server directory. Leave empty for invite-only mode.

## `inviteCodes` (type: `array`):

Optional public Discord invite codes or HTTPS discord.gg / discord.com/invite URLs. Search results are saved first when both modes are supplied; one global maxItems limit applies.

## `maxItems` (type: `integer`):

Maximum number of Discord servers to return.

## `searchQuery` (type: `string`):

Alias used only when query is omitted. Leave empty when using query or invite-only mode.

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

Optional proxy for directory and read-only public invite HTTP requests.

## Actor input object example

```json
{
  "query": "gaming",
  "inviteCodes": [],
  "maxItems": 10,
  "searchQuery": "",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

Dataset containing the records extracted by this Actor.

# 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 = {
    "query": "gaming",
    "inviteCodes": [],
    "maxItems": 10,
    "searchQuery": "",
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("gitlab/discord-server-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 = {
    "query": "gaming",
    "inviteCodes": [],
    "maxItems": 10,
    "searchQuery": "",
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("gitlab/discord-server-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 '{
  "query": "gaming",
  "inviteCodes": [],
  "maxItems": 10,
  "searchQuery": "",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call gitlab/discord-server-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,gitlab/discord-server-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/FlxiKPhWy9KfTTbyN/builds/MnSYSwvXk2dVBOZ4V/openapi.json
