> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetch many entities

> Fetch a paginated, filtered, and sorted list of entities

export const SpaceReputationParams = ({variant = "context", field = "path"}) => {
  const isUser = variant === "user";
  return <>
      <ParamField {...{
    [field]: "spaceReputation",
    type: "object"
  }}>
        Opt-in. Adds a <code>spaceReputation</code> number to each returned user,
        scoped to a single space. Requires the <code>reputation</code> bundle.
        The <code>reputation</code> total is always present regardless;{" "}
        <code>spaceReputation</code> is purely additive and only appears when you
        pass this object. <strong>This object is the primary form</strong> — it
        replaces the deprecated flat props below. See the{" "}
        <a href="/v8/data-models/reputation">Reputation data model</a> for the
        full contract.

        <Expandable title="spaceReputation">
          {isUser ? <ParamField name="spaceId" type="string | &quot;none&quot;" required>
              Which bucket to read. A space <strong><code>&lt;uuid&gt;</code></strong> reads that
              space's bucket; <strong><code>"none"</code></strong> reads the
              project-general (space-less) bucket.{" "}
              <strong><code>"context"</code> is rejected (400)</strong> on this
              endpoint — there is no space context to derive. The empty string
              and the legacy <code>general</code> / <code>null</code> aliases are
              also rejected. Missing buckets read as <code>0</code>.
            </ParamField> : <ParamField name="spaceId" type="string | &quot;none&quot; | &quot;context&quot;" required>
              Which bucket to read. One of: a space <strong><code>&lt;uuid&gt;</code></strong>{" "}
              (that space's bucket), <strong><code>"none"</code></strong> (the
              project-general, space-less bucket), or{" "}
              <strong><code>"context"</code></strong> (the space derived from the
              request context — resolved per-row on lists, or the single space on
              member/team/conversation surfaces). The empty string and the legacy{" "}
              <code>general</code> / <code>null</code> aliases are rejected (400).
              Missing buckets read as <code>0</code>.
            </ParamField>}
          <ParamField name="includeDescendants" type="boolean">
            Only honored when <code>spaceId</code> is an explicit space <code>&lt;uuid&gt;</code>.
            When <code>true</code>, <code>spaceReputation</code> is the{" "}
            <strong>subtree sum</strong> — the named space plus all of its
            descendant spaces (the root space's own bucket included). Ignored for{" "}
            <code>"none"</code>; not allowed with <code>"context"</code>.
          </ParamField>
        </Expandable>
      </ParamField>

      {isUser ? <ParamField {...{
    [field]: "spaceReputationId",
    type: "string",
    deprecated: true
  }}>
          <strong>Deprecated</strong> — use the <code>spaceReputation</code>{" "}
          object instead. The flat form of <code>spaceReputation.spaceId</code>.
          Still accepted (the object wins if both are passed); removal is a later
          major version. Accepts a space <code>&lt;uuid&gt;</code> or <code>"none"</code> only —{" "}
          <code>"context"</code> is rejected (400) on this endpoint.
        </ParamField> : <ParamField {...{
    [field]: "spaceReputationId",
    type: "string",
    deprecated: true
  }}>
          <strong>Deprecated</strong> — use the <code>spaceReputation</code>{" "}
          object instead. The flat form of <code>spaceReputation.spaceId</code>.
          Still accepted (the object wins if both are passed); removal is a later
          major version. Accepts a space <code>&lt;uuid&gt;</code>, <code>"none"</code>, or{" "}
          <code>"context"</code>.
        </ParamField>}

      <ParamField {...{
    [field]: "spaceReputationDescendants",
    type: "boolean",
    deprecated: true
  }}>
        <strong>Deprecated</strong> — use{" "}
        <code>spaceReputation.includeDescendants</code> instead. The flat form,
        only honored alongside an explicit <code>spaceReputationId</code> <code>&lt;uuid&gt;</code>.
      </ParamField>
    </>;
};

<Note>
  **Requires the `entities` bundle.** A project without the entities bundle returns `403 database/tables-not-available`. See [Bundles](/v8/bundles).
</Note>

## Overview

`useFetchManyEntities` returns a function that fetches a paginated list of entities with full filtering and sorting support. This is the low-level hook underlying `EntityListProvider`. For continuous-scroll or load-more list UIs, use [`useEntityList`](/v8/hooks/entity-lists/use-entity-list) instead, which wraps this hook with built-in pagination state.

## Usage Example

```tsx theme={null}
import { useFetchManyEntities } from "@sublay/react-js";
import { useEffect, useState } from "react";

function EntityFeed() {
  const fetchEntities = useFetchManyEntities();
  const [entities, setEntities] = useState([]);

  useEffect(() => {
    fetchEntities({
      page: 1,
      limit: 20,
      sortBy: "score",
      spaceId: "space_abc",
      include: ["user"],
    }).then((res) => setEntities(res.data));
  }, []);

  return (
    <ul>
      {entities.map((e) => (
        <li key={e.id}>{e.title}</li>
      ))}
    </ul>
  );
}
```

## Parameters

<ParamField path="page" type="number">
  Page number (1-indexed). Defaults to `1`.
</ParamField>

<ParamField path="limit" type="number">
  Results per page. Defaults to server default.
</ParamField>

<ParamField path="sortBy" type="string">
  Field to sort by. Options: `"createdAt"`, `"top"`, `"hot"`, `"controversial"`, or `"metadata.<property>"` to sort by a metadata field.
</ParamField>

<ParamField path="sortByReaction" type="string">
  Which reaction `top` ranks by. Only sent when `sortBy` is `"top"`; ignored for every other sort.
</ParamField>

<ParamField path="sortDir" type="string">
  Sort direction: `"asc"` or `"desc"`.
</ParamField>

<ParamField path="sortType" type="string">
  Sort algorithm type. Options: `"auto"`, `"numeric"`, `"text"`, `"boolean"`, `"timestamp"`. Used when sorting by a metadata field.
</ParamField>

<ParamField path="timeFrame" type="string">
  Filter entities to a time window. Options: `"day"`, `"week"`, `"month"`, `"year"`.
</ParamField>

<ParamField path="sourceId" type="string">
  Filter to entities associated with a specific source ID.
</ParamField>

<ParamField path="spaceId" type="string">
  Filter to entities in a specific space.
</ParamField>

<ParamField path="userId" type="string">
  Filter to entities created by a specific user.
</ParamField>

<ParamField path="followedOnly" type="boolean">
  If `true`, return only entities from users the authenticated user follows.
</ParamField>

<ParamField path="keywordsFilters" type="object">
  Filter by keywords. See [Entity List Filters](/v8/sdk/entity-lists/filters) for the full filter schema.
</ParamField>

<ParamField path="titleFilters" type="object">
  Filter by title content. See [Entity List Filters](/v8/sdk/entity-lists/filters).
</ParamField>

<ParamField path="contentFilters" type="object">
  Filter by body content. See [Entity List Filters](/v8/sdk/entity-lists/filters).
</ParamField>

<ParamField path="attachmentsFilters" type="object">
  Filter by attachments data. See [Entity List Filters](/v8/sdk/entity-lists/filters).
</ParamField>

<ParamField path="locationFilters" type="object">
  Filter by geographic proximity. See [Entity List Filters](/v8/sdk/entity-lists/filters).
</ParamField>

<ParamField path="metadataFilters" type="object">
  Filter by metadata fields. See [Entity List Filters](/v8/sdk/entity-lists/filters).
</ParamField>

<ParamField path="nsfwFilter" type="&#x22;include-all&#x22; | &#x22;exclude&#x22; | &#x22;only&#x22;">
  Filter by **effective** NSFW status (`entity.nsfw OR its space's nsfwEffective`). `"include-all"` (default) adds no predicate; `"exclude"` drops effective-NSFW entities; `"only"` returns only effective-NSFW entities. On projects without the spaces bundle it applies against the entity's own `nsfw` flag alone. See [Entity NSFW flagging](/v8/data-models/entity#nsfw-flagging).
</ParamField>

<ParamField path="include" type="string | EntityInclude[]">
  Populate related fields. Accepted values: `"user"`, `"space"`, `"topComments"`, `"saved"`, `"files"`, `"grants"`.
</ParamField>

<ParamField path="topCommentsLimit" type="number">
  With `"topComments"` included: how many top comments per entity. Server default `1`, maximum `5`. Not sent when `include` doesn't contain `"topComments"`.
</ParamField>

<ParamField path="topCommentsSortByReaction" type="ReactionType">
  With `"topComments"` included: the reaction whose raw count ranks the top comments. Server default `"upvote"`. Not sent when `include` doesn't contain `"topComments"`.
</ParamField>

<SpaceReputationParams variant="context" field="path" />

## Returns

<ResponseField name="data" type="Entity[]">
  Array of entities for the current page. When `spaceReputation` is requested, each embedded author carries an added `spaceReputation` number. See [Reputation](/v8/data-models/reputation).
</ResponseField>

<ResponseField name="pagination.page" type="number">
  Current page number.
</ResponseField>

<ResponseField name="pagination.pageSize" type="number">
  Number of results per page.
</ResponseField>

<ResponseField name="pagination.totalPages" type="number">
  Total number of pages matching the filters.
</ResponseField>

<ResponseField name="pagination.totalItems" type="number">
  Total count of entities matching the filters (across all pages).
</ResponseField>

<ResponseField name="pagination.hasMore" type="boolean">
  `true` if there are additional pages available.
</ResponseField>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.