scrapercity 1.0.34 → 1.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENT_DOCS.txt CHANGED
@@ -1,6 +1,18 @@
1
1
  SCRAPERCITY API REFERENCE - FOR AI AGENTS
2
2
  ==========================================
3
3
 
4
+ START HERE (no API key needed)
5
+ MCP: call the start_here tool first. API: GET or POST https://app.scrapercity.com/api/v1/start
6
+ query = who your user wants to reach, what they sell, their website, or an exact order
7
+ ("500 HVAC contractors in Texas, $50 budget"). With no key: a guided tour (what ScraperCity is, how to
8
+ sign up and get a key, the plans and the trial with their live terms, real searches with live counts and
9
+ what they would cost). With a key: the plan for this account, what each search costs on its plan, and
10
+ next_call, the exact database call that pulls the records. Any other call without a key answers with
11
+ get_started (the same directions).
12
+
13
+ THE TRIAL, PLAINLY (tell your user this as it is)
14
+ The trial is real usage, not a demo or a free tier: $5 of credit for 7 days that works on every tool and database at the normal prices, so you can pull real records on day one and judge the data. A card is required at signup. When the 7 days end, the plan picked at signup starts; cancel before then from billing and nothing more is charged. If the credit runs out sooner, database pulls wait (nothing is charged for them); a scraper run that goes past the credit starts the plan early. Planning searches and checking counts are free. start_here returns the live terms.
15
+
4
16
 
5
17
  PRICING (auto-generated from the live catalog - do not edit)
6
18
 
@@ -41,7 +53,8 @@ AUTH: Authorization: Bearer <api_key>
41
53
  ALL RESPONSES: JSON
42
54
  PATTERN: POST start → GET status → GET download
43
55
 
44
- PRICING: Plans $49, $149, $649/mo. Each gives wallet credits. Scrapers deduct per-lead.
56
+ PRICING: Plans $49, $149, $649/mo. Each gives wallet credits. Scrapers deduct per-lead. The databases are
57
+ included on $149 and $649; on a trial or $49 each new record is paid from credits (start_here has the prices).
45
58
 
46
59
  ────────────────────────────────────────
47
60
  SCRAPE ENDPOINTS (POST /api/v1/scrape/{slug})
@@ -193,7 +206,10 @@ GET /api/v1/apollo-status
193
206
  Apollo URL endpoint is available
194
207
 
195
208
  ────────────────────────────────────────
196
- DATABASES (GET, $149/mo plan and up, 100k new records/day)
209
+ DATABASES (GET; included on the $149/mo plan and up, 100k new records/day; on a trial or the $49 plan
210
+ each new record is paid from credits, records you already have are free. The answer then carries billing:
211
+ charged_dollars, credits_left_dollars, and not_returned + has_more when the credits ran out part way;
212
+ a 402 means none could be paid for.)
197
213
  ────────────────────────────────────────
198
214
 
199
215
  GET /api/v1/database/leads?title=CTO&country=United States&hasEmail=true&page=1&limit=100
@@ -234,7 +250,7 @@ GET /api/v1/database/leads?title=CTO&country=United States&hasEmail=true&page=1&
234
250
  or company size) and retry.
235
251
 
236
252
  GET /api/v1/database/local-businesses?category=Dentist&country=US&hasContact=true&limit=100
237
- Local businesses ($149/mo plan and up, 100k new businesses/day), same pattern as above.
253
+ Local businesses (included on $149/mo and up, 100k new businesses/day; per record below), same pattern as above.
238
254
  Search the way you would on Google Maps:
239
255
  keyword=thai restaurant (repeat for several; matches business names and categories, any keyword;
240
256
  a place inside a keyword, "plumbers in Austin TX", is the location when none is sent)
@@ -275,7 +291,7 @@ GET /api/v1/database/ecommerce?...
275
291
 
276
292
  POST /api/v1/database/plan { "query": "dentists in Austin", "database": "local" }
277
293
  (or GET /api/v1/database/plan?query=...&database=...)
278
- $149/mo plan and up; planning does not count toward the daily limit. Plain English -> ready-to-run
294
+ Free on every plan, trials included (a daily cap below $149); planning does not count toward the daily limit. Plain English -> ready-to-run
279
295
  database searches. query is who you want ("websites that
280
296
  use shopify", "CEOs of SaaS companies in Texas") or what you sell ("I sell life insurance").
281
297
  database (optional): leads | local | ecommerce; leave it out to let the planner pick.
@@ -285,7 +301,7 @@ POST /api/v1/database/plan { "query": "dentists in Austin", "database": "local"
285
301
 
286
302
  POST /api/v1/autoleads/lookalike { "domains": ["acme.com", "mike@globex.com", "initech.com"] }
287
303
  GET /api/v1/autoleads/lookalike?id=<job id>
288
- $149/mo plan and up. Your customers' websites or work emails -> lookalike groups. POST starts a
304
+ Every plan, trials included. Your customers' websites or work emails -> lookalike groups. POST starts a
289
305
  background job (202 { job }); GET it until job.status is done (or failed). When done, job.groups:
290
306
  [{ name, description, sites, database, filters, count, tool, addOn, reason }]. Send a group's
291
307
  filters to that database's endpoint to pull the records. $0.01 per site read, from credits when the
@@ -322,6 +338,12 @@ WORKFLOW EXAMPLES
322
338
  4. LEAD DATABASE (instant):
323
339
  GET /api/v1/database/leads?title=CTO&industry=computer+software&hasEmail=true&page=1
324
340
  Loop pages until page > totalPages
341
+ Every lead carries email_check_status (valid, valid_catch_all, invalid, unknown, not_checked) and email_checked_on:
342
+ send ONLY to valid emails checked in the last 30 days; put every other email through email-validator first.
343
+ Before sending: add replaceLeftContacts=true, wait for replacement.run_id (GET /api/v1/scrape/status/{run_id}),
344
+ then send the CSV from GET /api/downloads/{run_id}: every email checked, people who have left swapped for the person
345
+ in that role now ($0.02 per contact replaced, free on the $649 plan). At minimum: POST the emails to email-validator
346
+ and send only to the valid ones.
325
347
 
326
348
  5. LOCAL BUSINESS PIPELINE:
327
349
  Yelp/Angi/Maps → download CSV → POST email-finder with names+domains → POST mobile-finder
@@ -332,3 +354,6 @@ WORKFLOW EXAMPLES
332
354
  7. LOCAL BUSINESS DATABASE (instant):
333
355
  GET /api/v1/database/local-businesses?keyword=dentist&location=Austin%2C+TX&hasEmail=true&page=1
334
356
  Loop pages until page > totalPages
357
+ Every business carries email_check_status / contact_email_check_status and their checked_on dates:
358
+ send ONLY to valid emails checked in the last 30 days; put every other email through email-validator first.
359
+ Before sending: POST the emails to email-validator and send only to the valid ones.
package/README.md CHANGED
@@ -4,6 +4,16 @@ Pull leads, validate emails, find mobile numbers, and scrape business data - all
4
4
 
5
5
  ScraperCity gives AI agents access to 15+ B2B data tools: Apollo scraping, Google Maps extraction, email finding/validation, mobile number lookup, skip tracing, ecommerce store data, criminal records, and more.
6
6
 
7
+ ## Start Here (no API key needed)
8
+
9
+ ```bash
10
+ npx scrapercity start "dentists in Austin"
11
+ ```
12
+
13
+ Or have your agent call the `start_here` MCP tool, or `GET https://app.scrapercity.com/api/v1/start?query=...`. With no key you get a guided tour: what ScraperCity is, how to sign up, the plans and the trial with their live terms, and real searches with live counts. With a key it plans for your account and returns the exact next call.
14
+
15
+ **The trial, plainly:** The trial is real usage, not a demo or a free tier: $5 of credit for 7 days that works on every tool and database at the normal prices, so you can pull real records on day one and judge the data. A card is required at signup. When the 7 days end, the plan picked at signup starts; cancel before then from billing and nothing more is charged. If the credit runs out sooner, database pulls wait (nothing is charged for them); a scraper run that goes past the credit starts the plan early. Planning searches and checking counts are free. start_here returns the live terms.
16
+
7
17
  ## Quick Start
8
18
 
9
19
  ### Option 1: CLI
@@ -140,8 +150,12 @@ Both SDKs carry the same tool list as the MCP server, regenerated from the live
140
150
  | **Store Leads** | Shopify/WooCommerce stores with contacts | $0.0039/lead |
141
151
  | **BuiltWith** | All sites using a technology | $4.99/search |
142
152
  | **Criminal Records** | Background check by name | $1.00 if found |
143
- | **Lead Database** | 3M+ B2B contacts, instant query ($149/mo plan and up) | Included |
144
- | **Local Business Database** | Local businesses with phones, emails and ratings, instant query ($149/mo plan and up) | Included |
153
+ | **Lead Database** | B2B contacts, instant query | Included on $149/mo and up; per new lead from credits below it |
154
+ | **Local Business Database** | Local businesses with phones, emails and ratings, instant query | Included on $149/mo and up; per new business from credits below it |
155
+
156
+ ## Before You Send
157
+
158
+ Leads from any database: check them before outreach. Every record carries `email_check_status` (our own email checker: valid, valid_catch_all, invalid, unknown, not_checked): send ONLY to `valid` emails checked in the last 30 days (`email_checked_on`), and put every other email through `validate_emails` first. For people (Lead Database), pass `replaceLeftContacts: true` to `query_lead_database`; the response adds `replacement.run_id`, a run that checks every email and swaps each person who has left for the person in that role now. Wait for it with `check_run_status`, then send the CSV from `download_results` ($0.02 per contact replaced, free on the $649 plan). At minimum, run the emails through `validate_emails` and send only to the valid ones.
145
159
 
146
160
  ## How It Works
147
161
 
@@ -171,10 +185,10 @@ For Apollo and long-running scrapes, configure a webhook at [app.scrapercity.com
171
185
 
172
186
  | Plan | Price | Credits |
173
187
  |------|-------|---------|
174
- | Trial | Free | $5 |
175
- | Starter | $49/mo | $49 |
176
- | Growth | $149/mo | $149 + 10% bonus |
177
- | Professional | $649/mo | $649 + 30% bonus + Database API |
188
+ | Trial | 7 days, card required, then the plan picked at signup | $5 of usage credit |
189
+ | Starter | $49/mo | $49 (databases per record from credits) |
190
+ | Growth | $149/mo | $149 + 10% bonus, databases included |
191
+ | Scale | $649/mo | $649 + 30% bonus, databases included, higher limits |
178
192
 
179
193
  Buy additional credits anytime. [scrapercity.com/pricing](https://scrapercity.com/pricing)
180
194
 
package/SKILL.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # ScraperCity - B2B Lead Generation
2
2
 
3
+ ## START HERE (no API key needed)
4
+ Call the `start_here` tool first (API: `GET https://app.scrapercity.com/api/v1/start?query=...`). Give it who your user wants to reach, what they sell, their website, or an exact order. With no key it answers with a guided tour: what ScraperCity is, how to sign up and get a key, the plans and the trial with their live terms, and real searches with live counts. With a key it plans for the account and returns `next_call`, the exact call that pulls the records.
5
+
6
+ **The trial, plainly:** The trial is real usage, not a demo or a free tier: $5 of credit for 7 days that works on every tool and database at the normal prices, so you can pull real records on day one and judge the data. A card is required at signup. When the 7 days end, the plan picked at signup starts; cancel before then from billing and nothing more is charged. If the credit runs out sooner, database pulls wait (nothing is charged for them); a scraper run that goes past the credit starts the plan early. Planning searches and checking counts are free. start_here returns the live terms.
7
+
3
8
  ## Setup
4
9
  ```bash
5
10
  export SCRAPERCITY_API_KEY="your_key" # get from app.scrapercity.com/dashboard/api-docs
@@ -80,11 +85,11 @@ Apollo scrapes usually take **15-30 minutes** to deliver; some lists take longer
80
85
  | POST | `/api/v1/scrape/cancel/{runId}` | Cancel running job |
81
86
  | GET | `/api/v1/scrape/logs/{runId}` | Run logs |
82
87
  | GET | `/api/v1/apollo-status` | Apollo service health: `{status: "url-based" or "legacy", message, timestamp}` |
83
- | GET | `/api/v1/database/leads?title=CTO&country=United%20States&hasEmail=true&limit=100` | Lead DB ($149/mo plan and up, 100k new leads/day). Optional: `excludeDelivered=true` (only leads you don't have yet), `after=0` then `pagination.next_after` (cursor paging). Company filters: `keywords`, `revenueMin`/`revenueMax`, `companyCountry`/`companyState`/`companyCity`. Exclusions: `notTitle`, `notKeywords`, `notIndustry`. Website technologies: `technologies` (any of), `technologiesAll` (all of), `notTechnologies` (none of). `url=<people-search URL>` searches with that URL's filters. POST with a JSON body takes the same parameters (use it for a long `url`) |
84
- | GET | `/api/v1/database/local-businesses?category=Dentist&country=US&hasContact=true&limit=100` | Local biz DB ($149/mo plan and up, 100k new businesses/day). Search like Google Maps: `keyword` (repeat; names and categories, any keyword) and `location` (repeat; cities, states, countries, postal codes), with `searched_as` in the response and `lead_database` when nothing is found but the Lead Database has 100+ people. Filters: `category`, `country`, `state`, `city`, `postalCode`, `query`, `minRating`/`maxRating`, `minReviews`/`maxReviews`, `hasEmail`, `hasPhone`, `hasWebsite`, `hasContact` (only businesses with a named contact person), `maxLocations` (skip businesses with over that many locations: businesses with the same website; skips chains), `title` (business name), `box=minLat,minLng,maxLat,maxLng` (a map area). Exclusions: `notCategory`. `url=<Google Maps search URL>` searches with that URL's keyword and place. POST with a JSON body takes the same parameters (use it for a long `url`). Same optional `excludeDelivered` / `after` |
85
- | GET | `/api/v1/database/ecommerce?...` | Ecommerce DB ($149/mo plan and up). Same optional `excludeDelivered` / `after`. Technologies: `technologies` (any of), `technologiesAll` (all of), `notTechnologies` (none of) |
86
- | POST | `/api/v1/database/plan` | $149/mo plan and up (GET with `?query=` also works). `{ "query": "dentists in Austin", "database"?: "leads" or "local" or "ecommerce" }` -> ready-to-run searches: `{ targeting, searches: [{ database, name, filters, count, apiEndpoint, apiParams, link }] }`. Send `apiParams` as they are to `/api/v1/<apiEndpoint>` |
87
- | POST | `/api/v1/autoleads/lookalike` | $149/mo plan and up, $0.01 per site read. `{ "domains": ["acme.com", "mike@globex.com", ...] }` (websites or work emails, at least 3 company sites) -> 202 `{ job }`. Then GET `/api/v1/autoleads/lookalike?id=<job id>` until `job.status` is `done`: `job.groups` = `[{ name, description, sites, database, filters, count, tool }]`. Send a group's `filters` to that database's endpoint. 402 = balance under $0.01 x every site; 409 = a job is already running. Add `&format=csv` to the GET for every site as a CSV (no extra charge) |
88
+ | GET | `/api/v1/database/leads?title=CTO&country=United%20States&hasEmail=true&limit=100` | Lead DB (included on $149/mo and up, 100k new leads/day; on a trial or $49 each new lead is paid from credits, see `billing` in the answer). Optional: `excludeDelivered=true` (only leads you don't have yet), `after=0` then `pagination.next_after` (cursor paging), `replaceLeftContacts=true` (adds `replacement.run_id`: a run that swaps contacts who have left for the person in that role now; $0.02 per contact replaced, free on the $649 plan). Company filters: `keywords`, `revenueMin`/`revenueMax`, `companyCountry`/`companyState`/`companyCity`. Exclusions: `notTitle`, `notKeywords`, `notIndustry`. Website technologies: `technologies` (any of), `technologiesAll` (all of), `notTechnologies` (none of). `url=<people-search URL>` searches with that URL's filters. POST with a JSON body takes the same parameters (use it for a long `url`) |
89
+ | GET | `/api/v1/database/local-businesses?category=Dentist&country=US&hasContact=true&limit=100` | Local biz DB (included on $149/mo and up, 100k new businesses/day; per record from credits below it). Search like Google Maps: `keyword` (repeat; names and categories, any keyword) and `location` (repeat; cities, states, countries, postal codes), with `searched_as` in the response and `lead_database` when nothing is found but the Lead Database has 100+ people. Filters: `category`, `country`, `state`, `city`, `postalCode`, `query`, `minRating`/`maxRating`, `minReviews`/`maxReviews`, `hasEmail`, `hasPhone`, `hasWebsite`, `hasContact` (only businesses with a named contact person), `maxLocations` (skip businesses with over that many locations: businesses with the same website; skips chains), `title` (business name), `box=minLat,minLng,maxLat,maxLng` (a map area). Exclusions: `notCategory`. `url=<Google Maps search URL>` searches with that URL's keyword and place. POST with a JSON body takes the same parameters (use it for a long `url`). Same optional `excludeDelivered` / `after` |
90
+ | GET | `/api/v1/database/ecommerce?...` | Ecommerce DB (included on $149/mo and up; per record from credits below it). Same optional `excludeDelivered` / `after`. Technologies: `technologies` (any of), `technologiesAll` (all of), `notTechnologies` (none of) |
91
+ | POST | `/api/v1/database/plan` | Free on every plan, trials included (GET with `?query=` also works). `{ "query": "dentists in Austin", "database"?: "leads" or "local" or "ecommerce" }` -> ready-to-run searches: `{ targeting, searches: [{ database, name, filters, count, apiEndpoint, apiParams, link }] }`. Send `apiParams` as they are to `/api/v1/<apiEndpoint>` |
92
+ | POST | `/api/v1/autoleads/lookalike` | Every plan, $0.01 per site read. `{ "domains": ["acme.com", "mike@globex.com", ...] }` (websites or work emails, at least 3 company sites) -> 202 `{ job }`. Then GET `/api/v1/autoleads/lookalike?id=<job id>` until `job.status` is `done`: `job.groups` = `[{ name, description, sites, database, filters, count, tool }]`. Send a group's `filters` to that database's endpoint. 402 = balance under $0.01 x every site; 409 = a job is already running. Add `&format=csv` to the GET for every site as a CSV (no extra charge) |
88
93
 
89
94
  ## Status Values
90
95
  `RUNNING` → `SUCCEEDED` or `FAILED` or `CANCELLED`
@@ -124,3 +129,4 @@ scrapercity download <runId> # saves CSV
124
129
  - Website finder: domains only, no https:// prefix needed
125
130
  - Property lookup: full address with city, state, zip required
126
131
  - Downloads return CSV with all available fields
132
+ - Before sending outreach to leads from any database: every record carries `email_check_status` (our checker: valid, valid_catch_all, invalid, unknown, not_checked); send ONLY to `valid` emails checked in the last 30 days (`email_checked_on`); put every other email through `validate_emails` and send only to the ones it returns valid. For people (Lead Database), set `replaceLeftContacts=true` and send the CSV from that run (`check_run_status`, then `download_results`): every email is checked and people who have left are swapped for the person in that role now. At minimum, run the emails through `validate_emails` and send only to the valid ones
package/bin/cli.mjs CHANGED
@@ -395,9 +395,11 @@ async function main() {
395
395
  if (flagBool('--has-email')) params.hasEmail = 'true'
396
396
  if (flagBool('--has-phone')) params.hasPhone = 'true'
397
397
  if (flagBool('--exclude-delivered')) params.excludeDelivered = 'true'
398
+ if (flagBool('--replace-left-contacts')) params.replaceLeftContacts = 'true'
398
399
  const r = await sc.dbLeads(params)
399
400
  console.log(`${r.pagination?.total || '?'} total leads, page ${r.pagination?.page || 1} of ${r.pagination?.totalPages || '?'}`)
400
401
  if (r.pagination?.next_after) console.log(`Next page: --after ${r.pagination.next_after}`)
402
+ if (r.replacement?.run_id) console.log(`Contacts who have left are being replaced: scrapercity status ${r.replacement.run_id}, then scrapercity download ${r.replacement.run_id}`)
401
403
  const tr = r.search_translation || r.apollo_translation
402
404
  if (tr?.not_supported?.length) console.log(`Not supported from the search URL: ${tr.not_supported.join(', ')}`)
403
405
  console.log(json(r.data?.slice(0, 3) || r))
@@ -445,6 +447,14 @@ async function main() {
445
447
  }
446
448
 
447
449
  // ── Plan: plain English -> database searches ($149/mo plan and up) ──
450
+ // ── Start here (no key needed) ──
451
+ case 'start': {
452
+ const query = args.join(' ').trim()
453
+ const r = await sc.startHere(query || undefined)
454
+ console.log(json(r))
455
+ break
456
+ }
457
+
448
458
  case 'plan': {
449
459
  const database = flag('--database')
450
460
  const query = args.join(' ').trim()
@@ -460,7 +470,7 @@ async function main() {
460
470
  break
461
471
  }
462
472
 
463
- // ── Lookalike groups from your customers ($149/mo plan and up) ──
473
+ // ── Lookalike groups from your customers (every plan, $0.01 per site read) ──
464
474
  case 'lookalike': {
465
475
  const file = flag('--file')
466
476
  let domains = [...args]
@@ -519,6 +529,10 @@ async function main() {
519
529
  console.log(`
520
530
  ScraperCity CLI - B2B lead generation from your terminal
521
531
 
532
+ Start here (no API key needed):
533
+ scrapercity start "dentists in Austin" Guided tour: what ScraperCity is, signup, plans and trial,
534
+ real searches with live counts (with a key: your account's plan)
535
+
522
536
  Auth:
523
537
  scrapercity login [key] Save API key to ~/.scrapercityrc
524
538
  scrapercity wallet Check balance and plan
@@ -550,17 +564,17 @@ ScraperCity CLI - B2B lead generation from your terminal
550
564
  scrapercity logs <runId> View run logs
551
565
  scrapercity runs [--hours 24] List recent runs
552
566
 
553
- Plan ($149/mo plan and up):
567
+ Plan (every plan, trials included):
554
568
  scrapercity plan "dentists in Austin" Plain English -> ready-to-run database searches
555
569
  --database leads|local|ecommerce Only this database (default: the ones that fit)
556
570
 
557
- Lookalike groups ($149/mo plan and up, $0.01 per site read):
571
+ Lookalike groups (every plan, $0.01 per site read):
558
572
  scrapercity lookalike acme.com mike@globex.com ... Group your customers into lookalike audiences
559
573
  --file customers.txt One website or work email per line
560
574
  scrapercity lookalike-status <jobId> Read a lookalike job
561
575
  scrapercity lookalike-csv <jobId> [-o f.csv] Every site of a finished job as a CSV
562
576
 
563
- Database ($149/mo plan and up):
577
+ Database (included on $149/mo and up; per record from credits on a trial or $49):
564
578
  scrapercity db-leads [filters] Query lead database
565
579
  --title --industry --country --state --city --company --domain --seniority --department
566
580
  --min-employees --max-employees --has-email --has-phone
@@ -569,6 +583,7 @@ ScraperCity CLI - B2B lead generation from your terminal
569
583
  --technologies --technologies-all --not-technologies Website technologies: any of / all of / none of (comma separated)
570
584
  --url "<people-search URL>" Search with that URL's filters
571
585
  --exclude-delivered Only leads you don't already have
586
+ --replace-left-contacts Also start a run that swaps contacts who have left for the person in that role now
572
587
  --after <id> Cursor paging (start with 0, then use the printed next id)
573
588
  scrapercity db-local [filters] Query local business database
574
589
  --keyword "thai restaurant,sushi" What the businesses do or are called (any of them)
@@ -1,6 +1,6 @@
1
1
  // AUTO-GENERATED by scripts/generate.mjs — DO NOT EDIT BY HAND.
2
2
  // Source of truth: scraperConfigs.ts (+ src/config/scrapers.ts). Regenerate: npm run generate
3
- // Generated: 2026-11-05T13:36:26.727Z
3
+ // Generated: 2026-11-05T22:29:40.746Z
4
4
  export const TOOLS = [
5
5
  {
6
6
  "name": "scrape_apollo",
@@ -708,6 +708,7 @@ export const ENDPOINT_BY_TOOL = {
708
708
  }
709
709
 
710
710
  export const ENDPOINTS = {
711
+ "start": "/api/v1/start",
711
712
  "apollo": "/api/v1/scrape/apollo",
712
713
  "website-finder": "/api/v1/scrape/website-finder",
713
714
  "skip-trace": "/api/v1/scrape/skip-trace",
package/lib/client.mjs CHANGED
@@ -5,6 +5,8 @@ import os from 'os'
5
5
  import { ENDPOINTS } from './catalog.generated.mjs'
6
6
 
7
7
  const DEFAULT_BASE = 'https://app.scrapercity.com'
8
+ // What a call with no key is told (v1.0.36): the start_here tool and /api/v1/start need no key and explain how to get one.
9
+ export const NO_KEY_MESSAGE = 'No ScraperCity API key yet. Call the start_here tool first (it needs no key): it explains ScraperCity, the plans and the trial, and runs real searches with live counts. To get a key, ask your user to sign up at https://app.scrapercity.com/signup and copy the key from https://app.scrapercity.com/dashboard/api-docs into SCRAPERCITY_API_KEY (CLI: scrapercity login).'
8
10
  let BASE = DEFAULT_BASE
9
11
  let KEY_OVERRIDE = null
10
12
  const RC_PATH = path.join(os.homedir(), '.scrapercityrc')
@@ -36,7 +38,7 @@ export function saveApiKey(key) {
36
38
  // ── HTTP helpers ──────────────────────────────────────────────
37
39
  async function req(method, urlPath, body) {
38
40
  const key = getApiKey()
39
- if (!key) throw new Error('No API key. Run: scrapercity login OR export SCRAPERCITY_API_KEY=...')
41
+ if (!key) throw new Error(NO_KEY_MESSAGE)
40
42
 
41
43
  const opts = {
42
44
  method,
@@ -56,7 +58,9 @@ async function req(method, urlPath, body) {
56
58
  try { data = JSON.parse(text) } catch { data = { raw: text } }
57
59
 
58
60
  if (!res.ok) {
59
- const msg = data.error || data.message || `HTTP ${res.status}`
61
+ let msg = data.error || data.message || `HTTP ${res.status}`
62
+ // a key the API does not accept: the answer carries get_started; say where to go next
63
+ if (res.status === 401) msg += ' Call start_here (no key needed) for how to get a working key.'
60
64
  const err = new Error(msg)
61
65
  err.status = res.status
62
66
  err.data = data
@@ -68,6 +72,27 @@ async function req(method, urlPath, body) {
68
72
  const get = (p) => req('GET', p)
69
73
  const post = (p, b) => req('POST', p, b)
70
74
 
75
+ // ── Start here (no key needed) ────────────────────────────────
76
+ // /api/v1/start: with no key a guided tour (what ScraperCity is, signing up, the plans and the trial, real searches with
77
+ // live counts for the query); with a key, the plan for this account and the exact next call. The one call that works
78
+ // before there is a key, so it never throws for a missing one, and a busy answer (429) comes back as data.
79
+ export async function startHere(query) {
80
+ const key = getApiKey()
81
+ const headers = { 'Content-Type': 'application/json', 'User-Agent': 'scrapercity-cli/1.0' }
82
+ if (key) headers.Authorization = `Bearer ${key}`
83
+ const res = await fetch(`${BASE}/api/v1/start`, { method: 'POST', headers, body: JSON.stringify(query ? { query } : {}) })
84
+ const text = await res.text()
85
+ let data
86
+ try { data = JSON.parse(text) } catch { data = { raw: text } }
87
+ if (!res.ok && res.status !== 429) {
88
+ const err = new Error(data.error || `HTTP ${res.status}`)
89
+ err.status = res.status
90
+ err.data = data
91
+ throw err
92
+ }
93
+ return data
94
+ }
95
+
71
96
  // ── Wallet & Runs ─────────────────────────────────────────────
72
97
  export const wallet = () => get('/api/v1/wallet')
73
98
  export const runs = (hours = 24, limit = 50) => get(`/api/v1/runs?hours=${hours}&limit=${limit}`)
@@ -79,7 +104,7 @@ export const logs = (runId) => get(`/api/v1/scrape/logs/${runId}`)
79
104
 
80
105
  export async function download(runId, outputPath) {
81
106
  const key = getApiKey()
82
- if (!key) throw new Error('No API key')
107
+ if (!key) throw new Error(NO_KEY_MESSAGE)
83
108
  const res = await fetch(`${BASE}/api/downloads/${runId}`, {
84
109
  headers: { 'Authorization': `Bearer ${key}` }
85
110
  })
@@ -222,14 +247,14 @@ export const dbEcommerce = (params) => {
222
247
  export const planSearch = (query, database) =>
223
248
  post('/api/v1/database/plan', database ? { query, database } : { query })
224
249
 
225
- // Lookalike groups from your customers ($149/mo plan and up): start a job with websites or work emails, then read it by id.
250
+ // Lookalike groups from your customers (every plan, trials included; $0.01 per site read): start a job with websites or work emails, then read it by id.
226
251
  export const lookalikeStart = (domains) => post('/api/v1/autoleads/lookalike', { domains })
227
252
  export const lookalikeJob = (id) => get(`/api/v1/autoleads/lookalike?id=${encodeURIComponent(id)}`)
228
253
 
229
254
  // A finished lookalike job as a CSV file, one row per site (what was read, contacts, group).
230
255
  export async function lookalikeCsv(id, outputPath) {
231
256
  const key = getApiKey()
232
- if (!key) throw new Error('No API key. Run: scrapercity login OR export SCRAPERCITY_API_KEY=...')
257
+ if (!key) throw new Error(NO_KEY_MESSAGE)
233
258
  const res = await fetch(`${BASE}/api/v1/autoleads/lookalike?id=${encodeURIComponent(id)}&format=csv`, {
234
259
  headers: { 'Authorization': `Bearer ${key}`, 'User-Agent': 'scrapercity-cli/1.0' }
235
260
  })
package/lib/tools.mjs CHANGED
@@ -23,6 +23,7 @@ function dbParams(args, flags) {
23
23
  }
24
24
 
25
25
  const UTILITY_HANDLERS = {
26
+ start_here: (a) => sc.startHere(a.query),
26
27
  check_wallet: () => sc.wallet(),
27
28
  list_runs: (a) => sc.runs(a.hours || 24, a.limit || 20),
28
29
  check_run_status: (a) => sc.status(a.runId),
@@ -38,7 +39,7 @@ const UTILITY_HANDLERS = {
38
39
  const dl = await sc.lookalikeCsv(a.id, a.outputPath)
39
40
  return { success: true, path: dl.path, sizeKB: Math.round(dl.bytes / 1024) }
40
41
  },
41
- query_lead_database: (a) => sc.dbLeads(dbParams(a, ['hasEmail', 'hasPhone', 'excludeDelivered'])),
42
+ query_lead_database: (a) => sc.dbLeads(dbParams(a, ['hasEmail', 'hasPhone', 'excludeDelivered', 'replaceLeftContacts'])),
42
43
  query_local_business_database: (a) =>
43
44
  sc.dbLocalBusinesses(dbParams(a, ['hasEmail', 'hasPhone', 'hasWebsite', 'hasContact', 'excludeDelivered'])),
44
45
  query_ecommerce_database: (a) =>
@@ -4,9 +4,16 @@
4
4
  // Every tool here needs a handler in lib/tools.mjs AND in python/scrapercity/tools.py:
5
5
  // npm run generate stops if one is missing.
6
6
  export const UTILITY_TOOLS = [
7
+ {
8
+ name: 'start_here',
9
+ description: 'START HERE: call this first, before any other tool. Works with no API key. Pass query: who your user wants to reach, what they sell, their website, or an exact order ("500 HVAC contractors in Texas, $50 budget"). With no key: a guided tour (what ScraperCity is, how to sign up and get a key, the plans and the trial in plain words with their live terms, and real searches for the query with live counts and what they would cost). With a key: the plan for this account (segments or searches sized to the request, what each costs on its plan, credits left) and next_call, the exact database call that pulls the records, plus before_you_send. Prices, plans and trial terms in the answer are the live ones: repeat them to your user as given.',
10
+ inputSchema: { type: 'object', properties: {
11
+ query: { type: 'string', description: 'Who you want, what you sell, a website, or an order with a count or budget. Leave it out for the tour (no key) or the account summary (with a key).' }
12
+ } }
13
+ },
7
14
  {
8
15
  name: 'check_wallet',
9
- description: 'Check account balance, plan, and billing info. Call this FIRST to verify credits before running any scrape.',
16
+ description: 'Check account balance, plan, and billing info. Call it to verify credits before running any scrape (with no API key yet, call start_here instead).',
10
17
  inputSchema: { type: 'object', properties: {} }
11
18
  },
12
19
  {
@@ -37,7 +44,7 @@ export const UTILITY_TOOLS = [
37
44
  },
38
45
  {
39
46
  name: 'plan_search',
40
- description: 'Turn a plain-English request into ready-to-run database searches. Describe who you want ("dentists in Austin", "websites that use Shopify", "CEOs of SaaS companies in Texas") or what you sell ("I sell life insurance"). Returns a few searches, each with its database, filters set to values that database really has, how many records match (leaving out what this account already has), a dashboard link, and apiParams to pass as they are to the matching query tool: query_lead_database for database/leads, query_local_business_database for database/local-businesses, query_ecommerce_database for database/ecommerce. Included with the $149/mo plan, like the database tools. Use it before a database query whenever you are not sure of the exact filter values.',
47
+ description: 'Turn a plain-English request into ready-to-run database searches. Describe who you want ("dentists in Austin", "websites that use Shopify", "CEOs of SaaS companies in Texas") or what you sell ("I sell life insurance"). Returns a few searches, each with its database, filters set to values that database really has, how many records match (leaving out what this account already has), a dashboard link, and apiParams to pass as they are to the matching query tool: query_lead_database for database/leads, query_local_business_database for database/local-businesses, query_ecommerce_database for database/ecommerce. Free on every plan, trials included (a daily cap below the $149/mo plan). Use it before a database query whenever you are not sure of the exact filter values; for a first look with no key, use start_here.',
41
48
  inputSchema: { type: 'object', properties: {
42
49
  query: { type: 'string', description: 'What you are looking for or what you sell, in plain English' },
43
50
  database: { type: 'string', enum: ['leads', 'local', 'ecommerce'], description: 'Optional: plan in this database only (leads = people at companies, local = local businesses, ecommerce = online stores). Leave it out to let the planner pick the databases that fit.' }
@@ -45,7 +52,7 @@ export const UTILITY_TOOLS = [
45
52
  },
46
53
  {
47
54
  name: 'find_lookalike_groups',
48
- description: 'Group your customers into lookalike audiences. Send their websites or work emails (mike@acme.com reads acme.com and looks up Mike\'s title). Starts a background job and returns it with its id; then call get_lookalike_groups until status is done. Each group comes with ready-to-run database filters, a match count and the best tool to reach businesses like them. $0.01 per site read, from credits; your balance must cover $0.01 x every site. One job at a time. $149/mo plan and up.',
55
+ description: 'Group your customers into lookalike audiences. Send their websites or work emails (mike@acme.com reads acme.com and looks up Mike\'s title). Starts a background job and returns it with its id; then call get_lookalike_groups until status is done. Each group comes with ready-to-run database filters, a match count and the best tool to reach businesses like them. $0.01 per site read, from credits; your balance must cover $0.01 x every site. One job at a time. Every plan, trials included.',
49
56
  inputSchema: { type: 'object', properties: {
50
57
  domains: { type: 'array', items: { type: 'string' }, description: 'Your customers\' websites, URLs or work emails. At least 3 company sites.' }
51
58
  }, required: ['domains'] }
@@ -67,7 +74,7 @@ export const UTILITY_TOOLS = [
67
74
  },
68
75
  {
69
76
  name: 'query_lead_database',
70
- description: 'Query the B2B lead database directly. Returns contacts with names, emails, phones, titles, LinkedIn, Twitter and Facebook profiles, companies (plus company website, phone, revenue, total funding, founded year, HQ location and keywords). Up to 100 per request. Included with the $149/mo plan (100,000 new leads a day; leads you already have do not count again). For a daily pull of only new leads set excludeDelivered=true. For big pulls page with after: send after="0" first, then the pagination.next_after from each response until it is null. Have a saved people-search URL? Pass it as url to search with its filters right away (search_translation in the response says what was applied). Target by the technologies a company\'s website runs: technologies (any of), technologiesAll (all of), notTechnologies (none of), e.g. technologiesAll ["Klaviyo", "PayPal", "Shopify"] with notTechnologies ["Facebook Pixel"].',
77
+ description: 'BEFORE YOU SEND ANY OUTREACH, DO THIS: 1. Call query_lead_database with replaceLeftContacts=true. 2. Call check_run_status with the replacement.run_id it returns, every 30 seconds, until the status is SUCCEEDED. 3. Call download_results with that run_id. Send ONLY to rows whose Email Status is "valid" and whose Email Checked On date is within the last 30 days. People who left the company are already swapped for the person in that role now. If you cannot wait for the run: send ONLY to leads whose email_check_status is "valid" AND whose email_checked_on is within the last 30 days. Put every other email (not_checked, unknown, valid_catch_all, or checked more than 30 days ago) through validate_emails and send only to the ones it returns as "valid". Never send to "invalid". Use plan_search first when unsure of the filters. Query the B2B lead database directly. Returns contacts with names, emails, phones, titles, LinkedIn, Twitter and Facebook profiles, companies (plus company website, phone, revenue, total funding, founded year, HQ location and keywords). Up to 100 per request. Included on the $149/mo plan and up (100,000 new leads a day; leads you already have do not count again). On a trial or the $49 plan each new lead is paid from credits and leads you already have are free: the answer\'s billing block says what was charged and what is left, and when the credits run out part way it adds billing.not_returned and has_more (a 402 means none could be paid for; start_here gives the live prices). For a daily pull of only new leads set excludeDelivered=true. For big pulls page with after: send after="0" first, then the pagination.next_after from each response until it is null. Have a saved people-search URL? Pass it as url to search with its filters right away (search_translation in the response says what was applied). Target by the technologies a company\'s website runs: technologies (any of), technologiesAll (all of), notTechnologies (none of), e.g. technologiesAll ["Klaviyo", "PayPal", "Shopify"] with notTechnologies ["Facebook Pixel"].',
71
78
  inputSchema: { type: 'object', properties: {
72
79
  url: { type: 'string', description: 'A people-search URL (the address of a people search with its filters). Its filters become the search; any other filter you pass overrides the matching one.' },
73
80
  title: { type: 'string', description: 'Job title filter, comma separated for several (partial match, e.g. "CEO, Founder")' },
@@ -99,12 +106,13 @@ export const UTILITY_TOOLS = [
99
106
  page: { type: 'number', description: 'Page number (default 1)', default: 1 },
100
107
  limit: { type: 'number', description: 'Results per page (max 100)', default: 50 },
101
108
  excludeDelivered: { type: 'boolean', description: 'Skip leads this account already has (from the API or unlocked in the dashboard). With this on, keep page at 1 or use after.' },
102
- after: { type: 'string', description: 'Cursor paging: return leads after this lead id. Use "0" to start, then the pagination.next_after from each response.' }
109
+ after: { type: 'string', description: 'Cursor paging: return leads after this lead id. Use "0" to start, then the pagination.next_after from each response.' },
110
+ replaceLeftContacts: { type: 'boolean', description: 'Replace contacts who have left. The leads still come back now, plus replacement.run_id: a run that checks every email (again when its last check is over 30 days old) and swaps each person who has left the company for the person in that role now. Wait for it with check_run_status, then send the CSV from download_results, not the leads returned at once: send ONLY to rows whose Email Status is "valid" and whose Email Checked On is within the last 30 days. $0.02 per contact replaced, from your credits; free on the $649 plan.' }
103
111
  } }
104
112
  },
105
113
  {
106
114
  name: 'query_local_business_database',
107
- description: 'Query the local business database directly. Returns businesses with phone numbers, emails, websites, addresses and ratings, many with a named contact person. Up to 100 per request. Included with the $149/mo plan (100,000 new businesses a day; businesses you already have do not count again). Set hasContact=true for only businesses with a named contact person. Set maxLocations to skip chains: maxLocations=3 leaves out businesses whose website more than 3 businesses share. For a daily pull of only new businesses set excludeDelivered=true. For big pulls page with after: send after="0" first, then the pagination.next_after from each response until it is null. Search the way you would on Google Maps: keyword (what the businesses do or are called, e.g. ["thai restaurant"]) and location (cities, states, countries or postal codes, e.g. ["Houston TX", "Austin TX"]); searched_as in the response says how each was read. A search that finds nothing also returns lead_database: the same search in the Lead Database when it has 100+ people. Have a Google Maps search URL? Pass it as url to search with its keyword and place right away (search_translation in the response says what was applied).',
115
+ description: 'BEFORE YOU SEND ANY OUTREACH, DO THIS: 1. Use ONLY emails whose email_check_status (or contact_email_check_status for the contact person) is "valid" AND whose checked_on date is within the last 30 days. 2. Put every other email (not_checked, unknown, valid_catch_all, or checked more than 30 days ago) through validate_emails, and send only to the ones it returns as "valid". 3. Never send to "invalid". Use plan_search first when unsure of the filters. Query the local business database directly. Returns businesses with phone numbers, emails, websites, addresses and ratings, many with a named contact person. Up to 100 per request. Included on the $149/mo plan and up (100,000 new businesses a day; businesses you already have do not count again). On a trial or the $49 plan each new business is paid from credits and businesses you already have are free: the answer\'s billing block says what was charged and what is left, and when the credits run out part way it adds billing.not_returned and has_more (a 402 means none could be paid for; start_here gives the live prices). Set hasContact=true for only businesses with a named contact person. Set maxLocations to skip chains: maxLocations=3 leaves out businesses whose website more than 3 businesses share. For a daily pull of only new businesses set excludeDelivered=true. For big pulls page with after: send after="0" first, then the pagination.next_after from each response until it is null. Search the way you would on Google Maps: keyword (what the businesses do or are called, e.g. ["thai restaurant"]) and location (cities, states, countries or postal codes, e.g. ["Houston TX", "Austin TX"]); searched_as in the response says how each was read. A search that finds nothing also returns lead_database: the same search in the Lead Database when it has 100+ people. Have a Google Maps search URL? Pass it as url to search with its keyword and place right away (search_translation in the response says what was applied).',
108
116
  inputSchema: { type: 'object', properties: {
109
117
  keyword: { type: 'array', items: { type: 'string' }, description: 'What the businesses do or are called, as typed on Google Maps, e.g. ["thai restaurant", "sushi"]. Matches business names and categories; any keyword. A place inside a keyword ("plumbers in Austin TX") is used as the location when no location is given.' },
110
118
  location: { type: 'array', items: { type: 'string' }, description: 'Cities, states, countries or postal codes, as typed, e.g. ["Houston TX", "78701", "Ontario", "Germany"] (up to 2,000; any of them).' },
@@ -135,7 +143,7 @@ export const UTILITY_TOOLS = [
135
143
  },
136
144
  {
137
145
  name: 'query_ecommerce_database',
138
- description: 'Query the ecommerce store database directly. Returns online stores with platform, estimated monthly sales and visits, employee count, emails, phones and social links. Up to 100 per request. Included with the $149/mo plan (100,000 new stores a day; stores you already have do not count again). For a daily pull of only new stores set excludeDelivered=true. For big pulls page with after: send after="0" first, then the pagination.next_after from each response until it is null. Combine technologies (any of), technologiesAll (all of) and notTechnologies (none of) for exact targeting, e.g. technologiesAll ["Klaviyo", "PayPal"] with notTechnologies ["Facebook Pixel"].',
146
+ description: 'BEFORE YOU SEND ANY OUTREACH, DO THIS: 1. Use ONLY emails whose email_check_status (or contact_email_check_status for the contact person) is "valid" AND whose checked_on date is within the last 30 days. 2. Put every other email (not_checked, unknown, valid_catch_all, or checked more than 30 days ago) through validate_emails, and send only to the ones it returns as "valid". 3. Never send to "invalid". Use plan_search first when unsure of the filters. Query the ecommerce store database directly. Returns online stores with platform, estimated monthly sales and visits, employee count, emails, phones and social links. Up to 100 per request. Included on the $149/mo plan and up (100,000 new stores a day; stores you already have do not count again). On a trial or the $49 plan each new store is paid from credits and stores you already have are free: the answer\'s billing block says what was charged and what is left, and when the credits run out part way it adds billing.not_returned and has_more (a 402 means none could be paid for; start_here gives the live prices). For a daily pull of only new stores set excludeDelivered=true. For big pulls page with after: send after="0" first, then the pagination.next_after from each response until it is null. Combine technologies (any of), technologiesAll (all of) and notTechnologies (none of) for exact targeting, e.g. technologiesAll ["Klaviyo", "PayPal"] with notTechnologies ["Facebook Pixel"].',
139
147
  inputSchema: { type: 'object', properties: {
140
148
  platform: { type: 'array', items: { type: 'string' }, description: 'Ecommerce platforms, e.g. ["shopify", "woocommerce"] (any match)' },
141
149
  country: { type: 'array', items: { type: 'string' }, description: 'Two-letter country codes, e.g. ["US"]' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scrapercity",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "description": "ScraperCity SDK, CLI & MCP Server - B2B lead generation for AI agents and developers",
5
5
  "type": "module",
6
6
  "main": "./lib/index.mjs",