searchhive-js
v1.1.0
Published
TypeScript SDK for the SearchHive API
Readme
searchhive-js
TypeScript SDK for the SearchHive API. Zero runtime dependencies — uses native fetch.
Install
npm install searchhive-jsSetup
import { SearchHive } from "searchhive-js";
const client = new SearchHive({ apiKey: "sk_live_..." });
// Or custom base URL:
// const client = new SearchHive({ apiKey: "sk_live_...", baseUrl: "https://your-instance.com/api/v1" });Methods
client.swiftSearch({ query, max_results?, auto_scrape_top?, include_contacts?, include_social? })
Search + optional auto-scraping, contacts, and social profiles.
const res = await client.swiftSearch({
query: "best AI tools 2025",
max_results: 10,
auto_scrape_top: 3,
include_contacts: true,
include_social: true,
});
console.log(res.search_results); // [{title, link, snippet, position, date}]
console.log(res.scraped_content); // [{url, title, text, links, images, metadata, error}]
console.log(res.contacts); // [{type, value, source_url, source_title}]
console.log(res.social_profiles); // [{platform, url, username, source_url, source_title}]
console.log(res.credits_used, res.remaining_credits);client.scrapeForge({ url, extract?, wait_for?, timeout?, use_browser? })
Scrape a single URL.
const res = await client.scrapeForge({
url: "https://example.com",
extract: ["h1", ".main-content"],
wait_for: "article.loaded",
timeout: 30,
use_browser: false,
});
console.log(res.title, res.text);
console.log(res.credits_used);client.deepDive({ query, max_pages?, extract_content?, include_domains?, exclude_domains? })
Deep research: search + multi-page scraping + summary.
const res = await client.deepDive({
query: "Rust vs Go performance comparison",
max_pages: 5,
extract_content: true,
});
console.log(res.summary);
console.log(res.scraped_content);
console.log(res.credits_used, res.remaining_credits);client.batchScrape({ urls, extract?, timeout?, use_browser? })
Scrape multiple URLs in one request.
const results = await client.batchScrape({
urls: ["https://example.com", "https://other.com"],
timeout: 30,
});client.health()
Check API status.
const { status } = await client.health();Error Handling
import { SearchHiveError, RateLimitError, AuthenticationError } from "searchhive-js";
try {
await client.swiftSearch({ query: "test" });
} catch (err) {
if (err instanceof AuthenticationError) {
// Invalid API key
} else if (err instanceof RateLimitError) {
// 429 — back off
} else if (err instanceof SearchHiveError) {
console.log(err.status, err.message);
}
}Backwards Compatibility
Old method names still work as aliases:
| Old | New |
|-----|-----|
| client.search() | client.swiftSearch() |
| client.scrape() | client.scrapeForge() |
| client.research() | client.deepDive() |
| client.batchScrape() | (unchanged) |
These are marked @deprecated and will be removed in a future version.
License
MIT
