# Lemmy API

Retrieve Lemmy posts and nested comments by keyword, community, or instance timeline.

Set the target instance domain for each query. Full coverage across all federated instances is not guaranteed.

- Request: POST https://api.everyinfra.com/api/v1/social with `{"platform": "lemmy", "action": "<action>", "params": {...}}`
- Canonical page: [https://everyinfra.com/en/lemmy-api](https://everyinfra.com/en/lemmy-api?utm_medium=ai_doc&utm_campaign=page_md)
- Each capability uses the price recorded in the public catalog. The response includes the amount charged. Authentication failures, invalid parameters, failed calls, and empty results are not charged.

## Actions

### search — Search
Search Lemmy posts on one instance by `keyword`, with community, author, score, upvotes and downvotes, comment count, external link and NSFW, locked and featured flags. The search runs on the chosen `instance`, lemmy.world by default, and does not cover the whole fediverse.
- Sync delivery · Price: $1.39 per 1,000 requests (every 20 rows count as one call)
- Catalog values: defaultLimit=20, maxLimit=200. For some actions a limit controls pages or per-parent expansion, so it is not always the final row count.
- Parameters:
  - `keyword` (required): Specifies the search term for the Lemmy search action, which executes on the designated instance rather than guaranteeing a complete search across all federated instances.
  - `instance` (optional): Selects the Lemmy instance domain, such as lemmy.world, which is also the default. A full instance URL is accepted but reduced to its hostname. This chooses the query entry point, not a community name.
  - `sort` (optional): Sorts posts as hot, active, new, top, most_comments, or new_comments. Search and community default to hot, feed defaults to active, and comments defaults to most_comments. One of: active, hot, most_comments, new, new_comments, top.
  - `top_range` (optional): Sets the score window only when sort is top: hour, sixhour, twelvehour, day, week (default), month, threemonths, sixmonths, ninemonths, year, or all. It is not a comment publication-date filter. One of: all, day, hour, month, ninemonths, sixhour, sixmonths, threemonths, twelvehour, week, year.
- Returns fields: id, title, body, url, external_url, community, community_url, instance, author_username, author_url, score, upvote_count, downvote_count, comment_count, thumbnail_url, embed_title, is_nsfw, is_locked, is_featured, posted_at, updated_at, platform
- Capability page: [https://everyinfra.com/en/lemmy-api/search](https://everyinfra.com/en/lemmy-api/search?utm_medium=ai_doc&utm_campaign=page_md) (Markdown: https://everyinfra.com/en/lemmy-api/search.md)

### community — Community
Read the posts of a Lemmy community, by name or name@instance. Get score, votes, comment count, links and post flags, sorted hot by default. Same-named communities on other instances are not merged. `top_range` applies only when you sort by `top`.
- Sync delivery · Price: $1.39 per 1,000 requests (every 20 rows count as one call)
- Catalog values: defaultLimit=20, maxLimit=200. For some actions a limit controls pages or per-parent expansion, so it is not always the final row count.
- Parameters:
  - `community` (required): Specifies the community name or the cross-instance identifier in name@instance format. In the community action, it lists community posts; in the comments action, it fetches posts from the community and expands their comments rather than querying a single post URL directly.
  - `instance` (optional): Selects the Lemmy instance domain, such as lemmy.world, which is also the default. A full instance URL is accepted but reduced to its hostname. This chooses the query entry point, not a community name.
  - `sort` (optional): Sorts posts as hot, active, new, top, most_comments, or new_comments. Search and community default to hot, feed defaults to active, and comments defaults to most_comments. One of: active, hot, most_comments, new, new_comments, top.
  - `top_range` (optional): Sets the score window only when sort is top: hour, sixhour, twelvehour, day, week (default), month, threemonths, sixmonths, ninemonths, year, or all. It is not a comment publication-date filter. One of: all, day, hour, month, ninemonths, sixhour, sixmonths, threemonths, twelvehour, week, year.
- Returns fields: id, title, body, url, external_url, community, community_url, instance, author_username, author_url, score, upvote_count, downvote_count, comment_count, thumbnail_url, embed_title, is_nsfw, is_locked, is_featured, posted_at, updated_at, platform
- Capability page: [https://everyinfra.com/en/lemmy-api/community](https://everyinfra.com/en/lemmy-api/community?utm_medium=ai_doc&utm_campaign=page_md) (Markdown: https://everyinfra.com/en/lemmy-api/community.md)

### feed — News feed
Browse the post feed of a Lemmy instance, lemmy.world by default. Each post has community, score, votes, comment count and flags, sorted by activity by default. It is neither a personalized timeline nor a complete view of the fediverse.
- Sync delivery · Price: $1.39 per 1,000 requests (every 20 rows count as one call)
- Catalog values: defaultLimit=20, maxLimit=100. For some actions a limit controls pages or per-parent expansion, so it is not always the final row count.
- Parameters:
  - `instance` (optional): Selects the Lemmy instance domain, such as lemmy.world, which is also the default. A full instance URL is accepted but reduced to its hostname. This chooses the query entry point, not a community name.
  - `sort` (optional): Sorts posts as hot, active, new, top, most_comments, or new_comments. Search and community default to hot, feed defaults to active, and comments defaults to most_comments. One of: active, hot, most_comments, new, new_comments, top.
  - `top_range` (optional): Sets the score window only when sort is top: hour, sixhour, twelvehour, day, week (default), month, threemonths, sixmonths, ninemonths, year, or all. It is not a comment publication-date filter. One of: all, day, hour, month, ninemonths, sixhour, sixmonths, threemonths, twelvehour, week, year.
- Returns fields: id, title, body, url, external_url, community, community_url, instance, author_username, author_url, score, upvote_count, downvote_count, comment_count, thumbnail_url, embed_title, is_nsfw, is_locked, is_featured, posted_at, updated_at, platform
- Capability page: [https://everyinfra.com/en/lemmy-api/feed](https://everyinfra.com/en/lemmy-api/feed?utm_medium=ai_doc&utm_campaign=page_md) (Markdown: https://everyinfra.com/en/lemmy-api/feed.md)

### comments — Comments
Fetch comments from posts in a Lemmy community, with score, votes, depth, parent comment ID, deletion flag and the post each belongs to. `max_comments` caps comments per post, from 1 to 200 with a default of 50, not the request total.
- Sync delivery · Price: $1.39 per 1,000 requests (every 10 rows count as one call)
- Catalog values: defaultLimit=10, maxLimit=200. For some actions a limit controls pages or per-parent expansion, so it is not always the final row count.
- Parameters:
  - `community` (required): Specifies the community name or the cross-instance identifier in name@instance format. In the community action, it lists community posts; in the comments action, it fetches posts from the community and expands their comments rather than querying a single post URL directly.
  - `instance` (optional): Selects the Lemmy instance domain, such as lemmy.world, which is also the default. A full instance URL is accepted but reduced to its hostname. This chooses the query entry point, not a community name.
  - `max_comments` (optional): Sets the maximum number of comments to fetch per post in the comments action, defaulting to 50 with an allowed range of 1 to 200. It limits comments per post rather than total posts or total comments for the request and automatically clamps values outside the allowed range.
  - `sort` (optional): Sorts posts as hot, active, new, top, most_comments, or new_comments. Search and community default to hot, feed defaults to active, and comments defaults to most_comments. One of: active, hot, most_comments, new, new_comments, top.
  - `top_range` (optional): Sets the score window only when sort is top: hour, sixhour, twelvehour, day, week (default), month, threemonths, sixmonths, ninemonths, year, or all. It is not a comment publication-date filter. One of: all, day, hour, month, ninemonths, sixhour, sixmonths, threemonths, twelvehour, week, year.
- Returns fields: id, text, author_username, author_url, score, upvote_count, downvote_count, depth, parent_comment_id, is_deleted, post_url, post_title, community, posted_at, platform
- Capability page: [https://everyinfra.com/en/lemmy-api/comments](https://everyinfra.com/en/lemmy-api/comments?utm_medium=ai_doc&utm_campaign=page_md) (Markdown: https://everyinfra.com/en/lemmy-api/comments.md)

## Lemmy API questions

### What can I retrieve with the Lemmy API?

Set `platform` to `lemmy`. The current catalog lists search, community, news feed, and comments. These action names identify different Lemmy objects or views; they are not interchangeable search modes.

### Which input starts the Lemmy `search` request?

Specifies the search term for the Lemmy search action, which executes on the designated instance rather than guaranteeing a complete search across all federated instances. Send it as `keyword` inside `params`.

### Which fields can Lemmy `search` return?

Its declared schema includes `title`, `body`, `external_url`, and `community`. A declared field can still be absent from an individual record, and every other action has its own field list.

### Does every Lemmy action return immediately?

Actions labeled asynchronous return a job ID you poll. Every other action can also run asynchronously: add `"mode": "async"` to the request body to receive a job ID immediately, useful for slow tasks or large limits. The current catalog contains sync delivery.

## Also

- Machine catalog (no key): https://everyinfra.com/openapi.json · GET /api/v1/social/catalog?platform=lemmy
- API guide for AI clients: https://everyinfra.com/llms.txt · agents guide: https://everyinfra.com/agents.md
