Woodpecker.co API Client

1.1.0 · active · verified Tue Apr 21

The `woodpecker-api` package provides a Promise-based JavaScript client for interacting with the Woodpecker.co email outreach platform's API. It abstracts the underlying HTTP requests, offering a fluent interface for managing prospects, campaigns, and other Woodpecker resources directly from a Node.js application. The current stable version is 1.1.0, and releases appear to be feature-driven rather than on a fixed cadence, with recent updates introducing functionalities such as prospect editing, blacklisting, and webhook subscriptions. A key differentiator of this library is its role as a thin, unopinionated wrapper around the official Woodpecker API, designed to simplify asynchronous operations through the use of Promises. To utilize the library, developers must obtain and provide a valid API key from their Woodpecker.co account dashboard. It primarily targets CommonJS environments, requiring a specific factory function invocation pattern for client instantiation.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Woodpecker API client, find prospects by various criteria, and access specialized lists like 'newest' and 'replied' prospects, including robust error handling.

const Woodpecker = require('woodpecker-api')(process.env.WOODPECKER_API_KEY ?? '');

async function fetchAndManageProspects() {
  if (!process.env.WOODPECKER_API_KEY) {
    console.error('Error: WOODPECKER_API_KEY environment variable is not set.');
    console.error('Please set it before running the script.');
    return;
  }

  try {
    // Find prospects named 'd' with a limit of 1
    console.log('Searching for prospects with first name "d"...');
    const results = await Woodpecker.prospects()
      .find({
        firstName: 'd',
        $limit: 1
      });

    console.log('Found Prospect(s):', JSON.stringify(results, null, 2));

    if (results && results.length > 0) {
      const firstProspectId = results[0].id;
      console.log(`\nAttempting to retrieve newest prospects...`);
      const newest = await Woodpecker.prospects().newest();
      console.log(`Retrieved ${newest.length} newest prospects.`);

      // Example: Find 100 prospects who replied (if applicable)
      // Note: This often requires specific campaign context for real-world use.
      console.log('\nAttempting to retrieve replied prospects (if any)...');
      const replied = await Woodpecker.prospects().replied();
      console.log(`Retrieved ${replied.length} replied prospects.`);
    } else {
      console.log('No prospects found matching the initial search criteria.');
    }

  } catch (e) {
    console.error('\nAn error occurred during API interaction:');
    if (e.response && e.response.data) {
      console.error('API Error Details:', JSON.stringify(e.response.data, null, 2));
    } else {
      console.error(e.message);
    }
  }
}

fetchAndManageProspects();

view raw JSON →