> ## 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

> [!NOTE]
>
> **Requires the `entities` bundle.** A project without the entities bundle returns `403 database/tables-not-available`. See [Bundles](https://docs.sublay.io/v7/bundles.md).

## 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`](https://docs.sublay.io/v7/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

**page** `number`

Page number (1-indexed). Defaults to `1`.

**limit** `number`

Results per page. Defaults to server default.

**sortBy** `string`

Field to sort by. Options: `"createdAt"`, `"top"`, `"hot"`, `"controversial"`, or `"metadata.<property>"` to sort by a metadata field.

**sortByReaction** `string`

Sort by a specific reaction type count. Use with `sortBy: "reaction"`.

**sortDir** `string`

Sort direction: `"asc"` or `"desc"`.

**sortType** `string`

Sort algorithm type. Options: `"auto"`, `"numeric"`, `"text"`, `"boolean"`, `"timestamp"`. Used when sorting by a metadata field.

**timeFrame** `string`

Filter entities to a time window. Options: `"day"`, `"week"`, `"month"`, `"year"`.

**sourceId** `string`

Filter to entities associated with a specific source ID.

**spaceId** `string`

Filter to entities in a specific space.

**userId** `string`

Filter to entities created by a specific user.

**followedOnly** `boolean`

If `true`, return only entities from users the authenticated user follows.

**keywordsFilters** `object`

Filter by keywords. See [Entity List Filters](https://docs.sublay.io/v7/sdk/entity-lists/filters.md) for the full filter schema.

**titleFilters** `object`

Filter by title content. See [Entity List Filters](https://docs.sublay.io/v7/sdk/entity-lists/filters.md).

**contentFilters** `object`

Filter by body content. See [Entity List Filters](https://docs.sublay.io/v7/sdk/entity-lists/filters.md).

**attachmentsFilters** `object`

Filter by attachments data. See [Entity List Filters](https://docs.sublay.io/v7/sdk/entity-lists/filters.md).

**locationFilters** `object`

Filter by geographic proximity. See [Entity List Filters](https://docs.sublay.io/v7/sdk/entity-lists/filters.md).

**metadataFilters** `object`

Filter by metadata fields. See [Entity List Filters](https://docs.sublay.io/v7/sdk/entity-lists/filters.md).

**nsfwFilter** `"include-all" | "exclude" | "only"`

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](https://docs.sublay.io/v7/data-models/entity.md#nsfw-flagging).

**include** `string | string[]`

Populate related fields. Accepted values: `"user"`, `"space"`, `"topComment"`, `"saved"`, `"files"`, `"grants"`.

**spaceReputation** `object`

Opt-in. Adds a `spaceReputation` number to each returned user,
scoped to a single space. Requires the `reputation` bundle.
The `reputation` total is always present regardless;
`spaceReputation` is purely additive and only appears when you
pass this object. **This object is the primary form** — it
replaces the deprecated flat props below. See the
[Reputation data model](https://docs.sublay.io/v7/data-models/reputation.md) for the
full contract.

**spaceReputation**

Which bucket to read. One of: a space **`<uuid>`**
(that space's bucket), **`"none"`** (the
project-general, space-less bucket), or
**`"context"`** (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
`general` / `null` aliases are rejected (400).
Missing buckets read as `0`.
Only honored when `spaceId` is an explicit space `<uuid>`.
When `true`, `spaceReputation` is the
**subtree sum** — the named space plus all of its
descendant spaces (the root space's own bucket included). Ignored for
`"none"`; not allowed with `"context"`.

**spaceReputationId** `string` *deprecated*

**Deprecated** — use the `spaceReputation`
object instead. The flat form of `spaceReputation.spaceId`.
Still accepted (the object wins if both are passed); removal is a later
major version. Accepts a space `<uuid>`, `"none"`, or
`"context"`.

**spaceReputationDescendants** `boolean` *deprecated*

**Deprecated** — use
`spaceReputation.includeDescendants` instead. The flat form,
only honored alongside an explicit `spaceReputationId` `<uuid>`.

## Returns

**data** `Entity[]`

Array of entities for the current page. When `spaceReputation` is requested, each embedded author carries an added `spaceReputation` number. See [Reputation](https://docs.sublay.io/v7/data-models/reputation.md).

**pagination.page** `number`

Current page number.

**pagination.pageSize** `number`

Number of results per page.

**pagination.totalPages** `number`

Total number of pages matching the filters.

**pagination.totalItems** `number`

Total count of entities matching the filters (across all pages).

**pagination.hasMore** `boolean`

`true` if there are additional pages available.


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