Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.
JavaScript agent-skillsai-agentsai-seoclaudeclaude-codeclaude-code-pluginclaude-skillscodexcontent-marketingconversion-rate-optimizationcopywritingcursoremail-marketinggenerative-engine-optimizationgrowth-marketingmarketingmarketing-automationsaas-marketingseoskill-md
feat(hunter): retrieve later domain and lead-list pages
Rudy Celekli9c1977fd21ca
diff --git a/tests/clis/hunter-domain-pagination.test.cjs b/tests/clis/hunter-domain-pagination.test.cjsnew file mode 100644index 0000000..bb6435f--- /dev/null+++ b/tests/clis/hunter-domain-pagination.test.cjs@@ -0,0 +1,34 @@+const { test } = require('node:test')+const assert = require('node:assert/strict')+const { spawnSync } = require('node:child_process')+const path = require('node:path')+const cli = path.resolve(__dirname, '../../tools/clis/hunter.js')+function run(args, network = true) {+ const source = `global.fetch = async (url, options) => {+ if (!${network}) throw new Error('Unexpected network request');+ return { status: 200, text: async () => JSON.stringify({url, method: options.method}) };+ }; process.argv = ['node', ${JSON.stringify(cli)}, ...${JSON.stringify(args)}]; require(${JSON.stringify(cli)});`+ return spawnSync(process.execPath, ['-e', source], {encoding: 'utf8', timeout: 5000,+ env: {PATH: process.env.PATH, HUNTER_API_KEY: 'fixture-key'}})+}+function output(result) { assert.equal(result.status, 0, result.stderr); return JSON.parse(result.stdout) }+for (const args of [['domain', 'search', '--domain', 'example.com'], ['leads-lists', 'get', '--id', '123']]) {+ test(`${args.join(' ')} can retrieve later pages rather than repeat page one`, () => {+ const result = output(run([...args, '--offset', '100', '--limit', '25']))+ const url = new URL(result.url)+ assert.equal(url.searchParams.get('offset'), '100')+ assert.equal(url.searchParams.get('limit'), '25')+ })+ test(`${args.join(' ')} preserves omitted pagination and explicit zero`, () => {+ assert.equal(new URL(output(run(args)).url).searchParams.has('offset'), false)+ assert.equal(new URL(output(run([...args, '--offset', '0'])).url).searchParams.get('offset'), '0')+ })+ test(`${args.join(' ')} rejects malformed pages before fetching`, () => {+ for (const bad of [['--offset', '-1'], ['--offset', '1.5'], ['--offset', 'Infinity'], ['--offset'], ['--limit', '0'], ['--limit', '101'], ['--limit', 'no']]) {+ const result = run([...args, ...bad], false)+ assert.equal(result.status, 1)+ assert.match(result.stderr, /--(?:offset|limit) must be/)+ assert.doesNotMatch(result.stderr, /Unexpected network/)+ }+ })+}diff --git a/tools/clis/hunter.js b/tools/clis/hunter.jsindex f451160..a2e72cf 100755--- a/tools/clis/hunter.js+++ b/tools/clis/hunter.js@@ -51,6 +51,17 @@ function parseArgs(args) {return result}+function addPagination(params) {+ for (const [flag, minimum, maximum] of [['offset', 0, Number.MAX_SAFE_INTEGER], ['limit', 1, 100]]) {+ if (args[flag] === undefined) continue+ const value = typeof args[flag] === 'string' ? Number(args[flag]) : NaN+ if (!Number.isSafeInteger(value) || value < minimum || value > maximum) {+ throw new Error(`--${flag} must be a whole number from ${minimum} to ${maximum}`)+ }+ params.set(flag, String(value))+ }+}+const args = parseArgs(rawArgs)const [cmd, sub, ...rest] = args._@@ -64,7 +75,7 @@ async function main() {const domain = args.domainif (!domain) { result = { error: '--domain required' }; break }const params = new URLSearchParams({ domain })- if (args.limit) params.set('limit', args.limit)+ addPagination(params)if (args.type) params.set('type', args.type)result = await api('GET', `/domain-search?${params.toString()}`)break@@ -200,7 +211,10 @@ async function main() {case 'get': {const id = args.idif (!id) { result = { error: '--id required' }; break }- result = await api('GET', `/leads_lists/${id}`)+ const params = new URLSearchParams()+ addPagination(params)+ const qs = params.toString()+ result = await api('GET', `/leads_lists/${id}${qs ? '?' + qs : ''}`)break}default:@@ -213,7 +227,7 @@ async function main() {error: 'Unknown command',usage: {domain: {- search: 'domain search --domain <domain> [--limit <n>] [--type personal|generic]',+ search: 'domain search --domain <domain> [--limit <1-100>] [--offset <n>] [--type personal|generic]',count: 'domain count --domain <domain> [--type personal|generic]',},email: {@@ -235,7 +249,7 @@ async function main() {},'leads-lists': {list: 'leads-lists list [--limit <n>] [--offset <n>]',- get: 'leads-lists get --id <id>',+ get: 'leads-lists get --id <id> [--limit <1-100>] [--offset <n>]',},}}diff --git a/tools/integrations/hunter.md b/tools/integrations/hunter.mdindex 04250e3..252bd5b 100644--- a/tools/integrations/hunter.md+++ b/tools/integrations/hunter.md@@ -88,3 +88,14 @@ node tools/clis/hunter.js account info- **Link building**: Find email contacts at target domains for outreach- **Prospecting**: Build lead lists from company domains- **Verification**: Clean email lists before sending campaigns++### Reading complete domain and lead-list results++The CLI accepts `--offset` and `--limit` on `domain search` and `leads-lists get`. Fetch each page explicitly, advancing the offset by the returned page size until the provider returns no further records. Existing omitted pagination retains the provider default; these commands do not automatically spend credits on subsequent pages.++```bash+node tools/clis/hunter.js domain search --domain example.com --limit 100 --offset 100+node tools/clis/hunter.js leads-lists get --id 123 --limit 100 --offset 100+```++The flags require nonnegative whole-number offsets and limits from 1 to 100. Provider entitlement and total-result limits still apply. See [Hunter’s V2 API reference](https://hunter.io/api-documentation).