@uncover/sdk 0.1.1 → 0.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uncover/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "JavaScript SDK for Uncover API",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -14,9 +14,16 @@
14
14
  "build": "tsc",
15
15
  "dev": "tsc --watch"
16
16
  },
17
- "keywords": ["uncover", "api", "sdk"],
18
- "author": "",
17
+ "keywords": [
18
+ "uncover",
19
+ "api",
20
+ "sdk"
21
+ ],
22
+ "author": "Alexander Wondwossen <alex@thealxlabs.ca>",
19
23
  "license": "MIT",
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
20
27
  "devDependencies": {
21
28
  "@types/node": "^20.10.6",
22
29
  "typescript": "^5.3.3"
package/src/client.ts CHANGED
@@ -4,14 +4,11 @@ export class Uncover {
4
4
  private apiKey: string;
5
5
  private baseUrl: string;
6
6
 
7
- constructor(apiKey: string, baseUrl: string = "https://api.uncover.dev") {
7
+ constructor(apiKey: string, baseUrl = "https://api.uncover.dev") {
8
8
  this.apiKey = apiKey;
9
9
  this.baseUrl = baseUrl;
10
10
  }
11
11
 
12
- /**
13
- * Search for problems mentioned on Reddit/Twitter about a topic
14
- */
15
12
  async search(request: SearchRequest): Promise<SearchResponse> {
16
13
  const response = await fetch(`${this.baseUrl}/api/search`, {
17
14
  method: "POST",
@@ -24,47 +21,37 @@ export class Uncover {
24
21
 
25
22
  if (!response.ok) {
26
23
  const error = await response.json();
27
- throw new Error(`Search failed: ${error.error || "Unknown error"}`);
24
+ throw new Error(`Search failed: ${(error as any).error || "Unknown error"}`);
28
25
  }
29
26
 
30
27
  return response.json();
31
28
  }
32
29
 
33
- /**
34
- * Get the status and results of a search request
35
- */
36
30
  async getSearchStatus(requestId: string): Promise<SearchStatusResponse> {
37
31
  const response = await fetch(`${this.baseUrl}/api/search/${requestId}`, {
38
- headers: {
39
- Authorization: `Bearer ${this.apiKey}`,
40
- },
32
+ headers: { Authorization: `Bearer ${this.apiKey}` },
41
33
  });
42
34
 
43
35
  if (!response.ok) {
44
36
  const error = await response.json();
45
- throw new Error(`Failed to get status: ${error.error || "Unknown error"}`);
37
+ throw new Error(`Failed to get status: ${(error as any).error || "Unknown error"}`);
46
38
  }
47
39
 
48
40
  return response.json();
49
41
  }
50
42
 
51
- /**
52
- * Poll for search completion with timeout
53
- */
54
43
  async waitForSearch(
55
44
  requestId: string,
56
- timeoutMs: number = 30000,
57
- pollIntervalMs: number = 1000
45
+ timeoutMs = 30000,
46
+ pollIntervalMs = 1000
58
47
  ): Promise<SearchStatusResponse> {
59
48
  const startTime = Date.now();
60
49
 
61
50
  while (Date.now() - startTime < timeoutMs) {
62
51
  const status = await this.getSearchStatus(requestId);
63
-
64
52
  if (status.status === "completed" || status.status === "failed") {
65
53
  return status;
66
54
  }
67
-
68
55
  await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
69
56
  }
70
57
 
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export type {
5
5
  SearchStatusResponse,
6
6
  Problem,
7
7
  Source,
8
+ SearchOptions,
8
9
  SignupResponse,
9
10
  SigninResponse,
10
11
  } from "./types.js";
package/src/types.ts CHANGED
@@ -1,15 +1,23 @@
1
- export type Source = "reddit" | "twitter";
1
+ export type Source = "reddit" | "twitter" | "hackernews";
2
+
3
+ export interface SearchOptions {
4
+ excludeSubreddits?: string[];
5
+ excludeKeywords?: string[];
6
+ minUpvotes?: number;
7
+ maxAgeHours?: number;
8
+ }
2
9
 
3
10
  export interface SearchRequest {
4
11
  query: string;
5
12
  sources: Source[];
6
13
  limit?: number;
14
+ options?: SearchOptions;
7
15
  }
8
16
 
9
17
  export interface Problem {
10
18
  text: string;
11
19
  frequency: number;
12
- sentiment: string;
20
+ sentiment: "frustrated" | "confused" | "disappointed" | "neutral";
13
21
  }
14
22
 
15
23
  export interface SearchResponse {
@@ -17,10 +25,14 @@ export interface SearchResponse {
17
25
  status: "pending" | "processing" | "completed" | "failed";
18
26
  query: string;
19
27
  sources: Source[];
28
+ postsAnalyzed?: number;
20
29
  problems?: Problem[];
21
30
  summary?: string;
22
31
  trends?: string[];
23
32
  cost?: number;
33
+ credits?: {
34
+ remaining: number;
35
+ };
24
36
  }
25
37
 
26
38
  export interface SearchStatusResponse {
@@ -28,9 +40,11 @@ export interface SearchStatusResponse {
28
40
  status: "pending" | "processing" | "completed" | "failed";
29
41
  query: string;
30
42
  sources: Source[];
43
+ postsAnalyzed?: number;
31
44
  problems?: Problem[];
32
45
  summary?: string;
33
46
  trends?: string[];
47
+ cost?: number;
34
48
  createdAt: string;
35
49
  }
36
50
 
@@ -57,5 +71,7 @@ export interface SigninResponse {
57
71
  id: string;
58
72
  name: string;
59
73
  createdAt: string;
74
+ lastUsed: string | null;
60
75
  }>;
76
+ message: string;
61
77
  }
package/tsconfig.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
- "extends": "../../tsconfig.json",
3
2
  "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ES2020",
5
+ "moduleResolution": "node",
4
6
  "outDir": "./dist",
5
7
  "rootDir": "./src",
8
+ "strict": true,
9
+ "skipLibCheck": true,
10
+ "esModuleInterop": true,
6
11
  "declaration": true,
7
12
  "declarationMap": true,
8
- "sourceMap": true,
9
- "moduleResolution": "node",
10
- "target": "ES2020",
11
- "module": "ES2020"
13
+ "sourceMap": true
12
14
  },
13
15
  "include": ["src"],
14
- "exclude": ["node_modules"]
16
+ "exclude": ["node_modules", "dist"]
15
17
  }
package/README.md DELETED
@@ -1,253 +0,0 @@
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