netriskscan-cli 1.2.0 → 1.4.0
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/CHANGELOG.md +14 -0
- package/README.md +306 -75
- package/dist/cli.js +272 -69
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +103 -7
- package/dist/index.js +46 -18
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.4.0](https://github.com/TeamQQ/netriskscan-cli/compare/v1.3.0...v1.4.0) (2026-09-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **check:** show proxy type and verified search crawler identity ([4386353](https://github.com/TeamQQ/netriskscan-cli/commit/43863534b3d51bb8ce7ba22ac5b0b07fc03c48ee))
|
|
7
|
+
|
|
8
|
+
# [1.3.0](https://github.com/TeamQQ/netriskscan-cli/compare/v1.2.0...v1.3.0) (2026-08-28)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **cli:** add anonymous IP check trial ([a02c9df](https://github.com/TeamQQ/netriskscan-cli/commit/a02c9df33fc443cba253d95770f8cb27d6435bdb))
|
|
14
|
+
|
|
1
15
|
# [1.2.0](https://github.com/TeamQQ/netriskscan-cli/compare/v1.1.0...v1.2.0) (2026-08-27)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
# NetRiskScan CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The official command-line client and TypeScript SDK for [NetRiskScan](https://www.netriskscan.com) -
|
|
4
|
+
IP reputation, risk assessment, and network intelligence directly from your terminal.
|
|
4
5
|
|
|
5
6
|
[](https://github.com/TeamQQ/netriskscan-cli/actions/workflows/ci.yml)
|
|
6
7
|
[](https://www.npmjs.com/package/netriskscan-cli)
|
|
8
|
+
[](https://www.netriskscan.com)
|
|
7
9
|
[](LICENSE)
|
|
8
10
|
|
|
11
|
+
[Website](https://www.netriskscan.com) · [npm](https://www.npmjs.com/package/netriskscan-cli) · [Developer API](#developer-api) · [Official resources](#official-resources)
|
|
12
|
+
|
|
9
13
|
```bash
|
|
10
14
|
npx netriskscan-cli check 17.241.200.160
|
|
11
15
|
```
|
|
@@ -28,22 +32,36 @@ Organization Apple Inc.
|
|
|
28
32
|
|
|
29
33
|
Signals
|
|
30
34
|
Proxy No
|
|
35
|
+
Proxy Type -
|
|
31
36
|
VPN No
|
|
32
37
|
Tor No
|
|
33
38
|
Datacenter No
|
|
34
39
|
Scanner Unknown
|
|
35
40
|
Abuse No
|
|
36
41
|
|
|
42
|
+
Identity
|
|
43
|
+
Search Crawler Yes
|
|
44
|
+
Crawler Applebot
|
|
45
|
+
|
|
46
|
+
Usage
|
|
47
|
+
Available 29
|
|
48
|
+
Daily Limit 30
|
|
49
|
+
Reset 2026-08-29 00:00 UTC
|
|
50
|
+
|
|
37
51
|
Request ID req_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
38
52
|
|
|
39
53
|
Explore
|
|
40
|
-
Web https://netriskscan.com
|
|
54
|
+
Web https://www.netriskscan.com
|
|
41
55
|
GitHub https://github.com/TeamQQ/netriskscan-cli
|
|
42
56
|
```
|
|
43
57
|
|
|
58
|
+
**No account or API key required** for the anonymous trial - the command above works on a
|
|
59
|
+
clean machine. The `Usage` block is the server telling you how much of today's free
|
|
60
|
+
allowance is left; the CLI never estimates it. Add an API key when you need more
|
|
61
|
+
(see [Getting an API key](#getting-an-api-key)).
|
|
62
|
+
|
|
44
63
|
Example output - actual values come from the live API and can change as reputation and
|
|
45
|
-
threat data changes.
|
|
46
|
-
the free plan needs no credit card.
|
|
64
|
+
threat data changes.
|
|
47
65
|
|
|
48
66
|
## Why NetRiskScan?
|
|
49
67
|
|
|
@@ -52,6 +70,7 @@ the free plan needs no credit card.
|
|
|
52
70
|
- Proxy, VPN, Tor, abuse, blacklist and threat signals
|
|
53
71
|
- One normalized NetRiskScan Index instead of raw provider scores
|
|
54
72
|
- `unknown` and `not applicable` states are preserved, never collapsed into "false"
|
|
73
|
+
- Anonymous daily trial: run your first check with no account, no key, no configuration
|
|
55
74
|
- Human-readable CLI output plus JSON / JSONL for scripts, batches and CI
|
|
56
75
|
|
|
57
76
|
NetRiskScan can identify known infrastructure such as search crawlers, public DNS
|
|
@@ -73,6 +92,7 @@ Powered by the [NetRiskScan Developer API](#developer-api).
|
|
|
73
92
|
- [Introduction](#introduction)
|
|
74
93
|
- [Features](#features)
|
|
75
94
|
- [Installation](#installation)
|
|
95
|
+
- [Anonymous trial](#anonymous-trial)
|
|
76
96
|
- [Getting an API key](#getting-an-api-key)
|
|
77
97
|
- [Quick start](#quick-start)
|
|
78
98
|
- [IP risk check](#ip-risk-check)
|
|
@@ -88,15 +108,19 @@ Powered by the [NetRiskScan Developer API](#developer-api).
|
|
|
88
108
|
- [SDK usage](#sdk-usage)
|
|
89
109
|
- [Security](#security)
|
|
90
110
|
- [Developer API](#developer-api)
|
|
111
|
+
- [Official resources](#official-resources)
|
|
91
112
|
- [Contributing](#contributing)
|
|
92
113
|
- [License](#license)
|
|
93
114
|
|
|
94
115
|
## Introduction
|
|
95
116
|
|
|
96
|
-
`netriskscan-cli` is the official command-line client
|
|
97
|
-
[NetRiskScan](https://www.netriskscan.com)
|
|
98
|
-
|
|
99
|
-
|
|
117
|
+
`netriskscan-cli` is the official command-line client and thin TypeScript SDK for
|
|
118
|
+
[NetRiskScan](https://www.netriskscan.com), an IP reputation and network intelligence
|
|
119
|
+
service.
|
|
120
|
+
|
|
121
|
+
It connects to the NetRiskScan Developer API and returns machine-readable IP reputation
|
|
122
|
+
scores, network attribution, and risk signals. Give it an IP address, get back a result
|
|
123
|
+
you can pipe, gate on, or store.
|
|
100
124
|
|
|
101
125
|
This is a read-only diagnostic tool. It does not make decisions for you, and the CLI
|
|
102
126
|
never recomputes or approximates a risk score client-side - the `risk.index` returned by
|
|
@@ -104,8 +128,11 @@ the server is always the single source of truth.
|
|
|
104
128
|
|
|
105
129
|
## Features
|
|
106
130
|
|
|
131
|
+
- `check` and `batch` with no API key at all, via the anonymous daily trial
|
|
107
132
|
- `check`, `usage`, and client-side `batch` commands
|
|
108
133
|
- IPv4 and IPv6 support
|
|
134
|
+
- Proxy type classification (residential, ISP, mobile, datacenter) for detected proxies,
|
|
135
|
+
and verified search crawler identity (Googlebot, Bingbot, Applebot, ...)
|
|
109
136
|
- Human-readable terminal output, `--json`, and `--jsonl` (batch) modes
|
|
110
137
|
- Correct three-state handling of risk flags (`true` / `false` / `null` - never coerced)
|
|
111
138
|
- CI-friendly exit codes and `--fail-below` / `--fail-on` policy gates
|
|
@@ -131,8 +158,70 @@ netriskscan check 1.1.1.1
|
|
|
131
158
|
|
|
132
159
|
Requires Node.js >= 20.
|
|
133
160
|
|
|
161
|
+
## Anonymous trial
|
|
162
|
+
|
|
163
|
+
`check` and `batch` work without any credentials. When no API key is configured, the CLI
|
|
164
|
+
sends **no** `Authorization` header at all, and the Developer API serves the request from
|
|
165
|
+
an anonymous daily trial metered by the caller's public IP (currently 30 requests per
|
|
166
|
+
public IP per UTC day - the allowance reported in the response is always the authority,
|
|
167
|
+
not this number).
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
npx netriskscan-cli check 8.8.8.8
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Every anonymous response reports where you stand, and the CLI prints it verbatim:
|
|
174
|
+
|
|
175
|
+
```text
|
|
176
|
+
Usage
|
|
177
|
+
Available 29
|
|
178
|
+
Daily Limit 30
|
|
179
|
+
Reset 2026-08-29 00:00 UTC
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
`Available` is `usage.remaining` exactly as returned. The CLI keeps no local counter and
|
|
183
|
+
never recomputes it from `dailyLimit - used`.
|
|
184
|
+
|
|
185
|
+
When the day's allowance is spent, the next request returns
|
|
186
|
+
`429 anonymous_daily_limit_reached` and the CLI exits `5` with:
|
|
187
|
+
|
|
188
|
+
```text
|
|
189
|
+
NetRiskScan
|
|
190
|
+
|
|
191
|
+
Anonymous daily trial limit reached.
|
|
192
|
+
|
|
193
|
+
Usage
|
|
194
|
+
Available 0
|
|
195
|
+
Daily Limit 30
|
|
196
|
+
Reset 2026-08-29 00:00 UTC
|
|
197
|
+
|
|
198
|
+
Get more queries
|
|
199
|
+
https://www.netriskscan.com/developers
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
That response is deterministic until the reset, so it is **never** retried automatically.
|
|
203
|
+
|
|
204
|
+
Which commands need a key:
|
|
205
|
+
|
|
206
|
+
| Command | API key |
|
|
207
|
+
| ------------------- | --------------------------------------------------------------- |
|
|
208
|
+
| `netriskscan check` | Optional - anonymous trial when omitted |
|
|
209
|
+
| `netriskscan batch` | Optional - anonymous trial when omitted |
|
|
210
|
+
| `netriskscan usage` | **Required** - reports Developer Account plan and billing quota |
|
|
211
|
+
|
|
212
|
+
A key that the server rejects is never downgraded to an anonymous request: a configured
|
|
213
|
+
key that fails returns `401 invalid_api_key` and exit code `3`. The access mode is decided
|
|
214
|
+
purely by whether a key is present.
|
|
215
|
+
|
|
134
216
|
## Getting an API key
|
|
135
217
|
|
|
218
|
+
The anonymous trial does not require an API key. Create one when you need:
|
|
219
|
+
|
|
220
|
+
- more requests than the daily trial allows
|
|
221
|
+
- account quota instead of a per-IP allowance
|
|
222
|
+
- billing-period usage reporting (`netriskscan usage`)
|
|
223
|
+
- a production integration
|
|
224
|
+
|
|
136
225
|
1. Create a NetRiskScan Developer account and open the **Developer Dashboard**.
|
|
137
226
|
2. Go to **API Keys** and create one, selecting the scopes you need
|
|
138
227
|
(`ip-risk:read`, `usage:read`).
|
|
@@ -153,6 +242,14 @@ export NETRISKSCAN_API_KEY="nrs_live_xxx"
|
|
|
153
242
|
|
|
154
243
|
## Quick start
|
|
155
244
|
|
|
245
|
+
```bash
|
|
246
|
+
npx netriskscan-cli check 1.1.1.1
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
No setup required - no account, no key, no configuration file.
|
|
250
|
+
|
|
251
|
+
With an API key, for higher volume, account quota and `usage`:
|
|
252
|
+
|
|
156
253
|
```bash
|
|
157
254
|
export NETRISKSCAN_API_KEY="nrs_live_xxx"
|
|
158
255
|
|
|
@@ -167,7 +264,8 @@ netriskscan batch ips.txt --jsonl > results.jsonl
|
|
|
167
264
|
netriskscan check <ip> [options]
|
|
168
265
|
```
|
|
169
266
|
|
|
170
|
-
Calls `GET /v1/ip-risk/{ip}` - no query string parameters are ever sent.
|
|
267
|
+
Calls `GET /v1/ip-risk/{ip}` - no query string parameters are ever sent. An API key is
|
|
268
|
+
optional; without one the request uses the [anonymous trial](#anonymous-trial).
|
|
171
269
|
|
|
172
270
|
```bash
|
|
173
271
|
$ netriskscan check 1.1.1.1
|
|
@@ -187,18 +285,50 @@ Organization Cloudflare, Inc.
|
|
|
187
285
|
|
|
188
286
|
Signals
|
|
189
287
|
Proxy No
|
|
288
|
+
Proxy Type -
|
|
190
289
|
VPN No
|
|
191
290
|
Tor No
|
|
192
291
|
Datacenter Unknown
|
|
193
292
|
Scanner No
|
|
194
293
|
Abuse No
|
|
195
294
|
|
|
295
|
+
Identity
|
|
296
|
+
Search Crawler No
|
|
297
|
+
Crawler -
|
|
298
|
+
|
|
196
299
|
Request ID req_xxxxxxxx
|
|
197
300
|
```
|
|
198
301
|
|
|
199
302
|
Output above is illustrative of the format - actual values always come from the live
|
|
200
303
|
API response.
|
|
201
304
|
|
|
305
|
+
### Proxy Type
|
|
306
|
+
|
|
307
|
+
`Proxy Type` is a classification detail for an address already detected as a proxy - it
|
|
308
|
+
refines `Proxy`, it does not replace it. It renders as `-`, not `Unknown`, whenever the
|
|
309
|
+
address is not a proxy at all:
|
|
310
|
+
|
|
311
|
+
```text
|
|
312
|
+
Signals
|
|
313
|
+
Proxy Yes
|
|
314
|
+
Proxy Type Residential Proxy
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
The server-reported machine value (`residential_proxy`, `isp_proxy`, `mobile_proxy`,
|
|
318
|
+
`datacenter_proxy`, `unknown_proxy`) is what `--json`/`--jsonl` carry; the CLI only maps
|
|
319
|
+
it to a human-readable label (`Residential Proxy`, `ISP Proxy`, ...) in the default
|
|
320
|
+
terminal output.
|
|
321
|
+
|
|
322
|
+
### Search Crawler
|
|
323
|
+
|
|
324
|
+
The `Identity` block shows whether the NetRiskScan API has verified this address as a
|
|
325
|
+
known search engine crawler, and if so, its canonical name (`Googlebot`, `Bingbot`,
|
|
326
|
+
`Applebot`, ...) exactly as the server sends it - the CLI never reformats, cases, or
|
|
327
|
+
enumerates crawler names locally. **The CLI does not perform crawler verification
|
|
328
|
+
itself; it only displays the classification the API already returned.** A verified
|
|
329
|
+
crawler is identity information, not a risk signal, so it never affects `risk.index`,
|
|
330
|
+
`--fail-on`, or the CLI's exit code.
|
|
331
|
+
|
|
202
332
|
### Addresses that can't be scored
|
|
203
333
|
|
|
204
334
|
Private, loopback, reserved, and other non-routable addresses still return `HTTP 200`,
|
|
@@ -218,17 +348,17 @@ you opt into CI policy checks with `--fail-below` (see [CI/CD](#cicd)).
|
|
|
218
348
|
|
|
219
349
|
### Options
|
|
220
350
|
|
|
221
|
-
| Option
|
|
222
|
-
|
|
|
223
|
-
| `--api-key <key>`
|
|
224
|
-
| `--base-url <url>`
|
|
225
|
-
| `--json`
|
|
226
|
-
| `--verbose`
|
|
227
|
-
| `--debug`
|
|
228
|
-
| `--timeout <ms>`
|
|
229
|
-
| `--max-retries <n>`
|
|
230
|
-
| `--fail-below <index>` | CI gate: exit non-zero if `risk.index` is below this threshold
|
|
231
|
-
| `--fail-on <flag>`
|
|
351
|
+
| Option | Description |
|
|
352
|
+
| ---------------------- | ----------------------------------------------------------------------------------------------- |
|
|
353
|
+
| `--api-key <key>` | API key for this call, optional (overrides `NETRISKSCAN_API_KEY`; anonymous trial when omitted) |
|
|
354
|
+
| `--base-url <url>` | Override the API base URL (advanced) |
|
|
355
|
+
| `--json` | Machine-readable JSON output (see [JSON output](#json-output)) |
|
|
356
|
+
| `--verbose` | Also print rate limit, quota, and request id |
|
|
357
|
+
| `--debug` | Print a stack trace / extra detail on failure |
|
|
358
|
+
| `--timeout <ms>` | Request timeout in milliseconds (default `10000`) |
|
|
359
|
+
| `--max-retries <n>` | Max automatic retries for `429`/`503` (default `3`) |
|
|
360
|
+
| `--fail-below <index>` | CI gate: exit non-zero if `risk.index` is below this threshold |
|
|
361
|
+
| `--fail-on <flag>` | CI gate: exit non-zero if the given flag is `true` (repeatable) |
|
|
232
362
|
|
|
233
363
|
## Usage & quota
|
|
234
364
|
|
|
@@ -236,7 +366,15 @@ you opt into CI policy checks with `--fail-below` (see [CI/CD](#cicd)).
|
|
|
236
366
|
netriskscan usage
|
|
237
367
|
```
|
|
238
368
|
|
|
239
|
-
Calls `GET /v1/usage
|
|
369
|
+
Calls `GET /v1/usage`. **This command requires an API key** (with the `usage:read`
|
|
370
|
+
scope): it reports Developer Account plan, billing period and quota, which has no
|
|
371
|
+
anonymous equivalent. Without a key it fails immediately, without sending a request:
|
|
372
|
+
|
|
373
|
+
```text
|
|
374
|
+
Error: An API key is required for the usage command.
|
|
375
|
+
|
|
376
|
+
Set NETRISKSCAN_API_KEY or use --api-key.
|
|
377
|
+
```
|
|
240
378
|
|
|
241
379
|
```bash
|
|
242
380
|
$ netriskscan usage
|
|
@@ -268,7 +406,9 @@ netriskscan batch <file> [options]
|
|
|
268
406
|
|
|
269
407
|
**Important:** NetRiskScan does not currently expose a server-side batch endpoint. This
|
|
270
408
|
command is a **client-side batch**: it sends individual `GET /v1/ip-risk/{ip}` requests
|
|
271
|
-
with a controlled concurrency limit.
|
|
409
|
+
with a controlled concurrency limit. An API key is optional here too - without one, every
|
|
410
|
+
request draws on the [anonymous trial](#anonymous-trial), and the summary reports what the
|
|
411
|
+
server says is left. It never calls `/v1/ip-risk/batch` or
|
|
272
412
|
`/v1/ip-risk/query` - those endpoints are not open and currently return
|
|
273
413
|
`404 feature_not_available`.
|
|
274
414
|
|
|
@@ -301,16 +441,34 @@ limits shown in your NetRiskScan Developer Dashboard for your plan.
|
|
|
301
441
|
|
|
302
442
|
A failure on one IP never drops the others - every input line gets a result.
|
|
303
443
|
|
|
444
|
+
Run anonymously and the human summary ends with the trial position:
|
|
445
|
+
|
|
446
|
+
```text
|
|
447
|
+
4 succeeded, 0 failed
|
|
448
|
+
|
|
449
|
+
Anonymous trial
|
|
450
|
+
Available 19
|
|
451
|
+
Daily Limit 30
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
`Available` is the **lowest** `usage.remaining` seen in the batch, because concurrent
|
|
455
|
+
responses do not arrive in the order the server charged them. If any request came back
|
|
456
|
+
`anonymous_daily_limit_reached`, it reports `0`. The CLI never rejects an input file for
|
|
457
|
+
being longer than the daily allowance: it cannot know how much of today's allowance you
|
|
458
|
+
have already spent - only the server can. `--jsonl` output is unaffected; each line's
|
|
459
|
+
`result.usage` object already carries this, and no plain text is ever mixed into the
|
|
460
|
+
stream.
|
|
461
|
+
|
|
304
462
|
### Options
|
|
305
463
|
|
|
306
|
-
| Option
|
|
307
|
-
|
|
|
308
|
-
| `--api-key <key>`
|
|
309
|
-
| `--base-url <url>`
|
|
310
|
-
| `--concurrency <n>` | Concurrent requests (default `5`, max `20`)
|
|
311
|
-
| `--jsonl`
|
|
312
|
-
| `--timeout <ms>`
|
|
313
|
-
| `--max-retries <n>` | Max automatic retries per request for `429`/`503` (default `3`)
|
|
464
|
+
| Option | Description |
|
|
465
|
+
| ------------------- | ---------------------------------------------------------------------------------------------- |
|
|
466
|
+
| `--api-key <key>` | API key for this run, optional (overrides `NETRISKSCAN_API_KEY`; anonymous trial when omitted) |
|
|
467
|
+
| `--base-url <url>` | Override the API base URL (advanced) |
|
|
468
|
+
| `--concurrency <n>` | Concurrent requests (default `5`, max `20`) |
|
|
469
|
+
| `--jsonl` | Newline-delimited JSON output (see [JSONL output](#jsonl-output)) |
|
|
470
|
+
| `--timeout <ms>` | Per-request timeout in milliseconds (default `10000`) |
|
|
471
|
+
| `--max-retries <n>` | Max automatic retries per request for `429`/`503` (default `3`) |
|
|
314
472
|
|
|
315
473
|
## JSON output
|
|
316
474
|
|
|
@@ -325,11 +483,32 @@ coerced to `false`, `0`, or a string):
|
|
|
325
483
|
{
|
|
326
484
|
"requestId": "req_8f3ab21c9d",
|
|
327
485
|
"risk": { "index": 72, "band": "good", "assessmentGrade": "complete" },
|
|
328
|
-
"network": {
|
|
329
|
-
|
|
486
|
+
"network": {
|
|
487
|
+
"type": "residential",
|
|
488
|
+
"connectionType": "isp",
|
|
489
|
+
"asn": "AS4134",
|
|
490
|
+
"organization": "China Telecom"
|
|
491
|
+
},
|
|
492
|
+
"flags": {
|
|
493
|
+
"proxy": false,
|
|
494
|
+
"proxyType": null,
|
|
495
|
+
"vpn": false,
|
|
496
|
+
"tor": false,
|
|
497
|
+
"datacenter": false,
|
|
498
|
+
"scanner": false,
|
|
499
|
+
"abuse": false,
|
|
500
|
+
"searchCrawler": false,
|
|
501
|
+
"searchCrawlerName": null
|
|
502
|
+
}
|
|
330
503
|
}
|
|
331
504
|
```
|
|
332
505
|
|
|
506
|
+
`flags.proxyType` (when `flags.proxy` is `true`), `flags.searchCrawler`, and
|
|
507
|
+
`flags.searchCrawlerName` carry the server's raw machine values in `--json`/`--jsonl` -
|
|
508
|
+
e.g. `"residential_proxy"`, never the `Residential Proxy` label shown in the default
|
|
509
|
+
terminal output. A server that predates these fields simply omits the keys; the CLI
|
|
510
|
+
does not synthesize them.
|
|
511
|
+
|
|
333
512
|
In `--json` mode there is no spinner, no ANSI color, and no banner - stdout carries only
|
|
334
513
|
the JSON. Errors always go to stderr, so this composes cleanly:
|
|
335
514
|
|
|
@@ -375,23 +554,23 @@ Rules:
|
|
|
375
554
|
|
|
376
555
|
## Environment variables
|
|
377
556
|
|
|
378
|
-
| Variable
|
|
379
|
-
|
|
|
380
|
-
| `NETRISKSCAN_API_KEY`
|
|
381
|
-
| `NETRISKSCAN_BASE_URL` | Advanced: override the API base URL, used when `--base-url` is not passed
|
|
557
|
+
| Variable | Description |
|
|
558
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
559
|
+
| `NETRISKSCAN_API_KEY` | Default API key, used when `--api-key` is not passed. Optional for `check`/`batch`; required for `usage` |
|
|
560
|
+
| `NETRISKSCAN_BASE_URL` | Advanced: override the API base URL, used when `--base-url` is not passed |
|
|
382
561
|
|
|
383
562
|
## Exit codes
|
|
384
563
|
|
|
385
|
-
| Code | Meaning
|
|
386
|
-
|
|
|
387
|
-
| `0`
|
|
388
|
-
| `1`
|
|
389
|
-
| `2`
|
|
390
|
-
| `3`
|
|
391
|
-
| `4`
|
|
392
|
-
| `5`
|
|
393
|
-
| `6`
|
|
394
|
-
| `7`
|
|
564
|
+
| Code | Meaning |
|
|
565
|
+
| ---- | ------------------------------------------------------------------- |
|
|
566
|
+
| `0` | Success |
|
|
567
|
+
| `1` | General CLI error |
|
|
568
|
+
| `2` | Invalid CLI argument |
|
|
569
|
+
| `3` | Authentication / authorization failure |
|
|
570
|
+
| `4` | API request failure |
|
|
571
|
+
| `5` | Rate limit / quota exceeded, including the anonymous daily trial |
|
|
572
|
+
| `6` | CI policy failed (`--fail-below` / `--fail-on`) |
|
|
573
|
+
| `7` | Assessment unavailable (`--fail-below` used against a `null` index) |
|
|
395
574
|
|
|
396
575
|
These codes are stable and part of the CLI's public contract.
|
|
397
576
|
|
|
@@ -422,38 +601,58 @@ Request ID req_8f3ab21c9d
|
|
|
422
601
|
|
|
423
602
|
Known error codes:
|
|
424
603
|
|
|
425
|
-
| HTTP status | `error.code`
|
|
426
|
-
|
|
|
427
|
-
| 400
|
|
428
|
-
| 400
|
|
429
|
-
| 400
|
|
430
|
-
| 401
|
|
431
|
-
| 403
|
|
432
|
-
| 403
|
|
433
|
-
| 404
|
|
434
|
-
| 404
|
|
435
|
-
| 429
|
|
436
|
-
| 429
|
|
437
|
-
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
604
|
+
| HTTP status | `error.code` | Meaning |
|
|
605
|
+
| ----------- | ------------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
606
|
+
| 400 | `invalid_ip` | The address is not a valid IPv4/IPv6 address |
|
|
607
|
+
| 400 | `invalid_request` | Unsupported query parameter, or request too large |
|
|
608
|
+
| 400 | `unsupported_parameter` | e.g. `forceRefresh` / `force_refresh` / `refresh` - not supported |
|
|
609
|
+
| 401 | `invalid_api_key` | Missing/malformed `Authorization` header, or key doesn't exist |
|
|
610
|
+
| 403 | `api_key_disabled` | Key revoked/expired, or account/plan unavailable |
|
|
611
|
+
| 403 | `scope_not_allowed` | Key lacks the scope required for this endpoint |
|
|
612
|
+
| 404 | `not_found` | Unknown path |
|
|
613
|
+
| 404 | `feature_not_available` | Endpoint not yet available (e.g. batch, see above) |
|
|
614
|
+
| 429 | `rate_limit_exceeded` | Per-minute request limit exceeded |
|
|
615
|
+
| 429 | `quota_exceeded` | Billing-period quota exhausted |
|
|
616
|
+
| 429 | `anonymous_daily_limit_reached` | Anonymous daily trial exhausted. Never retried automatically - it cannot succeed before the UTC reset |
|
|
617
|
+
| 503 | `temporarily_unavailable` | Transient upstream/service issue - retry later |
|
|
618
|
+
|
|
619
|
+
Transient `429 rate_limit_exceeded` and `503` responses may be retried automatically,
|
|
620
|
+
honoring `Retry-After` when present and falling back to exponential backoff with jitter
|
|
621
|
+
otherwise. `anonymous_daily_limit_reached` is **never** retried, even though it is also a
|
|
622
|
+
`429`: the daily allowance cannot come back before the UTC reset, so retrying would only
|
|
623
|
+
repeat the same failure three more times. `400` / `401` / `403` / `404` are never retried
|
|
624
|
+
either.
|
|
442
625
|
|
|
443
626
|
Pass `--debug` to any command to include a stack trace on failure. Without it, errors
|
|
444
627
|
are shown as a clean summary - never a raw stack dump.
|
|
445
628
|
|
|
446
629
|
## Rate limits & quota
|
|
447
630
|
|
|
631
|
+
The anonymous daily trial and a plan's billing-period quota are different things, reported
|
|
632
|
+
through different channels. Do not read one as the other.
|
|
633
|
+
|
|
634
|
+
### Anonymous daily trial
|
|
635
|
+
|
|
636
|
+
Reported in the response body, on every request:
|
|
637
|
+
|
|
638
|
+
| Field | Meaning |
|
|
639
|
+
| ------------------ | ---------------------------------------------------------------- |
|
|
640
|
+
| `usage.mode` | `anonymous` when the request was served by the trial |
|
|
641
|
+
| `usage.remaining` | Requests still available today - authoritative, never recomputed |
|
|
642
|
+
| `usage.dailyLimit` | The trial's daily allowance |
|
|
643
|
+
| `usage.resetAt` | When the allowance resets (UTC day boundary) |
|
|
644
|
+
|
|
645
|
+
### API key quota
|
|
646
|
+
|
|
448
647
|
Every successful `/v1/*` response carries live rate limit and quota headers, so you
|
|
449
648
|
don't need a separate call to `/v1/usage` to know where you stand:
|
|
450
649
|
|
|
451
|
-
| Header
|
|
452
|
-
|
|
|
453
|
-
| `X-RateLimit-Limit` / `X-RateLimit-Remaining` / `X-RateLimit-Reset` | Per-minute limit
|
|
454
|
-
| `X-Quota-Limit` / `X-Quota-Used` / `X-Quota-Remaining`
|
|
455
|
-
| `X-Request-Id`
|
|
456
|
-
| `Retry-After`
|
|
650
|
+
| Header | Meaning |
|
|
651
|
+
| ------------------------------------------------------------------- | --------------------------------------------------- |
|
|
652
|
+
| `X-RateLimit-Limit` / `X-RateLimit-Remaining` / `X-RateLimit-Reset` | Per-minute limit |
|
|
653
|
+
| `X-Quota-Limit` / `X-Quota-Used` / `X-Quota-Remaining` | Billing-period quota |
|
|
654
|
+
| `X-Request-Id` | Request trace id (echoes yours, or a generated one) |
|
|
655
|
+
| `Retry-After` | Present on `429` responses |
|
|
457
656
|
|
|
458
657
|
See them with:
|
|
459
658
|
|
|
@@ -473,11 +672,31 @@ The API client is a standalone module, independent of the CLI layer, so it can b
|
|
|
473
672
|
directly from Node.js/TypeScript and will move to `@netriskscan/sdk` in a future release
|
|
474
673
|
without changing its shape:
|
|
475
674
|
|
|
675
|
+
The client needs no configuration at all. Without an API key it sends no `Authorization`
|
|
676
|
+
header and uses the anonymous trial:
|
|
677
|
+
|
|
678
|
+
```ts
|
|
679
|
+
import { NetRiskScanClient } from "netriskscan-cli";
|
|
680
|
+
|
|
681
|
+
const client = new NetRiskScanClient();
|
|
682
|
+
|
|
683
|
+
const { data } = await client.checkIp("1.1.1.1");
|
|
684
|
+
console.log(data.risk.index);
|
|
685
|
+
|
|
686
|
+
if (data.usage?.mode === "anonymous") {
|
|
687
|
+
console.log("available:", data.usage.remaining);
|
|
688
|
+
}
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
Pass `apiKey` to use Developer Account quota instead. `getUsage()` is account data and
|
|
692
|
+
always requires a key - without one it throws `NetRiskScanConfigError` before any request
|
|
693
|
+
is made:
|
|
694
|
+
|
|
476
695
|
```ts
|
|
477
696
|
import { NetRiskScanClient, NetRiskScanApiError } from "netriskscan-cli";
|
|
478
697
|
|
|
479
698
|
const client = new NetRiskScanClient({
|
|
480
|
-
apiKey: process.env.NETRISKSCAN_API_KEY
|
|
699
|
+
apiKey: process.env.NETRISKSCAN_API_KEY,
|
|
481
700
|
timeout: 10000,
|
|
482
701
|
maxRetries: 3,
|
|
483
702
|
});
|
|
@@ -516,9 +735,9 @@ See [examples/](examples/) for runnable scripts.
|
|
|
516
735
|
|
|
517
736
|
## Developer API
|
|
518
737
|
|
|
519
|
-
|
|
|
520
|
-
|
|
|
521
|
-
| Base URL
|
|
738
|
+
| | |
|
|
739
|
+
| --------------- | ------------------------------------------- |
|
|
740
|
+
| Base URL | `https://api.netriskscan.com` |
|
|
522
741
|
| Current version | `v1` (path prefix `/v1`, **not** `/api/v1`) |
|
|
523
742
|
|
|
524
743
|
This is a completely separate system from the netriskscan.com website's internal
|
|
@@ -527,8 +746,11 @@ guarantees between the two. `netriskscan-cli` only ever calls `/v1/*`.
|
|
|
527
746
|
|
|
528
747
|
Currently available endpoints:
|
|
529
748
|
|
|
530
|
-
- `GET /v1/ip-risk/{ip}`
|
|
531
|
-
-
|
|
749
|
+
- `GET /v1/ip-risk/{ip}`
|
|
750
|
+
- anonymous access supported
|
|
751
|
+
- API key optional
|
|
752
|
+
- API key requests use account quota and require `ip-risk:read`
|
|
753
|
+
- `GET /v1/usage` - requires an API key with `usage:read`
|
|
532
754
|
|
|
533
755
|
There is currently **no** server-side batch, history, or key-management endpoint
|
|
534
756
|
(`POST /v1/ip-risk/batch`, `POST /v1/ip-risk/query`, `GET /v1/history`,
|
|
@@ -541,6 +763,15 @@ See the official [Methodology](https://www.netriskscan.com/methodology.html) pag
|
|
|
541
763
|
how the NetRiskScan Index itself is computed (this project does not - and will not -
|
|
542
764
|
reimplement that logic client-side).
|
|
543
765
|
|
|
766
|
+
## Official resources
|
|
767
|
+
|
|
768
|
+
- [NetRiskScan](https://www.netriskscan.com) - web-based IP reputation and network
|
|
769
|
+
intelligence
|
|
770
|
+
- [NetRiskScan methodology](https://www.netriskscan.com/methodology.html) - how the
|
|
771
|
+
NetRiskScan Index and assessment model work
|
|
772
|
+
- [netriskscan-cli on npm](https://www.npmjs.com/package/netriskscan-cli)
|
|
773
|
+
- [GitHub repository](https://github.com/TeamQQ/netriskscan-cli)
|
|
774
|
+
|
|
544
775
|
## Contributing
|
|
545
776
|
|
|
546
777
|
See [CONTRIBUTING.md](CONTRIBUTING.md).
|