---
title: "CLI"
description: "`groundsocial`: Reddit data from a terminal or a coding agent, with `--json` on every command."
canonical_url: https://groundsocial.dev/docs/cli
---
# CLI

> `groundsocial`: Reddit data from a terminal or a coding agent, with `--json` on every command.

> ## Agent Instructions
> The Groundsocial REST API is at https://api.groundsocial.dev (OpenAPI: https://groundsocial.dev/openapi.json). Set yourself up with https://groundsocial.dev/SKILL.md; the MCP server is https://api.groundsocial.dev/mcp. Every docs page is Markdown at its URL plus `.md`; the index is https://groundsocial.dev/llms.txt.

> **Not on npm yet** The SDK, CLI and stdio MCP server are not published yet. Until they are, use the REST API or the remote MCP server, and don't install packages named `@groundsocial/…` from npm: they aren't ours.

**Built for agents in a shell.** Strict flags with did-you-mean, data on stdout and messages on stderr, and a `--json` envelope on every command. Install with `npm i -g @groundsocial/cli` or run it with `npx -y @groundsocial/cli`.

```bash
npx -y @groundsocial/cli init
```

`init` reuses a working key if it finds one, or creates a free account (no human needed). If signup asks a question, it prints it; run `init --answer <word>`.

## Commands

| Command | What it does |
| --- | --- |
| `groundsocial init [--answer <word>] [--agent-name <name>]` | Reuse a working key, or create a free account. |
| `groundsocial login` | Sign in through the browser (device login). `--no-wait` prints the code and exits; finish with `--poll`. `--api-key <key>` stores a key; `--email <address>` signs in by email, needed for `keys`. |
| `groundsocial logout` | Forget the stored key and session. |
| `groundsocial whoami` | Which account and key are in use. |
| `groundsocial balance` | Credits left. Free. |
| `groundsocial keys list\|create <name>\|revoke <key_id>` | Manage keys. `--daily-cap` and `--monthly-cap` set caps on a new key. Needs `login --email`: a key can’t manage keys. |
| `groundsocial mcp` | Print MCP client config for the stdio and remote servers. Edits nothing. |
| `groundsocial reddit <command> [args] [flags]` | Read Reddit data; one command per endpoint. |
| `groundsocial estimate <command>[:count] …` | Price a job before running it. Local and free; needs no key. |
| `groundsocial endpoints` | Every reddit command with its price. Free. |

## Reading data

The reddit commands are `subreddit`, `subreddit-posts`, `post`, `more-comments`, `user`, `user-posts`, `user-comments`, `search-posts` and `search-subreddits`. Path parameters (or the search query) are positional; everything else is a flag with the API’s own name. Listings take `--max-pages <n>` to follow the cursor.

```bash
groundsocial reddit subreddit-posts LocalLLaMA --sort new --limit 25
groundsocial reddit search-posts "self-hosted backups" --sort new --max-pages 3 --json
groundsocial estimate search-posts:100 post:20
```

## Global flags

- `--json`: machine output on stdout, `{ok: true, …}` or `{ok: false, error}`.
- `--api-key <key>`: use this key for one command (otherwise the environment, then the config file).
- `--api-url <url>`: API base URL.
- `--help`, `--version`.

Errors in `--json` mode carry `code`, `message`, `next_action` and `suggested_commands`, and where useful `likely_cause`, `retry_after`, `request_id` or the signup `challenge`.

## Examples

Set up:

```bash
npx -y @groundsocial/cli init
groundsocial balance
groundsocial reddit post 1y3k9qa --json
```

--json error:

```json
{
  "ok": false,
  "error": {
    "code": "unknown_command",
    "message": "Unknown command reddit posts. Did you mean reddit post?",
    "next_action": "Pick one of: subreddit, subreddit-posts, post, …",
    "suggested_commands": [
      "groundsocial reddit post <id>"
    ]
  }
}
```

_Canonical HTML: https://groundsocial.dev/docs/cli_

## Site Navigation

### Global Hub
- [Home](https://groundsocial.dev/index.md)
- [Pricing](https://groundsocial.dev/pricing.md)
- [Endpoints](https://groundsocial.dev/endpoints.md)
- [For agents](https://groundsocial.dev/agents.md)
- [Docs](https://groundsocial.dev/docs.md)
- [Compare](https://groundsocial.dev/compare.md)
- [Changelog](https://groundsocial.dev/changelog.md)
- [llms.txt](https://groundsocial.dev/llms.txt)
- [Agent skill](https://groundsocial.dev/SKILL.md)

### On This Topic
- [Groundsocial docs](https://groundsocial.dev/docs.md)
- [Quickstart](https://groundsocial.dev/docs/quickstart.md)
- [Authentication](https://groundsocial.dev/docs/authentication.md)
- [Credits and payments](https://groundsocial.dev/docs/payments.md)
- [Rate limits](https://groundsocial.dev/docs/rate-limits.md)
- [Errors](https://groundsocial.dev/docs/errors.md)
- [Data freshness and caching](https://groundsocial.dev/docs/freshness.md)
- [MCP server](https://groundsocial.dev/docs/mcp.md)
- [SKILL.md, llms.txt and Markdown twins](https://groundsocial.dev/docs/skill.md)
- [TypeScript SDK](https://groundsocial.dev/docs/sdk.md)
- [PRAW and snoowrap](https://groundsocial.dev/docs/praw.md)
- [Legal and compliance](https://groundsocial.dev/docs/compliance.md)
- [API reference](https://groundsocial.dev/docs/api.md)

## Structured data

```json
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://groundsocial.dev/"},{"@type":"ListItem","position":2,"name":"Docs","item":"https://groundsocial.dev/docs"},{"@type":"ListItem","position":3,"name":"CLI","item":"https://groundsocial.dev/docs/cli"}]}
```
