Skip to content

feeds.list()

List feeds with optional filtering and pagination.

Signature

feeds.list(query?: ListFeedsQuery): Promise<PaginatedResponse<Feed>>

Parameters

query

  • Type: ListFeedsQuery (optional)
interface ListFeedsQuery {
  page_size?: number;              // Max results per page (default: 20)
  page_token?: string;             // Pagination token from previous response
  owner_id?: string;               // Filter by owner ID (UUID)
  category?: string;               // Filter by category ID (UUID)
  tags?: string[];                 // Filter by tags
  min_entries?: number;            // Minimum number of entries
  min_age?: number;                // Minimum age in seconds
  max_age?: number;                // Maximum age in seconds
  is_active?: boolean;             // Filter by active status
}

Returns

  • Type: Promise<PaginatedResponse<Feed>>
interface PaginatedResponse<Feed> {
  data: Feed[];                    // Array of feeds
  next_page_token?: string;        // Token for next page (if more results)
  has_more: boolean;               // Whether more results exist
}

Usage

Basic Example

// List all feeds (default pagination)
const response = await grapevine.feeds.list();
 
console.log(`Found ${response.data.length} feeds (has more: ${response.has_more})`);
response.data.forEach(feed => {
  console.log(`${feed.name}: ${feed.total_entries} entries`);
});

With Filters

// List feeds with specific tags
const techFeeds = await grapevine.feeds.list({
  tags: ['technology', 'ai'],
  page_size: 10,
  is_active: true
});

Filter by Category

// Get categories first to find the category ID
const categories = await grapevine.categories.getAll();
const financeCategory = categories.find(c => c.name === 'Finance');
 
// Filter feeds by category ID and entry count
const results = await grapevine.feeds.list({
  category: financeCategory?.id,  // UUID, not name
  min_entries: 5,
  page_size: 50
});

Pagination

// Manual pagination with tokens
let pageToken: string | undefined;
 
do {
  const response = await grapevine.feeds.list({
    page_size: 20,
    page_token: pageToken
  });
  
  response.data.forEach(feed => {
    console.log(feed.name);
  });
  
  pageToken = response.next_page_token;
} while (pageToken);

Behind the Scenes

This method:

  1. Builds query parameters from options
  2. Makes GET request to /v1/feeds
  3. Handles pagination metadata
  4. Returns structured response

Error Handling

try {
  const feeds = await grapevine.feeds.list({
    category: 'invalid-category'
  });
} catch (error) {
  if (error.message.includes('400')) {
    console.error('Invalid parameters');
  } else {
    console.error('Error:', error.message);
  }
}

Notes

  • Authentication: Optional - public endpoint
  • Default Page Size: 20 feeds per request
  • Pagination: Uses cursor-based pagination with tokens
  • Sorting: Results ordered by relevance and creation date

Related