@aivisibilityskill/sdk 0.0.0-stage → 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aivisibilityskill
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,117 @@
1
- # Temporary Holding Version
1
+ # @aivisibilityskill/sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The official TypeScript client for the [aivisibilityskill](https://aivisibilityskill.com) API. Ask ChatGPT, Gemini, Google AI Overviews and AI Mode, Perplexity, Claude and Grok about any brand, in any country, and get back what they said, who they cited and what to fix.
4
+
5
+ - Fully typed from the API's OpenAPI document.
6
+ - Safe retries: every check carries an idempotency key, so a retry is never charged twice.
7
+ - Webhook signature verification included.
8
+ - No dependencies. Works in Node 20+, Deno, Bun and Cloudflare Workers (call it from your server: the API is for server-side use).
9
+
10
+ ```sh
11
+ npm install @aivisibilityskill/sdk
12
+ ```
13
+
14
+ ## Quick start
15
+
16
+ ```ts
17
+ import { Aiv } from "@aivisibilityskill/sdk";
18
+
19
+ const aiv = new Aiv({ apiKey: process.env.AIV_KEY! }); // aiv_live_… or aiv_test_… (free sample data)
20
+
21
+ const job = await aiv.checks.create({
22
+ questions: ["best invoicing app for freelancers"],
23
+ engines: ["chatgpt", "gemini", "ai_overviews", "perplexity"],
24
+ locale: "en-US",
25
+ });
26
+ const done = await aiv.jobs.wait(job.id);
27
+ for (const answer of done.answers ?? []) {
28
+ console.log(
29
+ answer.engine,
30
+ answer.brands?.map((b) => b.name),
31
+ );
32
+ }
33
+ ```
34
+
35
+ Get a key at [app.aivisibilityskill.com](https://app.aivisibilityskill.com). Test keys (`aiv_test_…`) are free and return sample answers, so you can build without spending credits.
36
+
37
+ ## Building for your own customers
38
+
39
+ Tag work with your customer's id, lock keys to one customer, and bill from the usage report:
40
+
41
+ ```ts
42
+ await aiv.checks.create({ questions, customer: "cus_8421", metadata: { workspace: "acme" } });
43
+
44
+ const key = await aiv.keys.create({
45
+ name: "acme",
46
+ customer: "cus_8421",
47
+ allowed_ips: ["203.0.113.0/24"],
48
+ });
49
+
50
+ const csv = await aiv.usage.csv({ from: "2026-11-01", to: "2026-11-30", groupBy: "customer" });
51
+
52
+ // Everything stored for a customer, deleted (runs in the background):
53
+ const deletion = await aiv.customers.deleteData("cus_8421");
54
+ await aiv.dataDeletions.wait(deletion.id);
55
+ ```
56
+
57
+ ## Thousands of answers at once
58
+
59
+ ```ts
60
+ const batch = await aiv.batches.create({
61
+ questions: myTwoThousandQuestions,
62
+ engines: ["chatgpt", "ai_overviews"],
63
+ mode: "batch", // cheapest
64
+ max_age_hours: 24, // reuse answers from the last day at half price
65
+ });
66
+ const done = await aiv.batches.wait(batch.id); // or listen for the batch.completed webhook
67
+ for (const jobId of done.checks) {
68
+ const job = await aiv.jobs.get(jobId);
69
+ }
70
+ ```
71
+
72
+ ## Webhooks
73
+
74
+ ```ts
75
+ import { verifyWebhook } from "@aivisibilityskill/sdk";
76
+
77
+ // Pass the raw body (before JSON parsing) and the request headers.
78
+ const event = await verifyWebhook(rawBody, request.headers, process.env.AIV_WEBHOOK_SECRET!);
79
+ if (event.type === "check.completed") {
80
+ const job = await aiv.jobs.get(event.data.id as string);
81
+ }
82
+ ```
83
+
84
+ During a secret rotation, pass both secrets: `verifyWebhook(body, headers, [newSecret, oldSecret])`. Deliveries older than 5 minutes are refused as replays.
85
+
86
+ ## Lists
87
+
88
+ Lists are paged. `iterate()` follows the pages for you:
89
+
90
+ ```ts
91
+ for await (const job of aiv.jobs.iterate({ customer: "cus_8421" })) { … }
92
+ for await (const event of aiv.events.iterate({ type: "check.failed" })) { … }
93
+ for await (const entry of aiv.auditLog.iterate()) { … }
94
+ ```
95
+
96
+ ## Errors
97
+
98
+ Every failure throws `AivError` with the HTTP `status`, a stable `code` (`insufficient_credits`, `budget_exceeded`, `rate_limited`, …), a readable `detail` and the `requestId` to quote to support.
99
+
100
+ ```ts
101
+ import { AivError } from "@aivisibilityskill/sdk";
102
+ try {
103
+ await aiv.checks.create({ questions });
104
+ } catch (err) {
105
+ if (err instanceof AivError && err.code === "insufficient_credits") { … }
106
+ }
107
+ ```
108
+
109
+ GET requests and checks are retried on 429, 502, 503, 504 and network errors (twice by default, honouring `Retry-After`). Set `maxRetries` and `timeoutMs` in the constructor.
110
+
111
+ ## Everything else
112
+
113
+ `aiv.projects` (tracking, schedules, visibility, competitors, sources, facts, history), `aiv.opportunities` and `aiv.fixes` (what to fix and proof it worked), `aiv.actions`, `aiv.webhooks`, `aiv.events`, `aiv.keys`, `aiv.account`, `aiv.locales`, `aiv.pricing()` and `aiv.estimate()`. For anything not wrapped yet: `aiv.request("GET", "/v1/…")`.
114
+
115
+ API reference: [api.aivisibilityskill.com/docs](https://api.aivisibilityskill.com/docs). Support: support@aivisibilityskill.com.
116
+
117
+ MIT licensed.