@coinchat/sdk
v0.1.0
Published
Official CoinChat API client for token-gated communities
Maintainers
Readme
@coinchat/sdk
Official TypeScript/JavaScript client for the CoinChat public API.
When baseUrl is omitted, the client uses https://coinchat.me.
Install
npm install @coinchat/sdkFrom this monorepo (local development):
npm install ./packages/coinchat-sdkGet an API key
- Open your community in CoinChat → Dashboard → API & Integrations
- Click Generate key (community admin required)
- Copy
cc_live_…— it is shown once
Quick start
import { CoinChat } from '@coinchat/sdk';
const cc = new CoinChat(process.env.COINCHAT_API_KEY!, {
baseUrl: 'http://localhost:3000', // your CoinChat deployment
});
// Verify wallet holds enough tokens for a room gate
const { access } = await cc.access.verify('YOUR_MINT_ADDRESS', {
wallet: '7xKQ…9fPa',
room: 'holders-lounge',
});
if (access.granted) {
console.log('Roles:', access.roles);
}
// List rooms
const { categories } = await cc.rooms.list('YOUR_MINT_ADDRESS');
// Post a bot message (requires messages:write scope)
await cc.messages.create('YOUR_MINT_ADDRESS', {
room: 'general',
text: 'Hello from my backend',
authorHandle: 'my_bot',
authorName: 'My Bot',
});API reference (v1)
| Method | Scope | Description |
|--------|--------|-------------|
| GET /api/v1 | — | API metadata |
| GET /api/v1/communities/{mint} | communities:read | Community info |
| GET /api/v1/communities/{mint}/rooms | rooms:read | Room categories |
| GET /api/v1/communities/{mint}/messages | messages:read | Chat history |
| POST /api/v1/communities/{mint}/messages | messages:write | Post message |
| GET /api/v1/communities/{mint}/members | members:read | Members (Coin Communities) |
| POST /api/v1/communities/{mint}/access/verify | access:verify | On-chain balance gate check |
Authentication: Authorization: Bearer cc_live_…
Webhooks
Configure endpoints in the Dashboard. Events include message.created. Verify payloads with the X-CoinChat-Signature header (t=<unix>,v1=<hmac-sha256>).
Scopes
communities:read,rooms:read,messages:read,messages:write,members:read,access:verifyadmin— all of the above
