netriskscan-cli 1.2.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 +7 -0
- package/README.md +258 -75
- package/dist/cli.js +228 -67
- 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 +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
# [1.2.0](https://github.com/TeamQQ/netriskscan-cli/compare/v1.1.0...v1.2.0) (2026-08-27)
|
|
2
9
|
|
|
3
10
|
|
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
|
```
|
|
@@ -34,16 +38,25 @@ Datacenter No
|
|
|
34
38
|
Scanner Unknown
|
|
35
39
|
Abuse No
|
|
36
40
|
|
|
41
|
+
Usage
|
|
42
|
+
Available 29
|
|
43
|
+
Daily Limit 30
|
|
44
|
+
Reset 2026-08-29 00:00 UTC
|
|
45
|
+
|
|
37
46
|
Request ID req_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
38
47
|
|
|
39
48
|
Explore
|
|
40
|
-
Web https://netriskscan.com
|
|
49
|
+
Web https://www.netriskscan.com
|
|
41
50
|
GitHub https://github.com/TeamQQ/netriskscan-cli
|
|
42
51
|
```
|
|
43
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
|
+
|
|
44
58
|
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.
|
|
59
|
+
threat data changes.
|
|
47
60
|
|
|
48
61
|
## Why NetRiskScan?
|
|
49
62
|
|
|
@@ -52,6 +65,7 @@ the free plan needs no credit card.
|
|
|
52
65
|
- Proxy, VPN, Tor, abuse, blacklist and threat signals
|
|
53
66
|
- One normalized NetRiskScan Index instead of raw provider scores
|
|
54
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
|
|
55
69
|
- Human-readable CLI output plus JSON / JSONL for scripts, batches and CI
|
|
56
70
|
|
|
57
71
|
NetRiskScan can identify known infrastructure such as search crawlers, public DNS
|
|
@@ -73,6 +87,7 @@ Powered by the [NetRiskScan Developer API](#developer-api).
|
|
|
73
87
|
- [Introduction](#introduction)
|
|
74
88
|
- [Features](#features)
|
|
75
89
|
- [Installation](#installation)
|
|
90
|
+
- [Anonymous trial](#anonymous-trial)
|
|
76
91
|
- [Getting an API key](#getting-an-api-key)
|
|
77
92
|
- [Quick start](#quick-start)
|
|
78
93
|
- [IP risk check](#ip-risk-check)
|
|
@@ -88,15 +103,19 @@ Powered by the [NetRiskScan Developer API](#developer-api).
|
|
|
88
103
|
- [SDK usage](#sdk-usage)
|
|
89
104
|
- [Security](#security)
|
|
90
105
|
- [Developer API](#developer-api)
|
|
106
|
+
- [Official resources](#official-resources)
|
|
91
107
|
- [Contributing](#contributing)
|
|
92
108
|
- [License](#license)
|
|
93
109
|
|
|
94
110
|
## Introduction
|
|
95
111
|
|
|
96
|
-
`netriskscan-cli` is the official command-line client
|
|
97
|
-
[NetRiskScan](https://www.netriskscan.com)
|
|
98
|
-
|
|
99
|
-
|
|
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.
|
|
100
119
|
|
|
101
120
|
This is a read-only diagnostic tool. It does not make decisions for you, and the CLI
|
|
102
121
|
never recomputes or approximates a risk score client-side - the `risk.index` returned by
|
|
@@ -104,6 +123,7 @@ the server is always the single source of truth.
|
|
|
104
123
|
|
|
105
124
|
## Features
|
|
106
125
|
|
|
126
|
+
- `check` and `batch` with no API key at all, via the anonymous daily trial
|
|
107
127
|
- `check`, `usage`, and client-side `batch` commands
|
|
108
128
|
- IPv4 and IPv6 support
|
|
109
129
|
- Human-readable terminal output, `--json`, and `--jsonl` (batch) modes
|
|
@@ -131,8 +151,70 @@ netriskscan check 1.1.1.1
|
|
|
131
151
|
|
|
132
152
|
Requires Node.js >= 20.
|
|
133
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
|
+
|
|
134
209
|
## Getting an API key
|
|
135
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
|
+
|
|
136
218
|
1. Create a NetRiskScan Developer account and open the **Developer Dashboard**.
|
|
137
219
|
2. Go to **API Keys** and create one, selecting the scopes you need
|
|
138
220
|
(`ip-risk:read`, `usage:read`).
|
|
@@ -153,6 +235,14 @@ export NETRISKSCAN_API_KEY="nrs_live_xxx"
|
|
|
153
235
|
|
|
154
236
|
## Quick start
|
|
155
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
|
+
|
|
156
246
|
```bash
|
|
157
247
|
export NETRISKSCAN_API_KEY="nrs_live_xxx"
|
|
158
248
|
|
|
@@ -167,7 +257,8 @@ netriskscan batch ips.txt --jsonl > results.jsonl
|
|
|
167
257
|
netriskscan check <ip> [options]
|
|
168
258
|
```
|
|
169
259
|
|
|
170
|
-
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).
|
|
171
262
|
|
|
172
263
|
```bash
|
|
173
264
|
$ netriskscan check 1.1.1.1
|
|
@@ -218,17 +309,17 @@ you opt into CI policy checks with `--fail-below` (see [CI/CD](#cicd)).
|
|
|
218
309
|
|
|
219
310
|
### Options
|
|
220
311
|
|
|
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>`
|
|
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) |
|
|
232
323
|
|
|
233
324
|
## Usage & quota
|
|
234
325
|
|
|
@@ -236,7 +327,15 @@ you opt into CI policy checks with `--fail-below` (see [CI/CD](#cicd)).
|
|
|
236
327
|
netriskscan usage
|
|
237
328
|
```
|
|
238
329
|
|
|
239
|
-
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
|
+
```
|
|
240
339
|
|
|
241
340
|
```bash
|
|
242
341
|
$ netriskscan usage
|
|
@@ -268,7 +367,9 @@ netriskscan batch <file> [options]
|
|
|
268
367
|
|
|
269
368
|
**Important:** NetRiskScan does not currently expose a server-side batch endpoint. This
|
|
270
369
|
command is a **client-side batch**: it sends individual `GET /v1/ip-risk/{ip}` requests
|
|
271
|
-
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
|
|
272
373
|
`/v1/ip-risk/query` - those endpoints are not open and currently return
|
|
273
374
|
`404 feature_not_available`.
|
|
274
375
|
|
|
@@ -301,16 +402,34 @@ limits shown in your NetRiskScan Developer Dashboard for your plan.
|
|
|
301
402
|
|
|
302
403
|
A failure on one IP never drops the others - every input line gets a result.
|
|
303
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
|
+
|
|
304
423
|
### Options
|
|
305
424
|
|
|
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`)
|
|
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`) |
|
|
314
433
|
|
|
315
434
|
## JSON output
|
|
316
435
|
|
|
@@ -325,8 +444,20 @@ coerced to `false`, `0`, or a string):
|
|
|
325
444
|
{
|
|
326
445
|
"requestId": "req_8f3ab21c9d",
|
|
327
446
|
"risk": { "index": 72, "band": "good", "assessmentGrade": "complete" },
|
|
328
|
-
"network": {
|
|
329
|
-
|
|
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
|
+
}
|
|
330
461
|
}
|
|
331
462
|
```
|
|
332
463
|
|
|
@@ -375,23 +506,23 @@ Rules:
|
|
|
375
506
|
|
|
376
507
|
## Environment variables
|
|
377
508
|
|
|
378
|
-
| Variable
|
|
379
|
-
|
|
|
380
|
-
| `NETRISKSCAN_API_KEY`
|
|
381
|
-
| `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 |
|
|
382
513
|
|
|
383
514
|
## Exit codes
|
|
384
515
|
|
|
385
|
-
| Code | Meaning
|
|
386
|
-
|
|
|
387
|
-
| `0`
|
|
388
|
-
| `1`
|
|
389
|
-
| `2`
|
|
390
|
-
| `3`
|
|
391
|
-
| `4`
|
|
392
|
-
| `5`
|
|
393
|
-
| `6`
|
|
394
|
-
| `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) |
|
|
395
526
|
|
|
396
527
|
These codes are stable and part of the CLI's public contract.
|
|
397
528
|
|
|
@@ -422,38 +553,58 @@ Request ID req_8f3ab21c9d
|
|
|
422
553
|
|
|
423
554
|
Known error codes:
|
|
424
555
|
|
|
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
|
-
|
|
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.
|
|
442
577
|
|
|
443
578
|
Pass `--debug` to any command to include a stack trace on failure. Without it, errors
|
|
444
579
|
are shown as a clean summary - never a raw stack dump.
|
|
445
580
|
|
|
446
581
|
## Rate limits & quota
|
|
447
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
|
+
|
|
448
599
|
Every successful `/v1/*` response carries live rate limit and quota headers, so you
|
|
449
600
|
don't need a separate call to `/v1/usage` to know where you stand:
|
|
450
601
|
|
|
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`
|
|
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 |
|
|
457
608
|
|
|
458
609
|
See them with:
|
|
459
610
|
|
|
@@ -473,11 +624,31 @@ The API client is a standalone module, independent of the CLI layer, so it can b
|
|
|
473
624
|
directly from Node.js/TypeScript and will move to `@netriskscan/sdk` in a future release
|
|
474
625
|
without changing its shape:
|
|
475
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
|
+
|
|
476
647
|
```ts
|
|
477
648
|
import { NetRiskScanClient, NetRiskScanApiError } from "netriskscan-cli";
|
|
478
649
|
|
|
479
650
|
const client = new NetRiskScanClient({
|
|
480
|
-
apiKey: process.env.NETRISKSCAN_API_KEY
|
|
651
|
+
apiKey: process.env.NETRISKSCAN_API_KEY,
|
|
481
652
|
timeout: 10000,
|
|
482
653
|
maxRetries: 3,
|
|
483
654
|
});
|
|
@@ -516,9 +687,9 @@ See [examples/](examples/) for runnable scripts.
|
|
|
516
687
|
|
|
517
688
|
## Developer API
|
|
518
689
|
|
|
519
|
-
|
|
|
520
|
-
|
|
|
521
|
-
| Base URL
|
|
690
|
+
| | |
|
|
691
|
+
| --------------- | ------------------------------------------- |
|
|
692
|
+
| Base URL | `https://api.netriskscan.com` |
|
|
522
693
|
| Current version | `v1` (path prefix `/v1`, **not** `/api/v1`) |
|
|
523
694
|
|
|
524
695
|
This is a completely separate system from the netriskscan.com website's internal
|
|
@@ -527,8 +698,11 @@ guarantees between the two. `netriskscan-cli` only ever calls `/v1/*`.
|
|
|
527
698
|
|
|
528
699
|
Currently available endpoints:
|
|
529
700
|
|
|
530
|
-
- `GET /v1/ip-risk/{ip}`
|
|
531
|
-
-
|
|
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`
|
|
532
706
|
|
|
533
707
|
There is currently **no** server-side batch, history, or key-management endpoint
|
|
534
708
|
(`POST /v1/ip-risk/batch`, `POST /v1/ip-risk/query`, `GET /v1/history`,
|
|
@@ -541,6 +715,15 @@ See the official [Methodology](https://www.netriskscan.com/methodology.html) pag
|
|
|
541
715
|
how the NetRiskScan Index itself is computed (this project does not - and will not -
|
|
542
716
|
reimplement that logic client-side).
|
|
543
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
|
+
|
|
544
727
|
## Contributing
|
|
545
728
|
|
|
546
729
|
See [CONTRIBUTING.md](CONTRIBUTING.md).
|