This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the @replyke/node package - the official Node.js SDK for Replyke. It's designed for server-side Node.js environments where React is not available or needed, such as server actions, backend APIs, scheduled jobs, webhooks, and CLI tools.
Package Name: @replyke/node Version: 7.0.0 Type: Node.js SDK library (published to npm)
# Build the package
pnpm build
# Generate TypeScript declaration files
pnpm build:types
# Build both (runs before publishing)
pnpm prepare
# Publish to npm with beta tag
pnpm publish-beta
# Publish to npm production
pnpm publish-prodThe SDK is organized into 5 main API modules:
src/
├── core/
│ └── client.ts # HTTP client with axios instances
├── interfaces/ # TypeScript type definitions
│ ├── Entity.ts
│ ├── Comment.ts
│ ├── User.ts
│ ├── List.ts
│ ├── HostedApp.ts
│ ├── Connection.ts
│ ├── Follow.ts
│ ├── Mention.ts
│ └── AppNotification.ts
├── modules/
│ ├── entities/ # Entity CRUD operations (8 functions)
│ ├── comments/ # Comment CRUD operations (5 functions)
│ ├── users/ # User operations (2 functions)
│ ├── lists/ # List CRUD operations (8 functions)
│ └── hosted-apps/ # Hosted app operations (1 function)
└── index.ts # Main entry point with ReplykeClient class
The SDK uses three axios instances for different API endpoints:
- projectInstance:
https://api.replyke.com/api/v5/{projectId}- Main project-scoped API - internalInstance:
https://api.replyke.com/internal- Internal operations (verification, admin) - baseInstance:
https://api.replyke.com- Base API endpoint
Authentication Headers:
Authorization: Bearer {apiKey}X-Replyke-Project-ID: {projectId}X-Replyke-Internal: true(for internal operations)
import { ReplykeClient } from '@replyke/node';
const client = await ReplykeClient.init({
projectId: "your-project-id",
apiKey: "your-api-key",
isInternal?: boolean // optional
});
// Automatically verifies credentials on init via /service/verify endpointEntities are the core content objects (posts, articles, products, listings, etc.).
Functions:
client.entities.createEntity(data)- Create a new entityclient.entities.fetchEntity({ entityId })- Fetch by IDclient.entities.fetchEntityByForeignId({ foreignId })- Fetch by external system IDclient.entities.fetchEntityByShortId({ shortId })- Fetch by short/shareable IDclient.entities.fetchManyEntities(filters)- Advanced querying with filtersclient.entities.updateEntity(data)- Update entityclient.entities.incrementEntityViews({ entityId })- Track view countclient.entities.deleteEntity({ entityId })- Delete entity
Key Features:
- Foreign ID support for integration with existing systems
- Geo-location (GeoJSON Point format)
- Upvotes/downvotes with automatic "hotness" scoring
- Comments and replies counting
- Keywords/tags
- Attachments (flexible JSON structure)
- User mentions
- Custom metadata (up to 10KB)
- Top comment caching
Advanced Filtering (fetchManyEntities):
- Sorting: hot, top, controversial
- Time frames: hour, day, week, month, year, all
- Keywords: includes/excludes arrays
- Metadata: includes/excludes/exists/doesNotExist filters
- Text search: title and content filtering
- Media: presence/absence of attachments
- Geo-location: latitude, longitude, radius filtering
- User-specific: filter by userId, followedOnly
- Pagination: page and limit parameters
Functions:
client.comments.createComment({ userId, entityId, content, ... })- Create comment or replyclient.comments.fetchComment({ commentId })- Fetch by IDclient.comments.fetchCommentByForeignId({ foreignId })- Fetch by external IDclient.comments.updateComment(data)- Update commentclient.comments.deleteComment({ commentId })- Delete comment (soft delete)
Key Features:
- Threaded replies (parentId support)
- Referenced comments for quote-replies
- GIF support with preview URLs and aspect ratios
- User mentions
- Upvotes/downvotes
- Custom metadata
- Foreign ID support
- Soft deletes (deletedAt, parentDeletedAt timestamps)
Functions:
client.users.fetchUserById({ userId })- Fetch user by Replyke IDclient.users.fetchUserByForeignId({ foreignId })- Fetch by external system ID
User Features:
- Roles: admin, moderator, visitor
- Profile data: email, name, username, avatar, bio (300 char max)
- Birthdate and geo-location
- Reputation score (auto-managed based on activity)
- Verification status
- Active/inactive account status
- Last activity tracking
- Public and secure metadata
- Suspension tracking
Lists allow users to create collections of entities (e.g., "Saved Posts", "Favorites", "Reading List").
Functions:
client.lists.createNewList({ userId, listId, listName })- Create new listclient.lists.fetchRootList(data)- Fetch root-level listclient.lists.fetchSubLists(data)- Fetch child listsclient.lists.isEntitySaved(data)- Check if entity is in listclient.lists.updateList(data)- Update listclient.lists.addEntityToList(data)- Add entity to listclient.lists.removeEntityFromList(data)- Remove entity from listclient.lists.deleteList({ listId })- Delete list
Key Features:
- Hierarchical structure (parent/child lists)
- User-scoped collections
- Entity membership tracking
Functions:
client.hostedApps.fetchHostedApp(data)- Fetch hosted app information
All major resources support foreign IDs, allowing you to map your existing system's IDs to Replyke IDs. This enables seamless integration on top of existing platforms.
Most resources support custom metadata (10KB limit) for storing project-specific data without modifying the core schema.
Entities and users support geo-location data in GeoJSON Point format for location-based features and filtering.
Resources use deletedAt timestamps rather than hard deletes, preserving data integrity and allowing for recovery.
Functions are bound to the HTTP client instance at initialization, providing a clean API: client.entities.createEntity(data) instead of passing the client explicitly.
import { ReplykeClient } from '@replyke/node';
// Initialize client
const client = await ReplykeClient.init({
projectId: process.env.REPLYKE_PROJECT_ID,
apiKey: process.env.REPLYKE_API_KEY
});
// Create an entity
const entity = await client.entities.createEntity({
foreignId: 'post-123',
title: 'My First Post',
content: 'This is the content of my post',
keywords: ['tutorial', 'nodejs'],
userId: 'user-456',
metadata: {
category: 'technology',
featured: true
}
});
// Fetch entities with advanced filtering
const trendingPosts = await client.entities.fetchManyEntities({
sort: 'hot',
timeframe: 'week',
keywords: { includes: ['nodejs'] },
limit: 10,
page: 1
});
// Create a comment
const comment = await client.comments.createComment({
entityId: entity.id,
userId: 'user-789',
content: 'Great post! Thanks for sharing.'
});
// Fetch user
const user = await client.users.fetchUserById({
userId: 'user-456'
});- Build Tool: tsup
- Output Formats: CommonJS and ESM (dual package)
- Type Declarations: Generated via TypeScript compiler
- Target: ESNext
- Entry Point:
src/index.ts
dist/
├── index.js # Main CommonJS/ESM bundle
└── index.d.ts # TypeScript declarations
# Beta release
pnpm publish-beta
# Production release
pnpm publish-prodPackage Exports:
- CommonJS:
dist/index.js - ES Modules:
dist/index.js - Types:
dist/index.d.ts
This SDK is ideal for:
- Server-Side Rendering - Next.js server actions, server components
- Backend APIs - Express, Fastify, Koa backend services
- Scheduled Jobs - Cron jobs, background workers, task queues
- CLI Tools - Command-line utilities for content management
- Migration Scripts - Bulk data operations and imports
- Webhooks - Event handlers for external integrations
- Admin Tools - Moderation dashboards, content management
- Edge Functions - Cloudflare Workers, Vercel Edge Functions
Essentially any Node.js environment where you need to interact with Replyke's social features without a React frontend.
- TypeScript: Strict mode enabled
- Dependencies: Only axios for HTTP requests
- API Version: Uses v7 API endpoints
- Authentication: Bearer token with project ID header
- Error Handling: Axios error responses
- Type Safety: Full TypeScript support with exported interfaces
- This SDK is on v7 (v7.0.0)
- Requires valid project ID and API key from Replyke dashboard
- Credentials are verified on initialization
- All API calls are project-scoped
- Rate limiting applies based on your Replyke plan