Skip to content

entries.get()

Retrieve a specific entry from a feed by its ID.

Signature

entries.get(feedId: string, entryId: string): Promise<Entry>

Parameters

feedId

  • Type: string
  • Required: Yes
  • Description: The UUID of the feed containing the entry

entryId

  • Type: string
  • Required: Yes
  • Description: The UUID of the entry to retrieve

Returns

  • Type: Promise<Entry>
interface Entry {
  id: string;
  feed_id: string;
  cid: string;                     // Content identifier
  mime_type: string;
  title?: string;
  description?: string;
  metadata?: string;               // JSON string of additional metadata
  tags: string[];
  is_free: boolean;
  expires_at?: number;             // Unix timestamp expiration
  is_active: boolean;
  total_purchases: number;
  total_revenue: string;           // Revenue in wei
  created_at: number;
  updated_at: number;
}

Usage

Basic Example

const entry = await grapevine.entries.get(feedId, entryId);
 
console.log('Title:', entry.title);
console.log('Free:', entry.is_free);
console.log('Active:', entry.is_active);
console.log('MIME Type:', entry.mime_type);
console.log('Created:', new Date(entry.created_at * 1000));

Check Access Status

const entry = await grapevine.entries.get(feedId, entryId);
 
if (entry.is_free) {
  console.log('Free content, Content ID:', entry.cid);
} else {
  console.log('Paid content, purchase required');
  console.log('Total purchases:', entry.total_purchases);
  console.log('Revenue generated:', entry.total_revenue);
}

Handle Different Content Types

const entry = await grapevine.entries.get(feedId, entryId);
 
console.log('Content type:', entry.mime_type);
console.log('Content ID for content:', entry.cid);
 
// Access content from secure storage
const contentUrl = `https://gateway.grapevine.markets/${entry.cid}`;
 
// Metadata handling
if (entry.metadata) {
  const metadata = JSON.parse(entry.metadata);
  console.log('Entry metadata:', metadata);
}

With Content Access

const entry = await grapevine.entries.get(feedId, entryId);
 
console.log('Content ID:', entry.cid);
// Access via secure gateway
const contentUrl = `https://gateway.grapevine.markets/${entry.cid}`;
console.log('Content URL:', contentUrl);

Purchase Flow

async function getEntryWithPurchase(feedId: string, entryId: string) {
  try {
    // First attempt to get entry
    let entry = await grapevine.entries.get(feedId, entryId);
    
    if (!entry.is_free) {
      console.log('Entry requires payment for content access');
      console.log('Content available at ID:', entry.cid);
      console.log('Revenue so far:', entry.total_revenue);
    }
    
    console.log('Entry details:', {
      title: entry.title,
      description: entry.description,
      cid: entry.cid,
      mime_type: entry.mime_type
    });
    return entry;
  } catch (error) {
    console.error('Failed to get entry:', error);
  }
}

Behind the Scenes

This method:

  1. Validates feed and entry ID formats
  2. Makes GET request to /v1/feeds/{feedId}/entries/{entryId}
  3. Checks authentication status
  4. Returns entry metadata and content ID
  5. Content access depends on payment status and x402 flow

Error Handling

try {
  const entry = await grapevine.entries.get(feedId, entryId);
  console.log('Entry found:', entry.title);
} catch (error) {
  if (error.message.includes('404')) {
    console.error('Entry or feed not found');
  } else if (error.message.includes('400')) {
    console.error('Invalid ID format');
  } else {
    console.error('Error:', error.message);
  }
}

Notes

  • Authentication: Optional but affects content visibility
  • Content Access: Based on free status and purchase history
  • Private IPFS Storage: Content stored on Private IPFS with ID reference
  • Purchase Status: Only shown when authenticated
  • Content Truncation: Paid content may be truncated for preview

Related