---
name: membit
description: Integrate Membit's real-time social context API into the project. Use when the user says "membit", "social context", "trending topics", "cluster search", "search posts", "real-time context", "social sentiment", or asks about fetching live social conversation data.
---

# Membit Integration

Membit is a Context-as-a-Service (CaaS) platform that provides AI agents with real-time knowledge from global social conversations (X/Twitter, Farcaster, Bluesky). Use it to power features with live social sentiment, trending topics, and discussion context.

## API Overview

**Base URL:** `https://api.membit.ai/v1`
**Auth:** `X-Membit-Api-Key` header (get key at membit.ai, sign in with GitHub/Google)
**Credits:** 500 on signup + 100/day refresh (beta)

Three endpoints:

| Endpoint | Method | Cost | Purpose |
|----------|--------|------|---------|
| `/clusters/search` | GET | 3 credits | Find trending discussion clusters by query or category |
| `/clusters/info` | GET | 2 credits | Get detailed cluster context with representative posts |
| `/posts/search` | GET | 1 credit | Find individual posts matching a semantic query |

## Quick Integration

### TypeScript SDK
```bash
npm install @bandprotocol/membit
```
```typescript
import { MembitClient } from "@bandprotocol/membit";

const client = new MembitClient({ apiKey: process.env.MEMBIT_API_KEY });

// Search trending clusters
const clusters = await client.clusters.search({ q: "solana defi", limit: 10 });

// Get cluster details with posts
const info = await client.clusters.info({ label: clusters[0].label, limit: 20 });

// Search individual posts
const posts = await client.posts.search({ q: "token launch", limit: 10 });
```

### Python SDK
```bash
pip install membit-python
```
```python
from membit import MembitClient

client = MembitClient(api_key="YOUR_KEY")

clusters = client.clusters.search(q="solana defi", limit=10)
info = client.clusters.info(label=clusters[0].label, limit=20)
posts = client.posts.search(q="token launch", limit=10)
```

### Direct REST
```bash
curl -H "X-Membit-Api-Key: YOUR_KEY" \
  "https://api.membit.ai/v1/clusters/search?q=solana+defi&limit=10&format=json"
```

## Use Cases for This Project

Membit + Bags API integration ideas:

1. **Sentiment-driven token launches** — Search social clusters for trending topics, auto-generate token metadata based on viral conversations
2. **Social trading signals** — Monitor posts/clusters for token mentions, trigger trades via Bags swap API
3. **Fee sharing with influencers** — Find top posts about a token, configure fee sharing with those authors
4. **Trending topic dashboard** — Display real-time social context alongside token analytics
5. **AI agent with live context** — Agent that reads social sentiment before making token launch/trade decisions

## References (load on demand)

- `references/membit-api.md` — Complete API reference with all endpoints, parameters, response schemas, and architecture details
