Quickstart
Get from install to first API call in a few minutes.
Install
bun add @coin-communities/sdk
# npm add @coin-communities/sdk
# yarn add @coin-communities/sdkPeer dependencies (react, react-native, @tanstack/react-query) are all optional —
install only the ones your project uses.
Get an API key
Most operations require an API key sent as the x-api-key request header.
- Register a business account:
import { api } from '@coin-communities/sdk';
await api.register({
body: {
businessName: 'My App',
email: 'you@example.com',
password: 'a-strong-password',
},
});
// → confirm the verification email, then login:
const { data } = await api.login({
body: { email: 'you@example.com', password: 'a-strong-password' },
});
const jwt = data?.token;- Create an API key (requires the JWT from login):
import { configureApi, api } from '@coin-communities/sdk';
// Use the JWT to authenticate the key-creation call
configureApi({
baseUrl: 'https://api.coin-communities.xyz',
auth: jwt,
});
const { data: keyData } = await api.createApiKey({
body: { name: 'production' },
});
// Store this immediately — the full key is shown only once
const apiKey = keyData?.key;Configure
Once you have an API key, configure the client once at startup:
import { configureApi } from '@coin-communities/sdk';
configureApi({
baseUrl: 'https://api.coin-communities.xyz',
headers: { 'x-api-key': apiKey },
});For business management operations that require a bearer JWT, set auth as well:
configureApi({
baseUrl: 'https://api.coin-communities.xyz',
headers: { 'x-api-key': apiKey },
auth: () => sessionStorage.getItem('business_jwt') ?? '',
});Make a request
All generated operations live under the api namespace. By default they return
{ data, error, response } — pass { throwOnError: true } to throw instead.
import { api } from '@coin-communities/sdk';
// Read a community (requires API key)
const { data, error } = await api.getCommunity({
path: { token_address: '7eYw...mintAddr' },
});
if (error) {
console.error('failed', error.message);
} else {
console.log(data.community.tokenAddress);
}Post a message (the wallet must be linked to the authenticated user):
await api.postMessage({
path: { token_address: '7eYw...mintAddr' },
body: {
content: 'gm',
chainId: 'solana', // 'solana' | 'ethereum' | 'base' | 'bsc'
walletAddress: 'YourWalletPublicKey',
},
throwOnError: true,
});Browse the public feed (no signed-in user required — still needs your API key):
const { data } = await api.getFeedPublic();
console.log(data?.items);User sign-in (Twitter OAuth)
End-users authenticate via Twitter. The flow uses your API key throughout:
// 1. Get the OAuth URL
const { data: authData } = await api.twitterAuthUrl({
query: { redirectUrl: 'https://your-app.com/callback' },
});
// → redirect the user to authData.authUrl
// 2. After the redirect, exchange the challengeCode
const { data: session } = await api.twitterChallengeExchange({
body: { challengeCode: searchParams.get('challengeCode') },
});
const { accessToken, refreshToken, user } = session;Store accessToken and pass it via the auth option (or Authorization: Bearer header)
for subsequent user-scoped calls.
Next steps
- SDK Reference — every operation by domain, with request/response types.
- React Query — pre-baked hooks and
queryKeysfor React apps.