fofa-sdk
v0.0.2
Published
TypeScript SDK for FOFA API with full type safety and automatic retry support.
Readme
fofa-sdk
A TypeScript SDK for FOFA API.
Installation
pnpm add fofa-sdkUsage
Initialize Client
import { FofaClient } from 'fofa-sdk'
const client = new FofaClient({
key: 'your_api_key',
// Optional
baseUrl: 'https://fofa.info',
timeout: 30000,
retries: 3,
retryDelay: 1000,
})Search
const result = await client.search('title="bing"', {
fields: ['host', 'ip', 'port'],
page: 1,
size: 100,
full: false,
})
console.log(result.results)
// [{ host: 'example.com', ip: '1.2.3.4', port: '80' }, ...]Get User Info
const userInfo = await client.getUserInfo()
console.log(userInfo.email)
console.log(userInfo.fpoint)
console.log(userInfo.vip_level)API
FofaClient
Constructor Options
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| key | string | - | API key (required) |
| baseUrl | string | https://fofa.info | API base URL |
| timeout | number | 30000 | Request timeout (ms) |
| retries | number | 3 | Retry count |
| retryDelay | number | 1000 | Retry delay (ms) |
Methods
search(query, options?)
Search for hosts.
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| fields | FofaField[] | ['host', 'ip', 'port'] | Fields to return |
| page | number | 1 | Page number |
| size | number | 100 | Results per page (max 10000) |
| full | boolean | false | Search all data (default: last year) |
getUserInfo()
Get current user information.
Available Fields
type FofaField =
// No permission required
| 'ip' | 'port' | 'protocol' | 'country' | 'country_name'
| 'region' | 'city' | 'longitude' | 'latitude' | 'asn'
| 'org' | 'host' | 'domain' | 'os' | 'server' | 'icp'
| 'title' | 'jarm' | 'header' | 'banner' | 'cert'
| 'base_protocol' | 'link'
// Personal+
| 'header_hash' | 'banner_hash' | 'banner_fid'
// Professional+
| 'cname' | 'lastupdatetime' | 'product' | 'product_category'
// Business+
| 'product.version' | 'icon_hash' | 'cert.is_valid' | 'cname_domain' | 'body'
// Enterprise
| 'icon' | 'fid' | 'structinfo'License
MIT
