Skip to main content

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.

The iOS and Android SDKs are the native client libraries for Metabind content. They wrap the GraphQL content API, add local caching and offline support, and integrate with the BindJS runtime so you can render content through native UI without a separate composition step.

The two-layer architecture

The mobile SDKs are a content client (metabind-apple / metabind-android) paired with a BindJS rendering layer (bindjs-apple / bindjs-android).
The content layer fetches data; the BindJS layer renders it. They’re decoupled — you can use one without the other — but they’re paired in the templates and sample apps for the simplest case.

iOS SDK

Install via Swift Package Manager:
https://github.com/metabindai/metabind-apple
Initialize and fetch:
import Metabind

let client = Metabind.Client(
  organizationId: "oak-ivory",
  projectId: "main",
  apiKey: ProcessInfo.processInfo.environment["MB_API_KEY"]!
)

let articles = try await client.content.list(
  contentType: "article",
  limit: 10
)
Render via BindJS:
import BindJS

ForEach(articles) { article in
  // Render the article through its bound layout component
  BindJSView(content: article)
}
The SDK auto-resolves the content type’s bound component (defined in MCP App Studio) and renders it. For custom rendering, use the typed model and write your own SwiftUI. For details, see the iOS SDK guide.

Android SDK

Install via Maven:
implementation("ai.metabind:client:1.0.0")
Initialize and fetch:
val client = Metabind.Client(
  organizationId = "oak-ivory",
  projectId = "main",
  apiKey = BuildConfig.METABIND_API_KEY
)

val articles = client.content.list(
  contentType = "article",
  limit = 10
)
Render via BindJS:
@Composable
fun ArticleList(articles: List<Article>) {
  LazyColumn {
    items(articles) { article ->
      BindJSCompose(content = article)
    }
  }
}
Same shape as iOS, Kotlin idioms. See the Android SDK guide.

Caching and offline

Both SDKs ship with local caching:
  • Memory cache. Hot data, instant access during a session.
  • Persistent cache. Survives app restarts via Apollo’s normalized SQLite store.
  • Offline queue. Mutations made offline queue and replay when connectivity returns.
For most apps, the defaults are right. To customize:
let client = Metabind.Client(
  organizationId: "oak-ivory",
  projectId: "main",
  apiKey: "...",
  cachePolicy: .returnCacheDataElseFetch,
  cacheDuration: .hours(1)
)

Live updates via subscriptions

The SDKs expose GraphQL subscriptions for live content updates:
let subscription = client.content.subscribeToUpdates(
  contentType: "article"
)

for try await change in subscription {
  switch change {
    case .created(let article): // ...
    case .updated(let article): // ...
    case .deleted(let id):       // ...
  }
}
Updates push over WebSocket; the SDK handles reconnection.

Authentication patterns

A few patterns:
  • Static API key (dev). Hardcode for local development; rotate before shipping.
  • Per-user token (production). Your backend mints a Metabind token per user; the SDK uses it. Track per-user usage and revoke individually.
  • Anonymous read-only token. For apps that read public content without per-user auth.
The SDK accepts a token-fetcher closure for async refresh:
let client = Metabind.Client(
  ...,
  tokenProvider: {
    await MyBackend.fetchMetabindToken()
  }
)

Asset handling

Asset URLs returned by the SDKs point at the Metabind CDN. The CDN supports on-the-fly transformations via query parameters:
https://cdn.metabind.ai/.../image.jpg?w=600&q=80&fmt=webp
The SDKs include helpers for common transformations:
asset.url(width: 600, quality: 80, format: .webp)
For 3D models and video, the SDKs handle streaming and progressive loading.

Testing

Both SDKs support a mock mode for tests:
let client = Metabind.Client.mock(
  contentTypes: [...],
  entries: [...]
)
Set up the in-memory state, run your app under test, assert behavior. No network calls, no fixtures to clean up.

When to use the SDK vs. raw GraphQL

The SDK gives you:
  • Typed content models
  • Cache management
  • Subscriptions and offline support
  • BindJS integration
  • Mock mode
If your app needs all of those, use the SDK. If you only need a single content read for a server-side render or a backend job, raw GraphQL via your platform’s HTTP client is fine.

iOS SDK guide

Full iOS SDK reference.

Android SDK guide

Full Android SDK reference.

Querying content

Other ways to read content.

GraphQL API

The underlying GraphQL surface.