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

# Querying content

> Read content from your client apps using REST, GraphQL, and the mobile SDKs

Metabind exposes content through three query surfaces. Each suits a different consumer; all return the same content model.

| API                        | Best for                                                          |
| -------------------------- | ----------------------------------------------------------------- |
| REST                       | Server-to-server, bulk operations, simple integrations            |
| GraphQL                    | Web and mobile clients needing flexible joins and shape selection |
| Mobile SDKs (iOS, Android) | Native apps with offline caching, BindJS rendering                |

This page is a tour of each surface. Deeper API references live in the REST API and GraphQL API tabs.

## REST

Endpoint shape:

```
GET https://api.metabind.ai/v1/orgs/{org}/projects/{project}/content
GET https://api.metabind.ai/v1/orgs/{org}/projects/{project}/content/{contentId}
GET https://api.metabind.ai/v1/orgs/{org}/projects/{project}/content/search?q=...
```

Authenticate with a Bearer token:

```bash theme={null}
curl -H "Authorization: Bearer mb_..." \
  "https://api.metabind.ai/v1/orgs/oak-ivory/projects/main/content?contentType=article&limit=10"
```

REST works well for:

* Backend services pulling content for SSR.
* Cron jobs syncing content to other systems.
* Bulk operations (import/migrate/archive).

For the full REST API, see the **REST API** tab.

## GraphQL

Endpoint:

```
POST https://api.metabind.ai/v1/orgs/{org}/projects/{project}/graphql
```

Example query:

```graphql theme={null}
query GetArticles {
  contentList(contentType: "article", limit: 10) {
    items {
      id
      title
      body
      heroImage {
        url
        width
        height
      }
      author {
        name
      }
      publishedAt
    }
  }
}
```

GraphQL is the recommended pathway for:

* Web apps that need to fetch only the fields they render.
* Mobile apps that want to batch related queries.
* Any client where reducing roundtrips matters.

Subscriptions are also supported — see [GraphQL: Subscriptions](/graphql/subscriptions/overview) for live content updates.

## Native SDKs

The iOS and Android SDKs wrap this GraphQL API with a local cache and BindJS rendering. On iOS, `MetabindClient` exposes `async` fetchers — `fetchContent(id:)` for a single entry and `fetchContents(typeId:limit:)` for a list — plus `streamContent(id:)` and `subscribeToContent(id:)` for cache-then-network and live streams. The Android SDK exposes coroutine and `Flow` equivalents through `ComponentRepository`.

For installation, configuration, and rendering, see the Mobile SDKs:

<CardGroup cols={2}>
  <Card title="iOS SDK" icon="apple" href="/content/mobile-sdks/ios-sdk">
    `metabind-apple` — fetch and render content with SwiftUI.
  </Card>

  <Card title="Android SDK" icon="android" href="/content/mobile-sdks/android-sdk">
    `metabind-android` — fetch and render content with Compose.
  </Card>
</CardGroup>

## Choosing draft or production

Each query surface accepts a `?preview=true` flag (REST) or a `preview` argument (GraphQL) to query draft content instead of published:

```
GET .../content?preview=true&contentType=article
```

```graphql theme={null}
query { contentList(contentType: "article", preview: true) { ... } }
```

Use draft for editor previews and staging environments. Default to published in production.

## Caching

Caching is on by default at the CDN edge for published content. Cache keys include the project, content type, query parameters, and locale.

Invalidation:

* **Automatic.** Publishing or unpublishing an entry invalidates that entry's cached responses within seconds.
* **Webhook-driven.** Custom invalidation triggers from your own systems (rare).

The iOS and Android SDKs add a local cache on top — entries persist between app launches and update via background refresh.

## Pagination

Two patterns:

* **Offset/limit.** `?limit=10&offset=20` — easy, fine for small collections.
* **Cursor.** `?after=<cursor>&limit=10` — recommended for large collections; stable under additions.

GraphQL supports both via `Connection` types. The SDKs paginate automatically when you iterate over results.

## Filtering

REST supports filter parameters per content type. GraphQL exposes typed filter inputs:

```graphql theme={null}
query {
  contentList(
    contentType: "article",
    filter: { tag: { in: ["featured", "running"] }, publishedAt: { gte: "2026-01-01" } }
  ) {
    items { id, title }
  }
}
```

For complex queries, save a search and reuse it via the [saved searches API](/rest/saved-searches/overview).

## Resolved content

Content with references can be returned **resolved** — references inlined to one or more levels of depth. Avoids round trips for client rendering:

```graphql theme={null}
query {
  content(id: "abc-123") {
    title
    author {
      name
      avatar { url }     # joined automatically
    }
  }
}
```

REST has a [`/content/resolved`](/rest/content/resolved) endpoint with similar behavior.

## When to use which

A few rules of thumb:

* **Native mobile app?** Use the iOS/Android SDK. They handle caching, offline, and pair cleanly with BindJS.
* **Web app?** Use GraphQL. Flexible queries, single-request data fetching, subscriptions for live updates.
* **Backend service?** REST. Simple, well-cached, works with any HTTP client.
* **MCP App?** Use a Data Tool that calls REST or GraphQL. The Data Tool pattern abstracts content fetching behind an AI-callable surface.

## Related

<CardGroup cols={2}>
  <Card title="REST API" icon="code" href="/rest/introduction">
    Full REST reference.
  </Card>

  <Card title="GraphQL API" icon="diagram-project" href="/graphql/overview">
    Schema, queries, subscriptions.
  </Card>

  <Card title="Mobile SDKs" icon="mobile" href="/content/mobile-sdks/overview">
    iOS and Android client libraries.
  </Card>

  <Card title="AI content creation" icon="wand-magic-sparkles" href="/content/ai-content-creation/overview">
    AI-driven content workflows.
  </Card>
</CardGroup>
