Grapevine SDK
Easy-to-use SDK for the Grapevine API. Create and manage content feeds with built-in authentication and x402 micropayment handling.
Features
✨ Simple API - Clean, intuitive interface for all operations
🔐 Flexible Authentication - Private keys or wagmi wallet integration
💰 Transparent Payments - x402 micropayments handled automatically
🎯 Smart Defaults - Auto-detect network, MIME types, and more
📦 Batch Operations - Efficiently handle multiple entries
⚛️ React Integration - Built-in hooks for React apps with wagmi
📝 Full TypeScript Support - Complete type definitions included
🌐 Browser Compatible - Works in Node.js and browser environments
Installation
bun add @pinata/grapevine-sdkQuick Start
import { GrapevineClient } from '@pinata/grapevine-sdk';
// Initialize the SDK
const grapevine = new GrapevineClient({
network: 'testnet', // or 'mainnet'
privateKey: process.env.PRIVATE_KEY
});
// Create a feed (one line!)
const feed = await grapevine.feeds.create({
name: 'My Content Feed',
description: 'Created with Grapevine SDK',
tags: ['content', 'marketplace']
});
// Add an entry (auto-detects MIME type)
const entry = await grapevine.entries.create(feed.id, {
content: 'Hello World!',
title: 'First Entry',
is_free: true
});
console.log(`Feed created: ${feed.id}`);
console.log(`Entry created: ${entry.id}`);SDK Resources
Client Setup
- Installation - Complete setup guide
- Configuration - Client configuration options
- React & Wagmi - React integration with wallet connection
- Error Handling - Comprehensive error handling guide
Feeds
- feeds.create() - Create a new feed
- feeds.list() - List feeds with filters
- feeds.get() - Get feed by ID
- feeds.update() - Update feed properties
- feeds.delete() - Delete a feed
- feeds.myFeeds() - Get your feeds
- feeds.paginate() - Async pagination
Entries
- entries.create() - Create an entry
- entries.list() - List entries
- entries.get() - Get entry by ID
- entries.delete() - Delete an entry
- entries.batchCreate() - Batch creation
- entries.paginate() - Async pagination
Wallets
- wallets.get() - Get wallet by ID
- wallets.getByAddress() - Get by Ethereum address
- wallets.getStats() - Get wallet statistics
- wallets.update() - Update wallet profile
- wallets.getMe() - Get current wallet
Transactions
- transactions.list() - List transactions
- transactions.get() - Get by ID
- transactions.getByHash() - Get by blockchain hash
- transactions.paginate() - Async pagination
Leaderboards
- leaderboards.trending() - Trending feeds
- leaderboards.mostPopular() - Most purchased
- leaderboards.topRevenue() - Top earners
- leaderboards.topFeeds() - Most content
- leaderboards.topProviders() - Top creators
- leaderboards.topBuyers() - Top collectors
- leaderboards.categoryStats() - Category stats
- leaderboards.recentEntries() - Latest entries
Categories
- categories.list() - List all categories
- categories.get() - Get category by ID
- categories.getAll() - Get all categories
Client Utilities
- getWalletAddress() - Get current wallet address
- getNetwork() - Get current network name
- isTestNetwork() - Check if using testnet
Client Utility Methods
The GrapevineClient provides utility methods to inspect the current configuration:
const grapevine = new GrapevineClient({
network: 'testnet',
privateKey: process.env.PRIVATE_KEY
});
// Get wallet address
const address = grapevine.getWalletAddress();
console.log('Wallet:', address); // "0x742d35..."
// Get network
const network = grapevine.getNetwork();
console.log('Network:', network); // "base-sepolia"
// Check if testnet
const isTestnet = grapevine.isTestNetwork();
console.log('Is testnet:', isTestnet); // truegetWalletAddress(): string
Returns the wallet address for the authenticated client.
const address = grapevine.getWalletAddress();
// Returns: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"Returns: The wallet address as a hex string, or throws if not authenticated.
getNetwork(): string
Returns the blockchain network name the client is configured for.
const network = grapevine.getNetwork();
// Returns: "base-sepolia" (testnet) or "base" (mainnet)Returns: Network identifier string.
isTestNetwork(): boolean
Checks if the client is configured for a test network.
const isTest = grapevine.isTestNetwork();
// Returns: true for testnet, false for mainnetReturns: true if using testnet, false if using mainnet.
Additional Utility Methods
The GrapevineClient provides several utility methods for common operations:
categories.getAll(): Promise<Category[]>
Retrieve all available content categories.
const categories = await grapevine.categories.getAll();
categories.forEach(category => {
console.log(`${category.name}: ${category.description || 'No description'}`);
});Returns: Array of Category objects with id, name, and optional description.
See: Complete categories documentation for detailed usage examples.
Examples
See complete working examples in the Examples section.