socialfi v0.1.12
Tapestry Social SDK
A TypeScript/JavaScript SDK for interacting with the Tapestry Social API. Build social features into your app with ease.
Features
- 🔑 Profile Management: Create, update, and manage user profiles with support for wallet addresses and phone numbers
- 👥 Social Graph: Handle follows/unfollows and social relationships
- 💬 Content & Comments: Manage user-generated content and interactions
- ❤️ Likes: Handle social engagement through likes
- 🔍 Search: Search for profiles and content
- 📱 Notifications: Send notifications to users (wallet notifications supported)
- 📊 Activity Feed: Get user activity feeds including follows, content, likes, comments, and new followers
- 💱 Swap Activity: Track swap transactions from followed wallets or specific tokens
- 🔓 Direct API Access: Access the underlying API client for advanced use cases
- 🎯 Identity Resolution: Find associated profiles across namespaces using phone numbers or wallet addresses
- 🛠️ Debug Mode: Optional debug logging for API calls
Installation
npm install socialfi
# or
yarn add socialfi
# or
pnpm add socialfi
Quick Start
import TapestryClient from 'socialfi';
// Initialize the client with your API key
const client = SocialFi({
baseURL: TAPESTRY_URL,
});
// Example: Create a profile
async function createProfile() {
try {
const profile = await socialfi.profiles.findOrCreateCreate(
{
apiKey: process.env.TAPESTRY_API_KEY || '',
},
{
walletAddress: 'YOUR_WALLET_ADDRESS',
username: 'johndoe',
bio: 'Hello World!',
blockchain: 'SOLANA',
},
);
console.log('Profile created:', profile);
} catch (error) {
console.error('Error creating profile:', error);
}
}
// Example: Follow a user
async function followUser() {
try {
await socialfi.followers.postFollowers(
{
apiKey: process.env.TAPESTRY_API_KEY || '',
},
{
startId: 'YOUR PROFILE ID',
endId: 'ANOTHER PROFILE ID',
},
);
console.log('Successfully followed user');
} catch (error) {
console.error('Error following user:', error);
}
}
API Documentation
Configuration
The TapestryClient
constructor accepts the following configuration options:
interface TapestryConfig {
apiKey: string; // Required: Your Tapestry API key
baseURL?: string; // Optional: Override the default API URL
debug?: boolean; // Optional: Enable debug logging
}
TypeScript Support
This SDK is written in TypeScript and provides comprehensive type definitions for all API responses and parameters. Import types directly:
import TapestryClient, {
// Profile types
ProfileSchema,
FindOrCreateProfileSchema,
UpdateProfileSchema,
// Content types
ContentSchema,
FindOrCreateContentSchema,
// Comment types
CreateCommentSchema,
// Social types
CreateFollowSchema,
// Activity types
FeedDetailData,
// Search types
SearchProfilesResponseSchema,
// Common types
CustomPropertySchema,
TapestryConfig,
} from 'socialfi';
Best Practices
API Key Security: Never expose your API key in client-side code. Use environment variables and server-side authentication.
Error Handling: Always implement proper error handling for API calls.
Rate Limiting: Be mindful of API rate limits and implement appropriate retry logic.
Custom Properties: Use custom properties to extend functionality while maintaining compatibility.
Debug Mode: Enable debug mode during development to log API calls for troubleshooting.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Support
- Documentation: Tapestry Documentation
- Issues: GitHub Issues
- Email: support@usetapestry.dev
License
This project is licensed under the MIT License - see the LICENSE file for details.