@uncover/sdk 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +253 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,253 @@
1
+ # @uncover/sdk
2
+
3
+ JavaScript/TypeScript SDK for the [Uncover API](https://uncover.dev). Surface real problems people talk about on Reddit, X, and HackerNews — analyzed by AI.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @uncover/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { Uncover } from "@uncover/sdk";
15
+
16
+ const uncover = new Uncover("sk_live_your_api_key");
17
+
18
+ const result = await uncover.search({
19
+ query: "password manager frustrations",
20
+ sources: ["reddit", "hackernews"],
21
+ limit: 20,
22
+ });
23
+
24
+ console.log(result.summary);
25
+ // "Most users struggle with pricing, mobile app crashes, and steep setup..."
26
+
27
+ console.log(result.problems);
28
+ // [
29
+ // { text: "Too expensive for personal use", frequency: 8, sentiment: "frustrated" },
30
+ // { text: "Mobile app crashes constantly", frequency: 7, sentiment: "frustrated" },
31
+ // { text: "Import from browser is broken", frequency: 5, sentiment: "disappointed" },
32
+ // ]
33
+
34
+ console.log(result.trends);
35
+ // ["pricing", "mobile", "browser extension", "support"]
36
+ ```
37
+
38
+ ## Get an API Key
39
+
40
+ ```bash
41
+ curl -X POST https://api.uncover.dev/api/auth/signup \
42
+ -H "Content-Type: application/json" \
43
+ -d '{"email":"you@example.com","password":"yourpassword"}'
44
+ ```
45
+
46
+ Returns `{ apiKey: { key: "sk_live_..." } }`. Save it — it's only shown once.
47
+
48
+ Or sign up at [uncover.dev](https://uncover.dev).
49
+
50
+ ## API Reference
51
+
52
+ ### `new Uncover(apiKey, baseUrl?)`
53
+
54
+ ```typescript
55
+ const uncover = new Uncover("sk_live_...");
56
+
57
+ // Custom base URL (e.g. self-hosted)
58
+ const uncover = new Uncover("sk_live_...", "https://your-api.com");
59
+ ```
60
+
61
+ ---
62
+
63
+ ### `uncover.search(request)`
64
+
65
+ Run a search. Deducts 1 credit.
66
+
67
+ ```typescript
68
+ const result = await uncover.search({
69
+ query: "CRM software problems", // required
70
+ sources: ["reddit", "hackernews"], // required — "reddit" | "twitter" | "hackernews"
71
+ limit: 20, // optional, 1–50, default 20
72
+ options: {
73
+ excludeSubreddits: ["memes", "AskReddit"], // filter out subreddits
74
+ excludeKeywords: ["sponsored", "ad"], // filter out posts with these words
75
+ minUpvotes: 10, // only include posts with 10+ upvotes
76
+ maxAgeHours: 720, // only posts from last 30 days
77
+ },
78
+ });
79
+ ```
80
+
81
+ **Response:**
82
+
83
+ ```typescript
84
+ {
85
+ requestId: string;
86
+ status: "completed" | "failed";
87
+ query: string;
88
+ sources: string[];
89
+ postsAnalyzed: number;
90
+ summary: string; // 2-3 sentence AI summary
91
+ problems: [
92
+ {
93
+ text: string; // description of the problem
94
+ frequency: number; // 1–10, how often it appears
95
+ sentiment: string; // "frustrated" | "confused" | "disappointed" | "neutral"
96
+ }
97
+ ];
98
+ trends: string[]; // recurring themes
99
+ cost: number; // $ cost of this search
100
+ credits: { remaining: number };
101
+ }
102
+ ```
103
+
104
+ ---
105
+
106
+ ### `uncover.getSearchStatus(requestId)`
107
+
108
+ Retrieve a previous search by ID.
109
+
110
+ ```typescript
111
+ const result = await uncover.getSearchStatus("req_abc123");
112
+ ```
113
+
114
+ ---
115
+
116
+ ### `uncover.waitForSearch(requestId, timeoutMs?, pollIntervalMs?)`
117
+
118
+ Poll until a search completes. Useful if you process searches asynchronously.
119
+
120
+ ```typescript
121
+ const result = await uncover.waitForSearch(
122
+ "req_abc123",
123
+ 30000, // timeout after 30s (default)
124
+ 1000 // poll every 1s (default)
125
+ );
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Examples
131
+
132
+ ### Find problems for product research
133
+
134
+ ```typescript
135
+ import { Uncover } from "@uncover/sdk";
136
+
137
+ const uncover = new Uncover(process.env.UNCOVER_API_KEY!);
138
+
139
+ async function researchTopic(topic: string) {
140
+ const result = await uncover.search({
141
+ query: `${topic} problems complaints`,
142
+ sources: ["reddit", "hackernews"],
143
+ limit: 30,
144
+ options: {
145
+ minUpvotes: 5,
146
+ maxAgeHours: 2160, // last 90 days
147
+ },
148
+ });
149
+
150
+ return {
151
+ summary: result.summary,
152
+ topProblems: result.problems
153
+ ?.sort((a, b) => b.frequency - a.frequency)
154
+ .slice(0, 5),
155
+ themes: result.trends,
156
+ };
157
+ }
158
+
159
+ const research = await researchTopic("project management software");
160
+ console.log(research);
161
+ ```
162
+
163
+ ### Filter noise aggressively
164
+
165
+ ```typescript
166
+ const result = await uncover.search({
167
+ query: "Notion productivity complaints",
168
+ sources: ["reddit"],
169
+ options: {
170
+ excludeSubreddits: ["memes", "funny", "AskReddit", "teenagers"],
171
+ excludeKeywords: ["sponsored", "affiliate", "promo", "discount"],
172
+ minUpvotes: 20,
173
+ maxAgeHours: 720,
174
+ },
175
+ });
176
+ ```
177
+
178
+ ### Use with multiple sources
179
+
180
+ ```typescript
181
+ const result = await uncover.search({
182
+ query: "Figma designer frustrations",
183
+ sources: ["reddit", "twitter", "hackernews"],
184
+ limit: 50,
185
+ });
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Error Handling
191
+
192
+ ```typescript
193
+ try {
194
+ const result = await uncover.search({ query: "...", sources: ["reddit"] });
195
+ } catch (err) {
196
+ if (err.message.includes("Insufficient credits")) {
197
+ // User needs to top up — redirect to billing
198
+ console.log("Buy more credits at https://uncover.dev/dashboard");
199
+ } else {
200
+ console.error("Search failed:", err.message);
201
+ }
202
+ }
203
+ ```
204
+
205
+ ---
206
+
207
+ ## CLI
208
+
209
+ Prefer the command line? Install the CLI instead:
210
+
211
+ ```bash
212
+ npm install -g @uncover/cli
213
+
214
+ uncover login
215
+ uncover scrape "password manager frustrations" --sources reddit,hackernews
216
+ uncover status
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Pricing
222
+
223
+ | Pack | Searches | Price |
224
+ |------|----------|-------|
225
+ | Starter | 50 | $5 |
226
+ | Growth | 200 | $15 |
227
+ | Pro | 500 | $29 |
228
+ | Scale | 2,000 | $79 |
229
+
230
+ Or subscribe for a monthly credit allowance (Builder $19/mo, Team $49/mo, Enterprise $149/mo).
231
+
232
+ Credits never expire. Subscribers can top up with PAYG packs.
233
+
234
+ ---
235
+
236
+ ## TypeScript
237
+
238
+ Fully typed. All request and response types are exported:
239
+
240
+ ```typescript
241
+ import type {
242
+ SearchRequest,
243
+ SearchResponse,
244
+ Problem,
245
+ Source,
246
+ } from "@uncover/sdk";
247
+ ```
248
+
249
+ ---
250
+
251
+ ## License
252
+
253
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uncover/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "JavaScript SDK for Uncover API",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",