import { createZapierSdk } from "@zapier/zapier-sdk"; async function main() { // Tip: run `npx zapier-sdk login` first to authenticate. const zapier = createZapierSdk(); console.log("⚡ Zapier SDK factory is initialized."); console.log('🔎 Searching for apps matching "slack"...'); const { data: apps } = await zapier.listApps({ search: "slack" }); const topApps = apps.slice(0, 5); console.log(`☑️ Found ${apps.length} matches.`); if (topApps.length > 0) { console.log("\nTop matches:"); for (const app of topApps) { console.log(` - ${app.title} (${app.slug})`); } } else { console.log( '\nNo app matches found for "slack". Try a different search term.', ); } // To use an app, you need a connection. List your connections: // const { data: connections } = await zapier.listConnections({ appKey: "slack", owner: "me" }); // // Run an action once you have a connection: // const { data: result } = await zapier.runAction({ // appKey: "slack", // actionType: "read", // actionKey: "channels", // connectionId: connections[0].id, // }); // // For type-safe access, generate app types: // npx zapier-sdk add slack // Then use: // await zapier.apps.slack.read.channels({ connectionId: "..." }); // // Make raw API requests with a connection's credentials: // const response = await zapier.fetch("https://slack.com/api/emoji.list", { // connectionId: connections[0].id, // }); } main().catch(console.error);