netriskscan-cli 1.1.0 → 1.3.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 +313 -81
- package/dist/cli.js +233 -65
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +77 -7
- package/dist/index.js +46 -18
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.3.0](https://github.com/TeamQQ/netriskscan-cli/compare/v1.2.0...v1.3.0) (2026-08-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **cli:** add anonymous IP check trial ([a02c9df](https://github.com/TeamQQ/netriskscan-cli/commit/a02c9df33fc443cba253d95770f8cb27d6435bdb))
|
|
7
|
+
|
|
8
|
+
# [1.2.0](https://github.com/TeamQQ/netriskscan-cli/compare/v1.1.0...v1.2.0) (2026-08-27)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **check:** add Explore footer and API key signup CTA ([dc68f27](https://github.com/TeamQQ/netriskscan-cli/commit/dc68f27b3c3c477e1dc8823a49358348c31869de))
|
|
14
|
+
|
|
1
15
|
# [1.1.0](https://github.com/TeamQQ/netriskscan-cli/compare/v1.0.0...v1.1.0) (2026-08-27)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -1,32 +1,93 @@
|
|
|
1
1
|
# NetRiskScan CLI
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Powered by the [NetRiskScan Developer API](#developer-api).
|
|
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.
|
|
6
5
|
|
|
7
6
|
[](https://github.com/TeamQQ/netriskscan-cli/actions/workflows/ci.yml)
|
|
8
7
|
[](https://www.npmjs.com/package/netriskscan-cli)
|
|
8
|
+
[](https://www.netriskscan.com)
|
|
9
9
|
[](LICENSE)
|
|
10
10
|
|
|
11
|
+
[Website](https://www.netriskscan.com) · [npm](https://www.npmjs.com/package/netriskscan-cli) · [Developer API](#developer-api) · [Official resources](#official-resources)
|
|
12
|
+
|
|
11
13
|
```bash
|
|
12
|
-
|
|
14
|
+
npx netriskscan-cli check 17.241.200.160
|
|
13
15
|
```
|
|
14
16
|
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
+
```text
|
|
18
|
+
NetRiskScan
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
IP 17.241.200.160
|
|
21
|
+
Index 97
|
|
22
|
+
Band excellent
|
|
23
|
+
Assessment complete
|
|
24
|
+
|
|
25
|
+
Network
|
|
26
|
+
Type public_infrastructure
|
|
27
|
+
Profile search_crawler
|
|
28
|
+
Service Applebot
|
|
29
|
+
Connection direct
|
|
30
|
+
ASN AS714
|
|
31
|
+
Organization Apple Inc.
|
|
32
|
+
|
|
33
|
+
Signals
|
|
34
|
+
Proxy No
|
|
35
|
+
VPN No
|
|
36
|
+
Tor No
|
|
37
|
+
Datacenter No
|
|
38
|
+
Scanner Unknown
|
|
39
|
+
Abuse No
|
|
40
|
+
|
|
41
|
+
Usage
|
|
42
|
+
Available 29
|
|
43
|
+
Daily Limit 30
|
|
44
|
+
Reset 2026-08-29 00:00 UTC
|
|
45
|
+
|
|
46
|
+
Request ID req_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
47
|
+
|
|
48
|
+
Explore
|
|
49
|
+
Web https://www.netriskscan.com
|
|
50
|
+
GitHub https://github.com/TeamQQ/netriskscan-cli
|
|
19
51
|
```
|
|
20
52
|
|
|
53
|
+
**No account or API key required** for the anonymous trial - the command above works on a
|
|
54
|
+
clean machine. The `Usage` block is the server telling you how much of today's free
|
|
55
|
+
allowance is left; the CLI never estimates it. Add an API key when you need more
|
|
56
|
+
(see [Getting an API key](#getting-an-api-key)).
|
|
57
|
+
|
|
58
|
+
Example output - actual values come from the live API and can change as reputation and
|
|
59
|
+
threat data changes.
|
|
60
|
+
|
|
61
|
+
## Why NetRiskScan?
|
|
62
|
+
|
|
63
|
+
- Known infrastructure identification for services such as search crawlers and public
|
|
64
|
+
infrastructure, instead of treating every address as a generic business or datacenter IP
|
|
65
|
+
- Proxy, VPN, Tor, abuse, blacklist and threat signals
|
|
66
|
+
- One normalized NetRiskScan Index instead of raw provider scores
|
|
67
|
+
- `unknown` and `not applicable` states are preserved, never collapsed into "false"
|
|
68
|
+
- Anonymous daily trial: run your first check with no account, no key, no configuration
|
|
69
|
+
- Human-readable CLI output plus JSON / JSONL for scripts, batches and CI
|
|
70
|
+
|
|
71
|
+
NetRiskScan can identify known infrastructure such as search crawlers, public DNS
|
|
72
|
+
resolvers and other published infrastructure, instead of treating every address as a
|
|
73
|
+
generic business or datacenter IP. Known infrastructure does not automatically mean
|
|
74
|
+
safe - proxy, VPN, Tor, abuse and threat signals are still evaluated separately on
|
|
75
|
+
every address. NetRiskScan normalizes multiple categories of evidence into one
|
|
76
|
+
consistent assessment rather than exposing a single provider's raw score.
|
|
77
|
+
|
|
21
78
|
> NetRiskScan provides diagnostic network intelligence. Results should not be treated as
|
|
22
79
|
> proof of malicious activity and should not be used as the sole basis for legal,
|
|
23
80
|
> employment, credit, identity, or other high-impact decisions.
|
|
24
81
|
|
|
82
|
+
Powered by the [NetRiskScan Developer API](#developer-api).
|
|
83
|
+
|
|
25
84
|
## Table of contents
|
|
26
85
|
|
|
86
|
+
- [Why NetRiskScan?](#why-netriskscan)
|
|
27
87
|
- [Introduction](#introduction)
|
|
28
88
|
- [Features](#features)
|
|
29
89
|
- [Installation](#installation)
|
|
90
|
+
- [Anonymous trial](#anonymous-trial)
|
|
30
91
|
- [Getting an API key](#getting-an-api-key)
|
|
31
92
|
- [Quick start](#quick-start)
|
|
32
93
|
- [IP risk check](#ip-risk-check)
|
|
@@ -42,15 +103,19 @@ netriskscan check 1.1.1.1
|
|
|
42
103
|
- [SDK usage](#sdk-usage)
|
|
43
104
|
- [Security](#security)
|
|
44
105
|
- [Developer API](#developer-api)
|
|
106
|
+
- [Official resources](#official-resources)
|
|
45
107
|
- [Contributing](#contributing)
|
|
46
108
|
- [License](#license)
|
|
47
109
|
|
|
48
110
|
## Introduction
|
|
49
111
|
|
|
50
|
-
`netriskscan-cli` is the official command-line client
|
|
51
|
-
[NetRiskScan](https://www.netriskscan.com)
|
|
52
|
-
|
|
53
|
-
|
|
112
|
+
`netriskscan-cli` is the official command-line client and thin TypeScript SDK for
|
|
113
|
+
[NetRiskScan](https://www.netriskscan.com), an IP reputation and network intelligence
|
|
114
|
+
service.
|
|
115
|
+
|
|
116
|
+
It connects to the NetRiskScan Developer API and returns machine-readable IP reputation
|
|
117
|
+
scores, network attribution, and risk signals. Give it an IP address, get back a result
|
|
118
|
+
you can pipe, gate on, or store.
|
|
54
119
|
|
|
55
120
|
This is a read-only diagnostic tool. It does not make decisions for you, and the CLI
|
|
56
121
|
never recomputes or approximates a risk score client-side - the `risk.index` returned by
|
|
@@ -58,6 +123,7 @@ the server is always the single source of truth.
|
|
|
58
123
|
|
|
59
124
|
## Features
|
|
60
125
|
|
|
126
|
+
- `check` and `batch` with no API key at all, via the anonymous daily trial
|
|
61
127
|
- `check`, `usage`, and client-side `batch` commands
|
|
62
128
|
- IPv4 and IPv6 support
|
|
63
129
|
- Human-readable terminal output, `--json`, and `--jsonl` (batch) modes
|
|
@@ -70,20 +136,85 @@ the server is always the single source of truth.
|
|
|
70
136
|
|
|
71
137
|
## Installation
|
|
72
138
|
|
|
139
|
+
Run it without installing anything:
|
|
140
|
+
|
|
73
141
|
```bash
|
|
74
|
-
|
|
142
|
+
npx netriskscan-cli check 1.1.1.1
|
|
75
143
|
```
|
|
76
144
|
|
|
77
|
-
Or
|
|
145
|
+
Or install it globally:
|
|
78
146
|
|
|
79
147
|
```bash
|
|
80
|
-
|
|
148
|
+
npm install -g netriskscan-cli
|
|
149
|
+
netriskscan check 1.1.1.1
|
|
81
150
|
```
|
|
82
151
|
|
|
83
152
|
Requires Node.js >= 20.
|
|
84
153
|
|
|
154
|
+
## Anonymous trial
|
|
155
|
+
|
|
156
|
+
`check` and `batch` work without any credentials. When no API key is configured, the CLI
|
|
157
|
+
sends **no** `Authorization` header at all, and the Developer API serves the request from
|
|
158
|
+
an anonymous daily trial metered by the caller's public IP (currently 30 requests per
|
|
159
|
+
public IP per UTC day - the allowance reported in the response is always the authority,
|
|
160
|
+
not this number).
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
npx netriskscan-cli check 8.8.8.8
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Every anonymous response reports where you stand, and the CLI prints it verbatim:
|
|
167
|
+
|
|
168
|
+
```text
|
|
169
|
+
Usage
|
|
170
|
+
Available 29
|
|
171
|
+
Daily Limit 30
|
|
172
|
+
Reset 2026-08-29 00:00 UTC
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`Available` is `usage.remaining` exactly as returned. The CLI keeps no local counter and
|
|
176
|
+
never recomputes it from `dailyLimit - used`.
|
|
177
|
+
|
|
178
|
+
When the day's allowance is spent, the next request returns
|
|
179
|
+
`429 anonymous_daily_limit_reached` and the CLI exits `5` with:
|
|
180
|
+
|
|
181
|
+
```text
|
|
182
|
+
NetRiskScan
|
|
183
|
+
|
|
184
|
+
Anonymous daily trial limit reached.
|
|
185
|
+
|
|
186
|
+
Usage
|
|
187
|
+
Available 0
|
|
188
|
+
Daily Limit 30
|
|
189
|
+
Reset 2026-08-29 00:00 UTC
|
|
190
|
+
|
|
191
|
+
Get more queries
|
|
192
|
+
https://www.netriskscan.com/developers
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
That response is deterministic until the reset, so it is **never** retried automatically.
|
|
196
|
+
|
|
197
|
+
Which commands need a key:
|
|
198
|
+
|
|
199
|
+
| Command | API key |
|
|
200
|
+
| ------------------- | --------------------------------------------------------------- |
|
|
201
|
+
| `netriskscan check` | Optional - anonymous trial when omitted |
|
|
202
|
+
| `netriskscan batch` | Optional - anonymous trial when omitted |
|
|
203
|
+
| `netriskscan usage` | **Required** - reports Developer Account plan and billing quota |
|
|
204
|
+
|
|
205
|
+
A key that the server rejects is never downgraded to an anonymous request: a configured
|
|
206
|
+
key that fails returns `401 invalid_api_key` and exit code `3`. The access mode is decided
|
|
207
|
+
purely by whether a key is present.
|
|
208
|
+
|
|
85
209
|
## Getting an API key
|
|
86
210
|
|
|
211
|
+
The anonymous trial does not require an API key. Create one when you need:
|
|
212
|
+
|
|
213
|
+
- more requests than the daily trial allows
|
|
214
|
+
- account quota instead of a per-IP allowance
|
|
215
|
+
- billing-period usage reporting (`netriskscan usage`)
|
|
216
|
+
- a production integration
|
|
217
|
+
|
|
87
218
|
1. Create a NetRiskScan Developer account and open the **Developer Dashboard**.
|
|
88
219
|
2. Go to **API Keys** and create one, selecting the scopes you need
|
|
89
220
|
(`ip-risk:read`, `usage:read`).
|
|
@@ -104,6 +235,14 @@ export NETRISKSCAN_API_KEY="nrs_live_xxx"
|
|
|
104
235
|
|
|
105
236
|
## Quick start
|
|
106
237
|
|
|
238
|
+
```bash
|
|
239
|
+
npx netriskscan-cli check 1.1.1.1
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
No setup required - no account, no key, no configuration file.
|
|
243
|
+
|
|
244
|
+
With an API key, for higher volume, account quota and `usage`:
|
|
245
|
+
|
|
107
246
|
```bash
|
|
108
247
|
export NETRISKSCAN_API_KEY="nrs_live_xxx"
|
|
109
248
|
|
|
@@ -118,7 +257,8 @@ netriskscan batch ips.txt --jsonl > results.jsonl
|
|
|
118
257
|
netriskscan check <ip> [options]
|
|
119
258
|
```
|
|
120
259
|
|
|
121
|
-
Calls `GET /v1/ip-risk/{ip}` - no query string parameters are ever sent.
|
|
260
|
+
Calls `GET /v1/ip-risk/{ip}` - no query string parameters are ever sent. An API key is
|
|
261
|
+
optional; without one the request uses the [anonymous trial](#anonymous-trial).
|
|
122
262
|
|
|
123
263
|
```bash
|
|
124
264
|
$ netriskscan check 1.1.1.1
|
|
@@ -169,17 +309,17 @@ you opt into CI policy checks with `--fail-below` (see [CI/CD](#cicd)).
|
|
|
169
309
|
|
|
170
310
|
### Options
|
|
171
311
|
|
|
172
|
-
| Option
|
|
173
|
-
|
|
|
174
|
-
| `--api-key <key>`
|
|
175
|
-
| `--base-url <url>`
|
|
176
|
-
| `--json`
|
|
177
|
-
| `--verbose`
|
|
178
|
-
| `--debug`
|
|
179
|
-
| `--timeout <ms>`
|
|
180
|
-
| `--max-retries <n>`
|
|
181
|
-
| `--fail-below <index>` | CI gate: exit non-zero if `risk.index` is below this threshold
|
|
182
|
-
| `--fail-on <flag>`
|
|
312
|
+
| Option | Description |
|
|
313
|
+
| ---------------------- | ----------------------------------------------------------------------------------------------- |
|
|
314
|
+
| `--api-key <key>` | API key for this call, optional (overrides `NETRISKSCAN_API_KEY`; anonymous trial when omitted) |
|
|
315
|
+
| `--base-url <url>` | Override the API base URL (advanced) |
|
|
316
|
+
| `--json` | Machine-readable JSON output (see [JSON output](#json-output)) |
|
|
317
|
+
| `--verbose` | Also print rate limit, quota, and request id |
|
|
318
|
+
| `--debug` | Print a stack trace / extra detail on failure |
|
|
319
|
+
| `--timeout <ms>` | Request timeout in milliseconds (default `10000`) |
|
|
320
|
+
| `--max-retries <n>` | Max automatic retries for `429`/`503` (default `3`) |
|
|
321
|
+
| `--fail-below <index>` | CI gate: exit non-zero if `risk.index` is below this threshold |
|
|
322
|
+
| `--fail-on <flag>` | CI gate: exit non-zero if the given flag is `true` (repeatable) |
|
|
183
323
|
|
|
184
324
|
## Usage & quota
|
|
185
325
|
|
|
@@ -187,7 +327,15 @@ you opt into CI policy checks with `--fail-below` (see [CI/CD](#cicd)).
|
|
|
187
327
|
netriskscan usage
|
|
188
328
|
```
|
|
189
329
|
|
|
190
|
-
Calls `GET /v1/usage
|
|
330
|
+
Calls `GET /v1/usage`. **This command requires an API key** (with the `usage:read`
|
|
331
|
+
scope): it reports Developer Account plan, billing period and quota, which has no
|
|
332
|
+
anonymous equivalent. Without a key it fails immediately, without sending a request:
|
|
333
|
+
|
|
334
|
+
```text
|
|
335
|
+
Error: An API key is required for the usage command.
|
|
336
|
+
|
|
337
|
+
Set NETRISKSCAN_API_KEY or use --api-key.
|
|
338
|
+
```
|
|
191
339
|
|
|
192
340
|
```bash
|
|
193
341
|
$ netriskscan usage
|
|
@@ -219,7 +367,9 @@ netriskscan batch <file> [options]
|
|
|
219
367
|
|
|
220
368
|
**Important:** NetRiskScan does not currently expose a server-side batch endpoint. This
|
|
221
369
|
command is a **client-side batch**: it sends individual `GET /v1/ip-risk/{ip}` requests
|
|
222
|
-
with a controlled concurrency limit.
|
|
370
|
+
with a controlled concurrency limit. An API key is optional here too - without one, every
|
|
371
|
+
request draws on the [anonymous trial](#anonymous-trial), and the summary reports what the
|
|
372
|
+
server says is left. It never calls `/v1/ip-risk/batch` or
|
|
223
373
|
`/v1/ip-risk/query` - those endpoints are not open and currently return
|
|
224
374
|
`404 feature_not_available`.
|
|
225
375
|
|
|
@@ -252,16 +402,34 @@ limits shown in your NetRiskScan Developer Dashboard for your plan.
|
|
|
252
402
|
|
|
253
403
|
A failure on one IP never drops the others - every input line gets a result.
|
|
254
404
|
|
|
405
|
+
Run anonymously and the human summary ends with the trial position:
|
|
406
|
+
|
|
407
|
+
```text
|
|
408
|
+
4 succeeded, 0 failed
|
|
409
|
+
|
|
410
|
+
Anonymous trial
|
|
411
|
+
Available 19
|
|
412
|
+
Daily Limit 30
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
`Available` is the **lowest** `usage.remaining` seen in the batch, because concurrent
|
|
416
|
+
responses do not arrive in the order the server charged them. If any request came back
|
|
417
|
+
`anonymous_daily_limit_reached`, it reports `0`. The CLI never rejects an input file for
|
|
418
|
+
being longer than the daily allowance: it cannot know how much of today's allowance you
|
|
419
|
+
have already spent - only the server can. `--jsonl` output is unaffected; each line's
|
|
420
|
+
`result.usage` object already carries this, and no plain text is ever mixed into the
|
|
421
|
+
stream.
|
|
422
|
+
|
|
255
423
|
### Options
|
|
256
424
|
|
|
257
|
-
| Option
|
|
258
|
-
|
|
|
259
|
-
| `--api-key <key>`
|
|
260
|
-
| `--base-url <url>`
|
|
261
|
-
| `--concurrency <n>` | Concurrent requests (default `5`, max `20`)
|
|
262
|
-
| `--jsonl`
|
|
263
|
-
| `--timeout <ms>`
|
|
264
|
-
| `--max-retries <n>` | Max automatic retries per request for `429`/`503` (default `3`)
|
|
425
|
+
| Option | Description |
|
|
426
|
+
| ------------------- | ---------------------------------------------------------------------------------------------- |
|
|
427
|
+
| `--api-key <key>` | API key for this run, optional (overrides `NETRISKSCAN_API_KEY`; anonymous trial when omitted) |
|
|
428
|
+
| `--base-url <url>` | Override the API base URL (advanced) |
|
|
429
|
+
| `--concurrency <n>` | Concurrent requests (default `5`, max `20`) |
|
|
430
|
+
| `--jsonl` | Newline-delimited JSON output (see [JSONL output](#jsonl-output)) |
|
|
431
|
+
| `--timeout <ms>` | Per-request timeout in milliseconds (default `10000`) |
|
|
432
|
+
| `--max-retries <n>` | Max automatic retries per request for `429`/`503` (default `3`) |
|
|
265
433
|
|
|
266
434
|
## JSON output
|
|
267
435
|
|
|
@@ -276,8 +444,20 @@ coerced to `false`, `0`, or a string):
|
|
|
276
444
|
{
|
|
277
445
|
"requestId": "req_8f3ab21c9d",
|
|
278
446
|
"risk": { "index": 72, "band": "good", "assessmentGrade": "complete" },
|
|
279
|
-
"network": {
|
|
280
|
-
|
|
447
|
+
"network": {
|
|
448
|
+
"type": "residential",
|
|
449
|
+
"connectionType": "isp",
|
|
450
|
+
"asn": "AS4134",
|
|
451
|
+
"organization": "China Telecom"
|
|
452
|
+
},
|
|
453
|
+
"flags": {
|
|
454
|
+
"proxy": false,
|
|
455
|
+
"vpn": false,
|
|
456
|
+
"tor": false,
|
|
457
|
+
"datacenter": false,
|
|
458
|
+
"scanner": false,
|
|
459
|
+
"abuse": false
|
|
460
|
+
}
|
|
281
461
|
}
|
|
282
462
|
```
|
|
283
463
|
|
|
@@ -326,23 +506,23 @@ Rules:
|
|
|
326
506
|
|
|
327
507
|
## Environment variables
|
|
328
508
|
|
|
329
|
-
| Variable
|
|
330
|
-
|
|
|
331
|
-
| `NETRISKSCAN_API_KEY`
|
|
332
|
-
| `NETRISKSCAN_BASE_URL` | Advanced: override the API base URL, used when `--base-url` is not passed
|
|
509
|
+
| Variable | Description |
|
|
510
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
511
|
+
| `NETRISKSCAN_API_KEY` | Default API key, used when `--api-key` is not passed. Optional for `check`/`batch`; required for `usage` |
|
|
512
|
+
| `NETRISKSCAN_BASE_URL` | Advanced: override the API base URL, used when `--base-url` is not passed |
|
|
333
513
|
|
|
334
514
|
## Exit codes
|
|
335
515
|
|
|
336
|
-
| Code | Meaning
|
|
337
|
-
|
|
|
338
|
-
| `0`
|
|
339
|
-
| `1`
|
|
340
|
-
| `2`
|
|
341
|
-
| `3`
|
|
342
|
-
| `4`
|
|
343
|
-
| `5`
|
|
344
|
-
| `6`
|
|
345
|
-
| `7`
|
|
516
|
+
| Code | Meaning |
|
|
517
|
+
| ---- | ------------------------------------------------------------------- |
|
|
518
|
+
| `0` | Success |
|
|
519
|
+
| `1` | General CLI error |
|
|
520
|
+
| `2` | Invalid CLI argument |
|
|
521
|
+
| `3` | Authentication / authorization failure |
|
|
522
|
+
| `4` | API request failure |
|
|
523
|
+
| `5` | Rate limit / quota exceeded, including the anonymous daily trial |
|
|
524
|
+
| `6` | CI policy failed (`--fail-below` / `--fail-on`) |
|
|
525
|
+
| `7` | Assessment unavailable (`--fail-below` used against a `null` index) |
|
|
346
526
|
|
|
347
527
|
These codes are stable and part of the CLI's public contract.
|
|
348
528
|
|
|
@@ -373,38 +553,58 @@ Request ID req_8f3ab21c9d
|
|
|
373
553
|
|
|
374
554
|
Known error codes:
|
|
375
555
|
|
|
376
|
-
| HTTP status | `error.code`
|
|
377
|
-
|
|
|
378
|
-
| 400
|
|
379
|
-
| 400
|
|
380
|
-
| 400
|
|
381
|
-
| 401
|
|
382
|
-
| 403
|
|
383
|
-
| 403
|
|
384
|
-
| 404
|
|
385
|
-
| 404
|
|
386
|
-
| 429
|
|
387
|
-
| 429
|
|
388
|
-
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
556
|
+
| HTTP status | `error.code` | Meaning |
|
|
557
|
+
| ----------- | ------------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
558
|
+
| 400 | `invalid_ip` | The address is not a valid IPv4/IPv6 address |
|
|
559
|
+
| 400 | `invalid_request` | Unsupported query parameter, or request too large |
|
|
560
|
+
| 400 | `unsupported_parameter` | e.g. `forceRefresh` / `force_refresh` / `refresh` - not supported |
|
|
561
|
+
| 401 | `invalid_api_key` | Missing/malformed `Authorization` header, or key doesn't exist |
|
|
562
|
+
| 403 | `api_key_disabled` | Key revoked/expired, or account/plan unavailable |
|
|
563
|
+
| 403 | `scope_not_allowed` | Key lacks the scope required for this endpoint |
|
|
564
|
+
| 404 | `not_found` | Unknown path |
|
|
565
|
+
| 404 | `feature_not_available` | Endpoint not yet available (e.g. batch, see above) |
|
|
566
|
+
| 429 | `rate_limit_exceeded` | Per-minute request limit exceeded |
|
|
567
|
+
| 429 | `quota_exceeded` | Billing-period quota exhausted |
|
|
568
|
+
| 429 | `anonymous_daily_limit_reached` | Anonymous daily trial exhausted. Never retried automatically - it cannot succeed before the UTC reset |
|
|
569
|
+
| 503 | `temporarily_unavailable` | Transient upstream/service issue - retry later |
|
|
570
|
+
|
|
571
|
+
Transient `429 rate_limit_exceeded` and `503` responses may be retried automatically,
|
|
572
|
+
honoring `Retry-After` when present and falling back to exponential backoff with jitter
|
|
573
|
+
otherwise. `anonymous_daily_limit_reached` is **never** retried, even though it is also a
|
|
574
|
+
`429`: the daily allowance cannot come back before the UTC reset, so retrying would only
|
|
575
|
+
repeat the same failure three more times. `400` / `401` / `403` / `404` are never retried
|
|
576
|
+
either.
|
|
393
577
|
|
|
394
578
|
Pass `--debug` to any command to include a stack trace on failure. Without it, errors
|
|
395
579
|
are shown as a clean summary - never a raw stack dump.
|
|
396
580
|
|
|
397
581
|
## Rate limits & quota
|
|
398
582
|
|
|
583
|
+
The anonymous daily trial and a plan's billing-period quota are different things, reported
|
|
584
|
+
through different channels. Do not read one as the other.
|
|
585
|
+
|
|
586
|
+
### Anonymous daily trial
|
|
587
|
+
|
|
588
|
+
Reported in the response body, on every request:
|
|
589
|
+
|
|
590
|
+
| Field | Meaning |
|
|
591
|
+
| ------------------ | ---------------------------------------------------------------- |
|
|
592
|
+
| `usage.mode` | `anonymous` when the request was served by the trial |
|
|
593
|
+
| `usage.remaining` | Requests still available today - authoritative, never recomputed |
|
|
594
|
+
| `usage.dailyLimit` | The trial's daily allowance |
|
|
595
|
+
| `usage.resetAt` | When the allowance resets (UTC day boundary) |
|
|
596
|
+
|
|
597
|
+
### API key quota
|
|
598
|
+
|
|
399
599
|
Every successful `/v1/*` response carries live rate limit and quota headers, so you
|
|
400
600
|
don't need a separate call to `/v1/usage` to know where you stand:
|
|
401
601
|
|
|
402
|
-
| Header
|
|
403
|
-
|
|
|
404
|
-
| `X-RateLimit-Limit` / `X-RateLimit-Remaining` / `X-RateLimit-Reset` | Per-minute limit
|
|
405
|
-
| `X-Quota-Limit` / `X-Quota-Used` / `X-Quota-Remaining`
|
|
406
|
-
| `X-Request-Id`
|
|
407
|
-
| `Retry-After`
|
|
602
|
+
| Header | Meaning |
|
|
603
|
+
| ------------------------------------------------------------------- | --------------------------------------------------- |
|
|
604
|
+
| `X-RateLimit-Limit` / `X-RateLimit-Remaining` / `X-RateLimit-Reset` | Per-minute limit |
|
|
605
|
+
| `X-Quota-Limit` / `X-Quota-Used` / `X-Quota-Remaining` | Billing-period quota |
|
|
606
|
+
| `X-Request-Id` | Request trace id (echoes yours, or a generated one) |
|
|
607
|
+
| `Retry-After` | Present on `429` responses |
|
|
408
608
|
|
|
409
609
|
See them with:
|
|
410
610
|
|
|
@@ -424,11 +624,31 @@ The API client is a standalone module, independent of the CLI layer, so it can b
|
|
|
424
624
|
directly from Node.js/TypeScript and will move to `@netriskscan/sdk` in a future release
|
|
425
625
|
without changing its shape:
|
|
426
626
|
|
|
627
|
+
The client needs no configuration at all. Without an API key it sends no `Authorization`
|
|
628
|
+
header and uses the anonymous trial:
|
|
629
|
+
|
|
630
|
+
```ts
|
|
631
|
+
import { NetRiskScanClient } from "netriskscan-cli";
|
|
632
|
+
|
|
633
|
+
const client = new NetRiskScanClient();
|
|
634
|
+
|
|
635
|
+
const { data } = await client.checkIp("1.1.1.1");
|
|
636
|
+
console.log(data.risk.index);
|
|
637
|
+
|
|
638
|
+
if (data.usage?.mode === "anonymous") {
|
|
639
|
+
console.log("available:", data.usage.remaining);
|
|
640
|
+
}
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
Pass `apiKey` to use Developer Account quota instead. `getUsage()` is account data and
|
|
644
|
+
always requires a key - without one it throws `NetRiskScanConfigError` before any request
|
|
645
|
+
is made:
|
|
646
|
+
|
|
427
647
|
```ts
|
|
428
648
|
import { NetRiskScanClient, NetRiskScanApiError } from "netriskscan-cli";
|
|
429
649
|
|
|
430
650
|
const client = new NetRiskScanClient({
|
|
431
|
-
apiKey: process.env.NETRISKSCAN_API_KEY
|
|
651
|
+
apiKey: process.env.NETRISKSCAN_API_KEY,
|
|
432
652
|
timeout: 10000,
|
|
433
653
|
maxRetries: 3,
|
|
434
654
|
});
|
|
@@ -467,9 +687,9 @@ See [examples/](examples/) for runnable scripts.
|
|
|
467
687
|
|
|
468
688
|
## Developer API
|
|
469
689
|
|
|
470
|
-
|
|
|
471
|
-
|
|
|
472
|
-
| Base URL
|
|
690
|
+
| | |
|
|
691
|
+
| --------------- | ------------------------------------------- |
|
|
692
|
+
| Base URL | `https://api.netriskscan.com` |
|
|
473
693
|
| Current version | `v1` (path prefix `/v1`, **not** `/api/v1`) |
|
|
474
694
|
|
|
475
695
|
This is a completely separate system from the netriskscan.com website's internal
|
|
@@ -478,8 +698,11 @@ guarantees between the two. `netriskscan-cli` only ever calls `/v1/*`.
|
|
|
478
698
|
|
|
479
699
|
Currently available endpoints:
|
|
480
700
|
|
|
481
|
-
- `GET /v1/ip-risk/{ip}`
|
|
482
|
-
-
|
|
701
|
+
- `GET /v1/ip-risk/{ip}`
|
|
702
|
+
- anonymous access supported
|
|
703
|
+
- API key optional
|
|
704
|
+
- API key requests use account quota and require `ip-risk:read`
|
|
705
|
+
- `GET /v1/usage` - requires an API key with `usage:read`
|
|
483
706
|
|
|
484
707
|
There is currently **no** server-side batch, history, or key-management endpoint
|
|
485
708
|
(`POST /v1/ip-risk/batch`, `POST /v1/ip-risk/query`, `GET /v1/history`,
|
|
@@ -492,6 +715,15 @@ See the official [Methodology](https://www.netriskscan.com/methodology.html) pag
|
|
|
492
715
|
how the NetRiskScan Index itself is computed (this project does not - and will not -
|
|
493
716
|
reimplement that logic client-side).
|
|
494
717
|
|
|
718
|
+
## Official resources
|
|
719
|
+
|
|
720
|
+
- [NetRiskScan](https://www.netriskscan.com) - web-based IP reputation and network
|
|
721
|
+
intelligence
|
|
722
|
+
- [NetRiskScan methodology](https://www.netriskscan.com/methodology.html) - how the
|
|
723
|
+
NetRiskScan Index and assessment model work
|
|
724
|
+
- [netriskscan-cli on npm](https://www.npmjs.com/package/netriskscan-cli)
|
|
725
|
+
- [GitHub repository](https://github.com/TeamQQ/netriskscan-cli)
|
|
726
|
+
|
|
495
727
|
## Contributing
|
|
496
728
|
|
|
497
729
|
See [CONTRIBUTING.md](CONTRIBUTING.md).
|