scavio 0.1.0 → 0.2.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/README.md +43 -1
- package/dist/index.cjs +46 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -1
- package/dist/index.d.ts +59 -1
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Scavio
|
|
2
2
|
|
|
3
|
-
TypeScript SDK for the [Scavio Search API](https://scavio.dev) — real-time Google, Amazon, Walmart, YouTube, Reddit, and
|
|
3
|
+
TypeScript SDK for the [Scavio Search API](https://scavio.dev) — real-time Google, Amazon, Walmart, YouTube, Reddit, TikTok, and Instagram data.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -158,6 +158,36 @@ await client.tiktok.userFollowers({ sec_user_id: "abc123" });
|
|
|
158
158
|
await client.tiktok.userFollowings({ sec_user_id: "abc123" });
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
+
### Instagram
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
// User profile
|
|
165
|
+
await client.instagram.profile({ username: "instagram" });
|
|
166
|
+
|
|
167
|
+
// User posts / reels / tagged
|
|
168
|
+
await client.instagram.userPosts({ username: "instagram", count: 12 });
|
|
169
|
+
await client.instagram.userReels({ username: "instagram" });
|
|
170
|
+
await client.instagram.userTagged({ username: "instagram" });
|
|
171
|
+
|
|
172
|
+
// User stories
|
|
173
|
+
await client.instagram.userStories({ username: "instagram" });
|
|
174
|
+
|
|
175
|
+
// Post detail (by url, media_id, or shortcode)
|
|
176
|
+
await client.instagram.post({ shortcode: "DUajw4YkorV" });
|
|
177
|
+
|
|
178
|
+
// Post comments and replies
|
|
179
|
+
await client.instagram.postComments({ shortcode: "DUajw4YkorV", sort_order: "newest" });
|
|
180
|
+
await client.instagram.commentReplies({ media_id: "123", comment_id: "456" });
|
|
181
|
+
|
|
182
|
+
// Search
|
|
183
|
+
await client.instagram.searchUsers({ keyword: "justin" });
|
|
184
|
+
await client.instagram.searchHashtags({ keyword: "fashion" });
|
|
185
|
+
|
|
186
|
+
// Followers / followings
|
|
187
|
+
await client.instagram.userFollowers({ username: "instagram", count: 50 });
|
|
188
|
+
await client.instagram.userFollowings({ username: "instagram" });
|
|
189
|
+
```
|
|
190
|
+
|
|
161
191
|
### Usage
|
|
162
192
|
|
|
163
193
|
```typescript
|
|
@@ -202,3 +232,15 @@ Zero dependencies — uses native `fetch`.
|
|
|
202
232
|
## License
|
|
203
233
|
|
|
204
234
|
MIT
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
## About Scavio
|
|
238
|
+
|
|
239
|
+
[Scavio](https://scavio.dev) is a unified [search API](https://scavio.dev/docs/search-api) built for AI agents — one API key, structured JSON, no scraping or proxies. A real-time [Tavily alternative](https://scavio.dev) and [SerpAPI alternative](https://scavio.dev) with data from:
|
|
240
|
+
|
|
241
|
+
- [Google Search API](https://scavio.dev/docs/search-api) — SERP results, news, images, maps, and knowledge graph
|
|
242
|
+
- [Amazon Product API](https://scavio.dev/docs/amazon-api) and [Walmart API](https://scavio.dev/docs/walmart-api) — product search and details
|
|
243
|
+
- [YouTube API](https://scavio.dev/docs/youtube-api), [TikTok API](https://scavio.dev/docs/tiktok-api), and [Instagram API](https://scavio.dev/docs/instagram-api) — video and social media data
|
|
244
|
+
- [Reddit API](https://scavio.dev/docs/reddit-api) — posts and threaded comments
|
|
245
|
+
|
|
246
|
+
Get a free [API key](https://dashboard.scavio.dev) and explore the [documentation](https://scavio.dev/docs/introduction).
|
package/dist/index.cjs
CHANGED
|
@@ -256,6 +256,50 @@ var TikTokNamespace = class {
|
|
|
256
256
|
}
|
|
257
257
|
};
|
|
258
258
|
|
|
259
|
+
// src/namespaces/instagram.ts
|
|
260
|
+
var InstagramNamespace = class {
|
|
261
|
+
constructor(client) {
|
|
262
|
+
this.client = client;
|
|
263
|
+
}
|
|
264
|
+
client;
|
|
265
|
+
async profile(options) {
|
|
266
|
+
return this.client._post("/api/v1/instagram/profile", options);
|
|
267
|
+
}
|
|
268
|
+
async userPosts(options) {
|
|
269
|
+
return this.client._post("/api/v1/instagram/user/posts", options);
|
|
270
|
+
}
|
|
271
|
+
async userReels(options) {
|
|
272
|
+
return this.client._post("/api/v1/instagram/user/reels", options);
|
|
273
|
+
}
|
|
274
|
+
async userTagged(options) {
|
|
275
|
+
return this.client._post("/api/v1/instagram/user/tagged", options);
|
|
276
|
+
}
|
|
277
|
+
async userStories(options) {
|
|
278
|
+
return this.client._post("/api/v1/instagram/user/stories", options);
|
|
279
|
+
}
|
|
280
|
+
async post(options) {
|
|
281
|
+
return this.client._post("/api/v1/instagram/post", options);
|
|
282
|
+
}
|
|
283
|
+
async postComments(options) {
|
|
284
|
+
return this.client._post("/api/v1/instagram/post/comments", options);
|
|
285
|
+
}
|
|
286
|
+
async commentReplies(options) {
|
|
287
|
+
return this.client._post("/api/v1/instagram/post/comments/replies", options);
|
|
288
|
+
}
|
|
289
|
+
async searchUsers(options) {
|
|
290
|
+
return this.client._post("/api/v1/instagram/search/users", options);
|
|
291
|
+
}
|
|
292
|
+
async searchHashtags(options) {
|
|
293
|
+
return this.client._post("/api/v1/instagram/search/hashtags", options);
|
|
294
|
+
}
|
|
295
|
+
async userFollowers(options) {
|
|
296
|
+
return this.client._post("/api/v1/instagram/user/followers", options);
|
|
297
|
+
}
|
|
298
|
+
async userFollowings(options) {
|
|
299
|
+
return this.client._post("/api/v1/instagram/user/followings", options);
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
259
303
|
// src/namespaces/walmart.ts
|
|
260
304
|
var WalmartNamespace = class {
|
|
261
305
|
constructor(client) {
|
|
@@ -296,6 +340,7 @@ var Scavio = class {
|
|
|
296
340
|
youtube;
|
|
297
341
|
reddit;
|
|
298
342
|
tiktok;
|
|
343
|
+
instagram;
|
|
299
344
|
apiKey;
|
|
300
345
|
baseUrl;
|
|
301
346
|
timeout;
|
|
@@ -318,6 +363,7 @@ var Scavio = class {
|
|
|
318
363
|
this.youtube = new YouTubeNamespace(this);
|
|
319
364
|
this.reddit = new RedditNamespace(this);
|
|
320
365
|
this.tiktok = new TikTokNamespace(this);
|
|
366
|
+
this.instagram = new InstagramNamespace(this);
|
|
321
367
|
}
|
|
322
368
|
/** @internal */
|
|
323
369
|
async _post(path, body) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/http.ts","../src/rate-limiter.ts","../src/namespaces/amazon.ts","../src/namespaces/google.ts","../src/namespaces/reddit.ts","../src/namespaces/tiktok.ts","../src/namespaces/walmart.ts","../src/namespaces/youtube.ts","../src/client.ts"],"sourcesContent":["export { Scavio } from \"./client.js\";\nexport type { ScavioConfig } from \"./client.js\";\n\nexport {\n ScavioError,\n MissingAPIKeyError,\n InvalidAPIKeyError,\n InsufficientCreditsError,\n BadRequestError,\n RateLimitError,\n ScavioAPIError,\n} from \"./errors.js\";\n\nexport type { GoogleSearchOptions } from \"./namespaces/google.js\";\nexport type {\n AmazonSearchOptions,\n AmazonProductOptions,\n} from \"./namespaces/amazon.js\";\nexport type {\n WalmartSearchOptions,\n WalmartProductOptions,\n} from \"./namespaces/walmart.js\";\nexport type {\n YouTubeSearchOptions,\n YouTubeMetadataOptions,\n} from \"./namespaces/youtube.js\";\nexport type {\n RedditSearchOptions,\n RedditPostOptions,\n} from \"./namespaces/reddit.js\";\nexport type {\n TikTokProfileOptions,\n TikTokUserPostsOptions,\n TikTokVideoOptions,\n TikTokVideoCommentsOptions,\n TikTokCommentRepliesOptions,\n TikTokSearchVideosOptions,\n TikTokSearchUsersOptions,\n TikTokHashtagOptions,\n TikTokHashtagVideosOptions,\n TikTokUserFollowersOptions,\n TikTokUserFollowingsOptions,\n} from \"./namespaces/tiktok.js\";\n","export class ScavioError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ScavioError\";\n }\n}\n\nexport class MissingAPIKeyError extends ScavioError {\n constructor() {\n super(\n \"No API key provided. Pass apiKey or set the SCAVIO_API_KEY \" +\n \"environment variable. Get your free key at https://dashboard.scavio.dev\",\n );\n this.name = \"MissingAPIKeyError\";\n }\n}\n\nexport class InvalidAPIKeyError extends ScavioError {\n constructor(message = \"Invalid API key\") {\n super(message);\n this.name = \"InvalidAPIKeyError\";\n }\n}\n\nexport class InsufficientCreditsError extends ScavioError {\n constructor(message = \"Insufficient credits\") {\n super(message);\n this.name = \"InsufficientCreditsError\";\n }\n}\n\nexport class BadRequestError extends ScavioError {\n constructor(message = \"Bad request\") {\n super(message);\n this.name = \"BadRequestError\";\n }\n}\n\nexport class RateLimitError extends ScavioError {\n constructor(message = \"Rate limit exceeded\") {\n super(message);\n this.name = \"RateLimitError\";\n }\n}\n\nexport class ScavioAPIError extends ScavioError {\n public readonly statusCode: number;\n\n constructor(statusCode: number, message: string) {\n super(`API error ${statusCode}: ${message}`);\n this.name = \"ScavioAPIError\";\n this.statusCode = statusCode;\n }\n}\n","import {\n BadRequestError,\n InsufficientCreditsError,\n InvalidAPIKeyError,\n RateLimitError,\n ScavioAPIError,\n} from \"./errors.js\";\nimport type { RateLimiter } from \"./rate-limiter.js\";\n\nexport const BASE_URL = \"https://api.scavio.dev\";\nexport const DEFAULT_TIMEOUT = 30_000;\n\nfunction buildHeaders(apiKey: string): Record<string, string> {\n return {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"X-Client-Source\": \"scavio-js\",\n };\n}\n\nfunction stripUndefined(\n obj: Record<string, unknown>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value !== undefined) {\n result[key] = value;\n }\n }\n return result;\n}\n\nfunction handleError(statusCode: number, body: Record<string, unknown>): never {\n let error = body.error ?? \"Unknown error\";\n if (typeof error === \"object\" && error !== null && \"message\" in error) {\n error = (error as { message: string }).message;\n }\n const msg = String(error);\n\n if (statusCode === 400) throw new BadRequestError(msg);\n if (statusCode === 401) throw new InvalidAPIKeyError(msg);\n if (statusCode === 402) throw new InsufficientCreditsError(msg);\n if (statusCode === 429) throw new RateLimitError(msg);\n throw new ScavioAPIError(statusCode, msg);\n}\n\nexport async function request(options: {\n method: \"GET\" | \"POST\";\n path: string;\n apiKey: string;\n baseUrl: string;\n timeout: number;\n rateLimiter: RateLimiter;\n body?: Record<string, unknown>;\n}): Promise<Record<string, unknown>> {\n await options.rateLimiter.wait();\n\n const url = `${options.baseUrl}${options.path}`;\n const headers = buildHeaders(options.apiKey);\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), options.timeout);\n\n try {\n const fetchOptions: RequestInit = {\n method: options.method,\n headers,\n signal: controller.signal,\n };\n\n if (options.method === \"POST\" && options.body) {\n fetchOptions.body = JSON.stringify(stripUndefined(options.body));\n }\n\n const response = await fetch(url, fetchOptions);\n\n if (!response.ok) {\n let body: Record<string, unknown> = {};\n try {\n body = (await response.json()) as Record<string, unknown>;\n } catch {\n // ignore parse failures\n }\n handleError(response.status, body);\n }\n\n return (await response.json()) as Record<string, unknown>;\n } finally {\n clearTimeout(timeoutId);\n }\n}\n","export class RateLimiter {\n private readonly maxPerSecond: number;\n private readonly timestamps: number[] = [];\n private pending: Promise<void> = Promise.resolve();\n\n constructor(maxPerSecond: number) {\n this.maxPerSecond = maxPerSecond;\n }\n\n async wait(): Promise<void> {\n const ticket = this.pending.then(() => this.acquire());\n this.pending = ticket;\n return ticket;\n }\n\n private async acquire(): Promise<void> {\n this.cleanup();\n if (this.timestamps.length >= this.maxPerSecond) {\n const sleepMs = 1000 - (Date.now() - this.timestamps[0]!);\n if (sleepMs > 0) {\n await new Promise<void>((resolve) => setTimeout(resolve, sleepMs));\n }\n this.cleanup();\n }\n this.timestamps.push(Date.now());\n }\n\n private cleanup(): void {\n const now = Date.now();\n while (this.timestamps.length > 0 && now - this.timestamps[0]! >= 1000) {\n this.timestamps.shift();\n }\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface AmazonSearchOptions {\n query: string;\n domain?: string;\n country?: string;\n language?: string;\n currency?: string;\n device?: string;\n sort_by?: string;\n start_page?: number;\n pages?: number;\n category_id?: string;\n merchant_id?: string;\n zip_code?: string;\n autoselect_variant?: boolean;\n}\n\nexport interface AmazonProductOptions {\n asin: string;\n domain?: string;\n country?: string;\n language?: string;\n currency?: string;\n device?: string;\n zip_code?: string;\n autoselect_variant?: boolean;\n}\n\nexport class AmazonNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: AmazonSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/amazon/search\", options);\n }\n\n async product(\n options: AmazonProductOptions,\n ): Promise<Record<string, unknown>> {\n const { asin, ...rest } = options;\n return this.client._post(\"/api/v1/amazon/product\", {\n query: asin,\n ...rest,\n });\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface GoogleSearchOptions {\n query: string;\n country_code?: string;\n language?: string;\n page?: number;\n search_type?: string;\n device?: string;\n nfpr?: boolean;\n light_request?: boolean;\n}\n\nexport class GoogleNamespace {\n constructor(private client: Scavio) {}\n\n async search(options: GoogleSearchOptions): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/google\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface RedditSearchOptions {\n query: string;\n type?: string;\n sort?: string;\n cursor?: string;\n}\n\nexport interface RedditPostOptions {\n url: string;\n}\n\nexport class RedditNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: RedditSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/reddit/search\", options);\n }\n\n async post(options: RedditPostOptions): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/reddit/post\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface TikTokProfileOptions {\n username?: string;\n sec_user_id?: string;\n}\n\nexport interface TikTokUserPostsOptions {\n sec_user_id: string;\n cursor?: string;\n count?: number;\n sort_type?: string;\n}\n\nexport interface TikTokVideoOptions {\n video_id: string;\n}\n\nexport interface TikTokVideoCommentsOptions {\n video_id: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokCommentRepliesOptions {\n video_id: string;\n comment_id: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokSearchVideosOptions {\n keyword: string;\n cursor?: string;\n count?: number;\n sort_type?: string;\n publish_time?: string;\n}\n\nexport interface TikTokSearchUsersOptions {\n keyword: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokHashtagOptions {\n hashtag_name?: string;\n hashtag_id?: string;\n}\n\nexport interface TikTokHashtagVideosOptions {\n hashtag_id: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokUserFollowersOptions {\n sec_user_id: string;\n count?: number;\n page_token?: string;\n min_time?: number;\n}\n\nexport interface TikTokUserFollowingsOptions {\n sec_user_id: string;\n count?: number;\n page_token?: string;\n min_time?: number;\n}\n\nexport class TikTokNamespace {\n constructor(private client: Scavio) {}\n\n async profile(\n options: TikTokProfileOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/profile\", options);\n }\n\n async userPosts(\n options: TikTokUserPostsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/user/posts\", options);\n }\n\n async video(\n options: TikTokVideoOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/video\", options);\n }\n\n async videoComments(\n options: TikTokVideoCommentsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/video/comments\", options);\n }\n\n async commentReplies(\n options: TikTokCommentRepliesOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/video/comments/replies\", options);\n }\n\n async searchVideos(\n options: TikTokSearchVideosOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/search/videos\", options);\n }\n\n async searchUsers(\n options: TikTokSearchUsersOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/search/users\", options);\n }\n\n async hashtag(\n options: TikTokHashtagOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/hashtag\", options);\n }\n\n async hashtagVideos(\n options: TikTokHashtagVideosOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/hashtag/videos\", options);\n }\n\n async userFollowers(\n options: TikTokUserFollowersOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/user/followers\", options);\n }\n\n async userFollowings(\n options: TikTokUserFollowingsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/user/followings\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface WalmartSearchOptions {\n query: string;\n domain?: string;\n device?: string;\n sort_by?: string;\n start_page?: number;\n min_price?: number;\n max_price?: number;\n fulfillment_speed?: string;\n fulfillment_type?: string;\n delivery_zip?: string;\n store_id?: string;\n}\n\nexport interface WalmartProductOptions {\n product_id: string;\n domain?: string;\n device?: string;\n delivery_zip?: string;\n store_id?: string;\n}\n\nexport class WalmartNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: WalmartSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/walmart/search\", options);\n }\n\n async product(\n options: WalmartProductOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/walmart/product\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface YouTubeSearchOptions {\n query: string;\n upload_date?: string;\n type?: string;\n duration?: string;\n sort_by?: string;\n hd?: boolean;\n subtitles?: boolean;\n creative_commons?: boolean;\n live?: boolean;\n}\n\nexport interface YouTubeMetadataOptions {\n video_id: string;\n}\n\nexport class YouTubeNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: YouTubeSearchOptions,\n ): Promise<Record<string, unknown>> {\n const { query, ...rest } = options;\n return this.client._post(\"/api/v1/youtube/search\", {\n search: query,\n ...rest,\n });\n }\n\n async metadata(\n options: YouTubeMetadataOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/youtube/metadata\", options);\n }\n}\n","import { MissingAPIKeyError, ScavioError } from \"./errors.js\";\nimport { BASE_URL, DEFAULT_TIMEOUT, request } from \"./http.js\";\nimport { RateLimiter } from \"./rate-limiter.js\";\nimport { AmazonNamespace } from \"./namespaces/amazon.js\";\nimport type { GoogleSearchOptions } from \"./namespaces/google.js\";\nimport { GoogleNamespace } from \"./namespaces/google.js\";\nimport { RedditNamespace } from \"./namespaces/reddit.js\";\nimport { TikTokNamespace } from \"./namespaces/tiktok.js\";\nimport { WalmartNamespace } from \"./namespaces/walmart.js\";\nimport { YouTubeNamespace } from \"./namespaces/youtube.js\";\n\nexport interface ScavioConfig {\n apiKey?: string;\n baseUrl?: string;\n timeout?: number;\n maxRequestsPerSecond?: number;\n}\n\nexport class Scavio {\n readonly google: GoogleNamespace;\n readonly amazon: AmazonNamespace;\n readonly walmart: WalmartNamespace;\n readonly youtube: YouTubeNamespace;\n readonly reddit: RedditNamespace;\n readonly tiktok: TikTokNamespace;\n\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly timeout: number;\n private readonly rateLimiter: RateLimiter;\n\n constructor(config?: ScavioConfig) {\n this.apiKey = config?.apiKey ?? process.env.SCAVIO_API_KEY ?? \"\";\n if (!this.apiKey) {\n throw new MissingAPIKeyError();\n }\n\n this.baseUrl = (config?.baseUrl ?? BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = config?.timeout ?? DEFAULT_TIMEOUT;\n\n const rps = config?.maxRequestsPerSecond ?? 1;\n if (rps < 1 || rps > 10) {\n throw new ScavioError(\"maxRequestsPerSecond must be between 1 and 10\");\n }\n this.rateLimiter = new RateLimiter(rps);\n\n this.google = new GoogleNamespace(this);\n this.amazon = new AmazonNamespace(this);\n this.walmart = new WalmartNamespace(this);\n this.youtube = new YouTubeNamespace(this);\n this.reddit = new RedditNamespace(this);\n this.tiktok = new TikTokNamespace(this);\n }\n\n /** @internal */\n async _post(\n path: string,\n body: object,\n ): Promise<Record<string, unknown>> {\n return request({\n method: \"POST\",\n path,\n apiKey: this.apiKey,\n baseUrl: this.baseUrl,\n timeout: this.timeout,\n rateLimiter: this.rateLimiter,\n body: body as Record<string, unknown>,\n });\n }\n\n /** @internal */\n async _get(path: string): Promise<Record<string, unknown>> {\n return request({\n method: \"GET\",\n path,\n apiKey: this.apiKey,\n baseUrl: this.baseUrl,\n timeout: this.timeout,\n rateLimiter: this.rateLimiter,\n });\n }\n\n async search(\n options: GoogleSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.google.search(options);\n }\n\n async getUsage(): Promise<Record<string, unknown>> {\n return this._get(\"/api/v1/usage\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,qBAAN,cAAiC,YAAY;AAAA,EAClD,cAAc;AACZ;AAAA,MACE;AAAA,IAEF;AACA,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,qBAAN,cAAiC,YAAY;AAAA,EAClD,YAAY,UAAU,mBAAmB;AACvC,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,2BAAN,cAAuC,YAAY;AAAA,EACxD,YAAY,UAAU,wBAAwB;AAC5C,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC/C,YAAY,UAAU,eAAe;AACnC,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,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AgD;AACzD,WAAO,QAAQ;AAAA,MACb,QAAQ;AAAA,MACR;AAAA,MACA,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,SAAS,KAAK;AAAA,MACd,aAAa,KAAK;AAAA,IACpB,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,OACJ,SACkC;AAClC,WAAO,KAAK,OAAO,OAAO,OAAO;AAAA,EACnC;AAAA,EAEA,MAAM,WAA6C;AACjD,WAAO,KAAK,KAAK,eAAe;AAAA,EAClC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/http.ts","../src/rate-limiter.ts","../src/namespaces/amazon.ts","../src/namespaces/google.ts","../src/namespaces/reddit.ts","../src/namespaces/tiktok.ts","../src/namespaces/instagram.ts","../src/namespaces/walmart.ts","../src/namespaces/youtube.ts","../src/client.ts"],"sourcesContent":["export { Scavio } from \"./client.js\";\nexport type { ScavioConfig } from \"./client.js\";\n\nexport {\n ScavioError,\n MissingAPIKeyError,\n InvalidAPIKeyError,\n InsufficientCreditsError,\n BadRequestError,\n RateLimitError,\n ScavioAPIError,\n} from \"./errors.js\";\n\nexport type { GoogleSearchOptions } from \"./namespaces/google.js\";\nexport type {\n AmazonSearchOptions,\n AmazonProductOptions,\n} from \"./namespaces/amazon.js\";\nexport type {\n WalmartSearchOptions,\n WalmartProductOptions,\n} from \"./namespaces/walmart.js\";\nexport type {\n YouTubeSearchOptions,\n YouTubeMetadataOptions,\n} from \"./namespaces/youtube.js\";\nexport type {\n RedditSearchOptions,\n RedditPostOptions,\n} from \"./namespaces/reddit.js\";\nexport type {\n TikTokProfileOptions,\n TikTokUserPostsOptions,\n TikTokVideoOptions,\n TikTokVideoCommentsOptions,\n TikTokCommentRepliesOptions,\n TikTokSearchVideosOptions,\n TikTokSearchUsersOptions,\n TikTokHashtagOptions,\n TikTokHashtagVideosOptions,\n TikTokUserFollowersOptions,\n TikTokUserFollowingsOptions,\n} from \"./namespaces/tiktok.js\";\nexport type {\n InstagramProfileOptions,\n InstagramUserFeedOptions,\n InstagramStoriesOptions,\n InstagramPostOptions,\n InstagramPostCommentsOptions,\n InstagramCommentRepliesOptions,\n InstagramSearchOptions,\n InstagramFollowOptions,\n} from \"./namespaces/instagram.js\";\n","export class ScavioError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ScavioError\";\n }\n}\n\nexport class MissingAPIKeyError extends ScavioError {\n constructor() {\n super(\n \"No API key provided. Pass apiKey or set the SCAVIO_API_KEY \" +\n \"environment variable. Get your free key at https://dashboard.scavio.dev\",\n );\n this.name = \"MissingAPIKeyError\";\n }\n}\n\nexport class InvalidAPIKeyError extends ScavioError {\n constructor(message = \"Invalid API key\") {\n super(message);\n this.name = \"InvalidAPIKeyError\";\n }\n}\n\nexport class InsufficientCreditsError extends ScavioError {\n constructor(message = \"Insufficient credits\") {\n super(message);\n this.name = \"InsufficientCreditsError\";\n }\n}\n\nexport class BadRequestError extends ScavioError {\n constructor(message = \"Bad request\") {\n super(message);\n this.name = \"BadRequestError\";\n }\n}\n\nexport class RateLimitError extends ScavioError {\n constructor(message = \"Rate limit exceeded\") {\n super(message);\n this.name = \"RateLimitError\";\n }\n}\n\nexport class ScavioAPIError extends ScavioError {\n public readonly statusCode: number;\n\n constructor(statusCode: number, message: string) {\n super(`API error ${statusCode}: ${message}`);\n this.name = \"ScavioAPIError\";\n this.statusCode = statusCode;\n }\n}\n","import {\n BadRequestError,\n InsufficientCreditsError,\n InvalidAPIKeyError,\n RateLimitError,\n ScavioAPIError,\n} from \"./errors.js\";\nimport type { RateLimiter } from \"./rate-limiter.js\";\n\nexport const BASE_URL = \"https://api.scavio.dev\";\nexport const DEFAULT_TIMEOUT = 30_000;\n\nfunction buildHeaders(apiKey: string): Record<string, string> {\n return {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"X-Client-Source\": \"scavio-js\",\n };\n}\n\nfunction stripUndefined(\n obj: Record<string, unknown>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value !== undefined) {\n result[key] = value;\n }\n }\n return result;\n}\n\nfunction handleError(statusCode: number, body: Record<string, unknown>): never {\n let error = body.error ?? \"Unknown error\";\n if (typeof error === \"object\" && error !== null && \"message\" in error) {\n error = (error as { message: string }).message;\n }\n const msg = String(error);\n\n if (statusCode === 400) throw new BadRequestError(msg);\n if (statusCode === 401) throw new InvalidAPIKeyError(msg);\n if (statusCode === 402) throw new InsufficientCreditsError(msg);\n if (statusCode === 429) throw new RateLimitError(msg);\n throw new ScavioAPIError(statusCode, msg);\n}\n\nexport async function request(options: {\n method: \"GET\" | \"POST\";\n path: string;\n apiKey: string;\n baseUrl: string;\n timeout: number;\n rateLimiter: RateLimiter;\n body?: Record<string, unknown>;\n}): Promise<Record<string, unknown>> {\n await options.rateLimiter.wait();\n\n const url = `${options.baseUrl}${options.path}`;\n const headers = buildHeaders(options.apiKey);\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), options.timeout);\n\n try {\n const fetchOptions: RequestInit = {\n method: options.method,\n headers,\n signal: controller.signal,\n };\n\n if (options.method === \"POST\" && options.body) {\n fetchOptions.body = JSON.stringify(stripUndefined(options.body));\n }\n\n const response = await fetch(url, fetchOptions);\n\n if (!response.ok) {\n let body: Record<string, unknown> = {};\n try {\n body = (await response.json()) as Record<string, unknown>;\n } catch {\n // ignore parse failures\n }\n handleError(response.status, body);\n }\n\n return (await response.json()) as Record<string, unknown>;\n } finally {\n clearTimeout(timeoutId);\n }\n}\n","export class RateLimiter {\n private readonly maxPerSecond: number;\n private readonly timestamps: number[] = [];\n private pending: Promise<void> = Promise.resolve();\n\n constructor(maxPerSecond: number) {\n this.maxPerSecond = maxPerSecond;\n }\n\n async wait(): Promise<void> {\n const ticket = this.pending.then(() => this.acquire());\n this.pending = ticket;\n return ticket;\n }\n\n private async acquire(): Promise<void> {\n this.cleanup();\n if (this.timestamps.length >= this.maxPerSecond) {\n const sleepMs = 1000 - (Date.now() - this.timestamps[0]!);\n if (sleepMs > 0) {\n await new Promise<void>((resolve) => setTimeout(resolve, sleepMs));\n }\n this.cleanup();\n }\n this.timestamps.push(Date.now());\n }\n\n private cleanup(): void {\n const now = Date.now();\n while (this.timestamps.length > 0 && now - this.timestamps[0]! >= 1000) {\n this.timestamps.shift();\n }\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface AmazonSearchOptions {\n query: string;\n domain?: string;\n country?: string;\n language?: string;\n currency?: string;\n device?: string;\n sort_by?: string;\n start_page?: number;\n pages?: number;\n category_id?: string;\n merchant_id?: string;\n zip_code?: string;\n autoselect_variant?: boolean;\n}\n\nexport interface AmazonProductOptions {\n asin: string;\n domain?: string;\n country?: string;\n language?: string;\n currency?: string;\n device?: string;\n zip_code?: string;\n autoselect_variant?: boolean;\n}\n\nexport class AmazonNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: AmazonSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/amazon/search\", options);\n }\n\n async product(\n options: AmazonProductOptions,\n ): Promise<Record<string, unknown>> {\n const { asin, ...rest } = options;\n return this.client._post(\"/api/v1/amazon/product\", {\n query: asin,\n ...rest,\n });\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface GoogleSearchOptions {\n query: string;\n country_code?: string;\n language?: string;\n page?: number;\n search_type?: string;\n device?: string;\n nfpr?: boolean;\n light_request?: boolean;\n}\n\nexport class GoogleNamespace {\n constructor(private client: Scavio) {}\n\n async search(options: GoogleSearchOptions): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/google\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface RedditSearchOptions {\n query: string;\n type?: string;\n sort?: string;\n cursor?: string;\n}\n\nexport interface RedditPostOptions {\n url: string;\n}\n\nexport class RedditNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: RedditSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/reddit/search\", options);\n }\n\n async post(options: RedditPostOptions): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/reddit/post\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface TikTokProfileOptions {\n username?: string;\n sec_user_id?: string;\n}\n\nexport interface TikTokUserPostsOptions {\n sec_user_id: string;\n cursor?: string;\n count?: number;\n sort_type?: string;\n}\n\nexport interface TikTokVideoOptions {\n video_id: string;\n}\n\nexport interface TikTokVideoCommentsOptions {\n video_id: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokCommentRepliesOptions {\n video_id: string;\n comment_id: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokSearchVideosOptions {\n keyword: string;\n cursor?: string;\n count?: number;\n sort_type?: string;\n publish_time?: string;\n}\n\nexport interface TikTokSearchUsersOptions {\n keyword: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokHashtagOptions {\n hashtag_name?: string;\n hashtag_id?: string;\n}\n\nexport interface TikTokHashtagVideosOptions {\n hashtag_id: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokUserFollowersOptions {\n sec_user_id: string;\n count?: number;\n page_token?: string;\n min_time?: number;\n}\n\nexport interface TikTokUserFollowingsOptions {\n sec_user_id: string;\n count?: number;\n page_token?: string;\n min_time?: number;\n}\n\nexport class TikTokNamespace {\n constructor(private client: Scavio) {}\n\n async profile(\n options: TikTokProfileOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/profile\", options);\n }\n\n async userPosts(\n options: TikTokUserPostsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/user/posts\", options);\n }\n\n async video(\n options: TikTokVideoOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/video\", options);\n }\n\n async videoComments(\n options: TikTokVideoCommentsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/video/comments\", options);\n }\n\n async commentReplies(\n options: TikTokCommentRepliesOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/video/comments/replies\", options);\n }\n\n async searchVideos(\n options: TikTokSearchVideosOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/search/videos\", options);\n }\n\n async searchUsers(\n options: TikTokSearchUsersOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/search/users\", options);\n }\n\n async hashtag(\n options: TikTokHashtagOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/hashtag\", options);\n }\n\n async hashtagVideos(\n options: TikTokHashtagVideosOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/hashtag/videos\", options);\n }\n\n async userFollowers(\n options: TikTokUserFollowersOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/user/followers\", options);\n }\n\n async userFollowings(\n options: TikTokUserFollowingsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/user/followings\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface InstagramProfileOptions {\n username?: string;\n user_id?: string;\n}\n\nexport interface InstagramUserFeedOptions {\n username?: string;\n user_id?: string;\n count?: number;\n cursor?: string;\n}\n\nexport interface InstagramStoriesOptions {\n username?: string;\n user_id?: string;\n}\n\nexport interface InstagramPostOptions {\n url?: string;\n media_id?: string;\n shortcode?: string;\n}\n\nexport interface InstagramPostCommentsOptions {\n shortcode?: string;\n url?: string;\n cursor?: string;\n sort_order?: string;\n}\n\nexport interface InstagramCommentRepliesOptions {\n media_id: string;\n comment_id: string;\n cursor?: string;\n}\n\nexport interface InstagramSearchOptions {\n keyword: string;\n cursor?: string;\n}\n\nexport interface InstagramFollowOptions {\n username?: string;\n user_id?: string;\n count?: number;\n cursor?: string;\n}\n\nexport class InstagramNamespace {\n constructor(private client: Scavio) {}\n\n async profile(\n options: InstagramProfileOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/profile\", options);\n }\n\n async userPosts(\n options: InstagramUserFeedOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/user/posts\", options);\n }\n\n async userReels(\n options: InstagramUserFeedOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/user/reels\", options);\n }\n\n async userTagged(\n options: InstagramUserFeedOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/user/tagged\", options);\n }\n\n async userStories(\n options: InstagramStoriesOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/user/stories\", options);\n }\n\n async post(\n options: InstagramPostOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/post\", options);\n }\n\n async postComments(\n options: InstagramPostCommentsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/post/comments\", options);\n }\n\n async commentReplies(\n options: InstagramCommentRepliesOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/post/comments/replies\", options);\n }\n\n async searchUsers(\n options: InstagramSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/search/users\", options);\n }\n\n async searchHashtags(\n options: InstagramSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/search/hashtags\", options);\n }\n\n async userFollowers(\n options: InstagramFollowOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/user/followers\", options);\n }\n\n async userFollowings(\n options: InstagramFollowOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/user/followings\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface WalmartSearchOptions {\n query: string;\n domain?: string;\n device?: string;\n sort_by?: string;\n start_page?: number;\n min_price?: number;\n max_price?: number;\n fulfillment_speed?: string;\n fulfillment_type?: string;\n delivery_zip?: string;\n store_id?: string;\n}\n\nexport interface WalmartProductOptions {\n product_id: string;\n domain?: string;\n device?: string;\n delivery_zip?: string;\n store_id?: string;\n}\n\nexport class WalmartNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: WalmartSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/walmart/search\", options);\n }\n\n async product(\n options: WalmartProductOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/walmart/product\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface YouTubeSearchOptions {\n query: string;\n upload_date?: string;\n type?: string;\n duration?: string;\n sort_by?: string;\n hd?: boolean;\n subtitles?: boolean;\n creative_commons?: boolean;\n live?: boolean;\n}\n\nexport interface YouTubeMetadataOptions {\n video_id: string;\n}\n\nexport class YouTubeNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: YouTubeSearchOptions,\n ): Promise<Record<string, unknown>> {\n const { query, ...rest } = options;\n return this.client._post(\"/api/v1/youtube/search\", {\n search: query,\n ...rest,\n });\n }\n\n async metadata(\n options: YouTubeMetadataOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/youtube/metadata\", options);\n }\n}\n","import { MissingAPIKeyError, ScavioError } from \"./errors.js\";\nimport { BASE_URL, DEFAULT_TIMEOUT, request } from \"./http.js\";\nimport { RateLimiter } from \"./rate-limiter.js\";\nimport { AmazonNamespace } from \"./namespaces/amazon.js\";\nimport type { GoogleSearchOptions } from \"./namespaces/google.js\";\nimport { GoogleNamespace } from \"./namespaces/google.js\";\nimport { RedditNamespace } from \"./namespaces/reddit.js\";\nimport { TikTokNamespace } from \"./namespaces/tiktok.js\";\nimport { InstagramNamespace } from \"./namespaces/instagram.js\";\nimport { WalmartNamespace } from \"./namespaces/walmart.js\";\nimport { YouTubeNamespace } from \"./namespaces/youtube.js\";\n\nexport interface ScavioConfig {\n apiKey?: string;\n baseUrl?: string;\n timeout?: number;\n maxRequestsPerSecond?: number;\n}\n\nexport class Scavio {\n readonly google: GoogleNamespace;\n readonly amazon: AmazonNamespace;\n readonly walmart: WalmartNamespace;\n readonly youtube: YouTubeNamespace;\n readonly reddit: RedditNamespace;\n readonly tiktok: TikTokNamespace;\n readonly instagram: InstagramNamespace;\n\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly timeout: number;\n private readonly rateLimiter: RateLimiter;\n\n constructor(config?: ScavioConfig) {\n this.apiKey = config?.apiKey ?? process.env.SCAVIO_API_KEY ?? \"\";\n if (!this.apiKey) {\n throw new MissingAPIKeyError();\n }\n\n this.baseUrl = (config?.baseUrl ?? BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = config?.timeout ?? DEFAULT_TIMEOUT;\n\n const rps = config?.maxRequestsPerSecond ?? 1;\n if (rps < 1 || rps > 10) {\n throw new ScavioError(\"maxRequestsPerSecond must be between 1 and 10\");\n }\n this.rateLimiter = new RateLimiter(rps);\n\n this.google = new GoogleNamespace(this);\n this.amazon = new AmazonNamespace(this);\n this.walmart = new WalmartNamespace(this);\n this.youtube = new YouTubeNamespace(this);\n this.reddit = new RedditNamespace(this);\n this.tiktok = new TikTokNamespace(this);\n this.instagram = new InstagramNamespace(this);\n }\n\n /** @internal */\n async _post(\n path: string,\n body: object,\n ): Promise<Record<string, unknown>> {\n return request({\n method: \"POST\",\n path,\n apiKey: this.apiKey,\n baseUrl: this.baseUrl,\n timeout: this.timeout,\n rateLimiter: this.rateLimiter,\n body: body as Record<string, unknown>,\n });\n }\n\n /** @internal */\n async _get(path: string): Promise<Record<string, unknown>> {\n return request({\n method: \"GET\",\n path,\n apiKey: this.apiKey,\n baseUrl: this.baseUrl,\n timeout: this.timeout,\n rateLimiter: this.rateLimiter,\n });\n }\n\n async search(\n options: GoogleSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.google.search(options);\n }\n\n async getUsage(): Promise<Record<string, unknown>> {\n return this._get(\"/api/v1/usage\");\n }\n}\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,QAAI,MAAM,KAAK,MAAM,IAAI;AACvB,YAAM,IAAI,YAAY,+CAA+C;AAAA,IACvE;AACA,SAAK,cAAc,IAAI,YAAY,GAAG;AAEtC,SAAK,SAAS,IAAI,gBAAgB,IAAI;AACtC,SAAK,SAAS,IAAI,gBAAgB,IAAI;AACtC,SAAK,UAAU,IAAI,iBAAiB,IAAI;AACxC,SAAK,UAAU,IAAI,iBAAiB,IAAI;AACxC,SAAK,SAAS,IAAI,gBAAgB,IAAI;AACtC,SAAK,SAAS,IAAI,gBAAgB,IAAI;AACtC,SAAK,YAAY,IAAI,mBAAmB,IAAI;AAAA,EAC9C;AAAA;AAAA,EAGA,MAAM,MACJ,MACA,MACkC;AAClC,WAAO,QAAQ;AAAA,MACb,QAAQ;AAAA,MACR;AAAA,MACA,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,SAAS,KAAK;AAAA,MACd,aAAa,KAAK;AAAA,MAClB;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,KAAK,MAAgD;AACzD,WAAO,QAAQ;AAAA,MACb,QAAQ;AAAA,MACR;AAAA,MACA,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,SAAS,KAAK;AAAA,MACd,aAAa,KAAK;AAAA,IACpB,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,OACJ,SACkC;AAClC,WAAO,KAAK,OAAO,OAAO,OAAO;AAAA,EACnC;AAAA,EAEA,MAAM,WAA6C;AACjD,WAAO,KAAK,KAAK,eAAe;AAAA,EAClC;AACF;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -135,6 +135,63 @@ declare class TikTokNamespace {
|
|
|
135
135
|
userFollowings(options: TikTokUserFollowingsOptions): Promise<Record<string, unknown>>;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
interface InstagramProfileOptions {
|
|
139
|
+
username?: string;
|
|
140
|
+
user_id?: string;
|
|
141
|
+
}
|
|
142
|
+
interface InstagramUserFeedOptions {
|
|
143
|
+
username?: string;
|
|
144
|
+
user_id?: string;
|
|
145
|
+
count?: number;
|
|
146
|
+
cursor?: string;
|
|
147
|
+
}
|
|
148
|
+
interface InstagramStoriesOptions {
|
|
149
|
+
username?: string;
|
|
150
|
+
user_id?: string;
|
|
151
|
+
}
|
|
152
|
+
interface InstagramPostOptions {
|
|
153
|
+
url?: string;
|
|
154
|
+
media_id?: string;
|
|
155
|
+
shortcode?: string;
|
|
156
|
+
}
|
|
157
|
+
interface InstagramPostCommentsOptions {
|
|
158
|
+
shortcode?: string;
|
|
159
|
+
url?: string;
|
|
160
|
+
cursor?: string;
|
|
161
|
+
sort_order?: string;
|
|
162
|
+
}
|
|
163
|
+
interface InstagramCommentRepliesOptions {
|
|
164
|
+
media_id: string;
|
|
165
|
+
comment_id: string;
|
|
166
|
+
cursor?: string;
|
|
167
|
+
}
|
|
168
|
+
interface InstagramSearchOptions {
|
|
169
|
+
keyword: string;
|
|
170
|
+
cursor?: string;
|
|
171
|
+
}
|
|
172
|
+
interface InstagramFollowOptions {
|
|
173
|
+
username?: string;
|
|
174
|
+
user_id?: string;
|
|
175
|
+
count?: number;
|
|
176
|
+
cursor?: string;
|
|
177
|
+
}
|
|
178
|
+
declare class InstagramNamespace {
|
|
179
|
+
private client;
|
|
180
|
+
constructor(client: Scavio);
|
|
181
|
+
profile(options: InstagramProfileOptions): Promise<Record<string, unknown>>;
|
|
182
|
+
userPosts(options: InstagramUserFeedOptions): Promise<Record<string, unknown>>;
|
|
183
|
+
userReels(options: InstagramUserFeedOptions): Promise<Record<string, unknown>>;
|
|
184
|
+
userTagged(options: InstagramUserFeedOptions): Promise<Record<string, unknown>>;
|
|
185
|
+
userStories(options: InstagramStoriesOptions): Promise<Record<string, unknown>>;
|
|
186
|
+
post(options: InstagramPostOptions): Promise<Record<string, unknown>>;
|
|
187
|
+
postComments(options: InstagramPostCommentsOptions): Promise<Record<string, unknown>>;
|
|
188
|
+
commentReplies(options: InstagramCommentRepliesOptions): Promise<Record<string, unknown>>;
|
|
189
|
+
searchUsers(options: InstagramSearchOptions): Promise<Record<string, unknown>>;
|
|
190
|
+
searchHashtags(options: InstagramSearchOptions): Promise<Record<string, unknown>>;
|
|
191
|
+
userFollowers(options: InstagramFollowOptions): Promise<Record<string, unknown>>;
|
|
192
|
+
userFollowings(options: InstagramFollowOptions): Promise<Record<string, unknown>>;
|
|
193
|
+
}
|
|
194
|
+
|
|
138
195
|
interface WalmartSearchOptions {
|
|
139
196
|
query: string;
|
|
140
197
|
domain?: string;
|
|
@@ -196,6 +253,7 @@ declare class Scavio {
|
|
|
196
253
|
readonly youtube: YouTubeNamespace;
|
|
197
254
|
readonly reddit: RedditNamespace;
|
|
198
255
|
readonly tiktok: TikTokNamespace;
|
|
256
|
+
readonly instagram: InstagramNamespace;
|
|
199
257
|
private readonly apiKey;
|
|
200
258
|
private readonly baseUrl;
|
|
201
259
|
private readonly timeout;
|
|
@@ -232,4 +290,4 @@ declare class ScavioAPIError extends ScavioError {
|
|
|
232
290
|
constructor(statusCode: number, message: string);
|
|
233
291
|
}
|
|
234
292
|
|
|
235
|
-
export { type AmazonProductOptions, type AmazonSearchOptions, BadRequestError, type GoogleSearchOptions, InsufficientCreditsError, InvalidAPIKeyError, MissingAPIKeyError, RateLimitError, type RedditPostOptions, type RedditSearchOptions, Scavio, ScavioAPIError, type ScavioConfig, ScavioError, type TikTokCommentRepliesOptions, type TikTokHashtagOptions, type TikTokHashtagVideosOptions, type TikTokProfileOptions, type TikTokSearchUsersOptions, type TikTokSearchVideosOptions, type TikTokUserFollowersOptions, type TikTokUserFollowingsOptions, type TikTokUserPostsOptions, type TikTokVideoCommentsOptions, type TikTokVideoOptions, type WalmartProductOptions, type WalmartSearchOptions, type YouTubeMetadataOptions, type YouTubeSearchOptions };
|
|
293
|
+
export { type AmazonProductOptions, type AmazonSearchOptions, BadRequestError, type GoogleSearchOptions, type InstagramCommentRepliesOptions, type InstagramFollowOptions, type InstagramPostCommentsOptions, type InstagramPostOptions, type InstagramProfileOptions, type InstagramSearchOptions, type InstagramStoriesOptions, type InstagramUserFeedOptions, InsufficientCreditsError, InvalidAPIKeyError, MissingAPIKeyError, RateLimitError, type RedditPostOptions, type RedditSearchOptions, Scavio, ScavioAPIError, type ScavioConfig, ScavioError, type TikTokCommentRepliesOptions, type TikTokHashtagOptions, type TikTokHashtagVideosOptions, type TikTokProfileOptions, type TikTokSearchUsersOptions, type TikTokSearchVideosOptions, type TikTokUserFollowersOptions, type TikTokUserFollowingsOptions, type TikTokUserPostsOptions, type TikTokVideoCommentsOptions, type TikTokVideoOptions, type WalmartProductOptions, type WalmartSearchOptions, type YouTubeMetadataOptions, type YouTubeSearchOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -135,6 +135,63 @@ declare class TikTokNamespace {
|
|
|
135
135
|
userFollowings(options: TikTokUserFollowingsOptions): Promise<Record<string, unknown>>;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
interface InstagramProfileOptions {
|
|
139
|
+
username?: string;
|
|
140
|
+
user_id?: string;
|
|
141
|
+
}
|
|
142
|
+
interface InstagramUserFeedOptions {
|
|
143
|
+
username?: string;
|
|
144
|
+
user_id?: string;
|
|
145
|
+
count?: number;
|
|
146
|
+
cursor?: string;
|
|
147
|
+
}
|
|
148
|
+
interface InstagramStoriesOptions {
|
|
149
|
+
username?: string;
|
|
150
|
+
user_id?: string;
|
|
151
|
+
}
|
|
152
|
+
interface InstagramPostOptions {
|
|
153
|
+
url?: string;
|
|
154
|
+
media_id?: string;
|
|
155
|
+
shortcode?: string;
|
|
156
|
+
}
|
|
157
|
+
interface InstagramPostCommentsOptions {
|
|
158
|
+
shortcode?: string;
|
|
159
|
+
url?: string;
|
|
160
|
+
cursor?: string;
|
|
161
|
+
sort_order?: string;
|
|
162
|
+
}
|
|
163
|
+
interface InstagramCommentRepliesOptions {
|
|
164
|
+
media_id: string;
|
|
165
|
+
comment_id: string;
|
|
166
|
+
cursor?: string;
|
|
167
|
+
}
|
|
168
|
+
interface InstagramSearchOptions {
|
|
169
|
+
keyword: string;
|
|
170
|
+
cursor?: string;
|
|
171
|
+
}
|
|
172
|
+
interface InstagramFollowOptions {
|
|
173
|
+
username?: string;
|
|
174
|
+
user_id?: string;
|
|
175
|
+
count?: number;
|
|
176
|
+
cursor?: string;
|
|
177
|
+
}
|
|
178
|
+
declare class InstagramNamespace {
|
|
179
|
+
private client;
|
|
180
|
+
constructor(client: Scavio);
|
|
181
|
+
profile(options: InstagramProfileOptions): Promise<Record<string, unknown>>;
|
|
182
|
+
userPosts(options: InstagramUserFeedOptions): Promise<Record<string, unknown>>;
|
|
183
|
+
userReels(options: InstagramUserFeedOptions): Promise<Record<string, unknown>>;
|
|
184
|
+
userTagged(options: InstagramUserFeedOptions): Promise<Record<string, unknown>>;
|
|
185
|
+
userStories(options: InstagramStoriesOptions): Promise<Record<string, unknown>>;
|
|
186
|
+
post(options: InstagramPostOptions): Promise<Record<string, unknown>>;
|
|
187
|
+
postComments(options: InstagramPostCommentsOptions): Promise<Record<string, unknown>>;
|
|
188
|
+
commentReplies(options: InstagramCommentRepliesOptions): Promise<Record<string, unknown>>;
|
|
189
|
+
searchUsers(options: InstagramSearchOptions): Promise<Record<string, unknown>>;
|
|
190
|
+
searchHashtags(options: InstagramSearchOptions): Promise<Record<string, unknown>>;
|
|
191
|
+
userFollowers(options: InstagramFollowOptions): Promise<Record<string, unknown>>;
|
|
192
|
+
userFollowings(options: InstagramFollowOptions): Promise<Record<string, unknown>>;
|
|
193
|
+
}
|
|
194
|
+
|
|
138
195
|
interface WalmartSearchOptions {
|
|
139
196
|
query: string;
|
|
140
197
|
domain?: string;
|
|
@@ -196,6 +253,7 @@ declare class Scavio {
|
|
|
196
253
|
readonly youtube: YouTubeNamespace;
|
|
197
254
|
readonly reddit: RedditNamespace;
|
|
198
255
|
readonly tiktok: TikTokNamespace;
|
|
256
|
+
readonly instagram: InstagramNamespace;
|
|
199
257
|
private readonly apiKey;
|
|
200
258
|
private readonly baseUrl;
|
|
201
259
|
private readonly timeout;
|
|
@@ -232,4 +290,4 @@ declare class ScavioAPIError extends ScavioError {
|
|
|
232
290
|
constructor(statusCode: number, message: string);
|
|
233
291
|
}
|
|
234
292
|
|
|
235
|
-
export { type AmazonProductOptions, type AmazonSearchOptions, BadRequestError, type GoogleSearchOptions, InsufficientCreditsError, InvalidAPIKeyError, MissingAPIKeyError, RateLimitError, type RedditPostOptions, type RedditSearchOptions, Scavio, ScavioAPIError, type ScavioConfig, ScavioError, type TikTokCommentRepliesOptions, type TikTokHashtagOptions, type TikTokHashtagVideosOptions, type TikTokProfileOptions, type TikTokSearchUsersOptions, type TikTokSearchVideosOptions, type TikTokUserFollowersOptions, type TikTokUserFollowingsOptions, type TikTokUserPostsOptions, type TikTokVideoCommentsOptions, type TikTokVideoOptions, type WalmartProductOptions, type WalmartSearchOptions, type YouTubeMetadataOptions, type YouTubeSearchOptions };
|
|
293
|
+
export { type AmazonProductOptions, type AmazonSearchOptions, BadRequestError, type GoogleSearchOptions, type InstagramCommentRepliesOptions, type InstagramFollowOptions, type InstagramPostCommentsOptions, type InstagramPostOptions, type InstagramProfileOptions, type InstagramSearchOptions, type InstagramStoriesOptions, type InstagramUserFeedOptions, InsufficientCreditsError, InvalidAPIKeyError, MissingAPIKeyError, RateLimitError, type RedditPostOptions, type RedditSearchOptions, Scavio, ScavioAPIError, type ScavioConfig, ScavioError, type TikTokCommentRepliesOptions, type TikTokHashtagOptions, type TikTokHashtagVideosOptions, type TikTokProfileOptions, type TikTokSearchUsersOptions, type TikTokSearchVideosOptions, type TikTokUserFollowersOptions, type TikTokUserFollowingsOptions, type TikTokUserPostsOptions, type TikTokVideoCommentsOptions, type TikTokVideoOptions, type WalmartProductOptions, type WalmartSearchOptions, type YouTubeMetadataOptions, type YouTubeSearchOptions };
|
package/dist/index.js
CHANGED
|
@@ -223,6 +223,50 @@ var TikTokNamespace = class {
|
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
+
// src/namespaces/instagram.ts
|
|
227
|
+
var InstagramNamespace = class {
|
|
228
|
+
constructor(client) {
|
|
229
|
+
this.client = client;
|
|
230
|
+
}
|
|
231
|
+
client;
|
|
232
|
+
async profile(options) {
|
|
233
|
+
return this.client._post("/api/v1/instagram/profile", options);
|
|
234
|
+
}
|
|
235
|
+
async userPosts(options) {
|
|
236
|
+
return this.client._post("/api/v1/instagram/user/posts", options);
|
|
237
|
+
}
|
|
238
|
+
async userReels(options) {
|
|
239
|
+
return this.client._post("/api/v1/instagram/user/reels", options);
|
|
240
|
+
}
|
|
241
|
+
async userTagged(options) {
|
|
242
|
+
return this.client._post("/api/v1/instagram/user/tagged", options);
|
|
243
|
+
}
|
|
244
|
+
async userStories(options) {
|
|
245
|
+
return this.client._post("/api/v1/instagram/user/stories", options);
|
|
246
|
+
}
|
|
247
|
+
async post(options) {
|
|
248
|
+
return this.client._post("/api/v1/instagram/post", options);
|
|
249
|
+
}
|
|
250
|
+
async postComments(options) {
|
|
251
|
+
return this.client._post("/api/v1/instagram/post/comments", options);
|
|
252
|
+
}
|
|
253
|
+
async commentReplies(options) {
|
|
254
|
+
return this.client._post("/api/v1/instagram/post/comments/replies", options);
|
|
255
|
+
}
|
|
256
|
+
async searchUsers(options) {
|
|
257
|
+
return this.client._post("/api/v1/instagram/search/users", options);
|
|
258
|
+
}
|
|
259
|
+
async searchHashtags(options) {
|
|
260
|
+
return this.client._post("/api/v1/instagram/search/hashtags", options);
|
|
261
|
+
}
|
|
262
|
+
async userFollowers(options) {
|
|
263
|
+
return this.client._post("/api/v1/instagram/user/followers", options);
|
|
264
|
+
}
|
|
265
|
+
async userFollowings(options) {
|
|
266
|
+
return this.client._post("/api/v1/instagram/user/followings", options);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
226
270
|
// src/namespaces/walmart.ts
|
|
227
271
|
var WalmartNamespace = class {
|
|
228
272
|
constructor(client) {
|
|
@@ -263,6 +307,7 @@ var Scavio = class {
|
|
|
263
307
|
youtube;
|
|
264
308
|
reddit;
|
|
265
309
|
tiktok;
|
|
310
|
+
instagram;
|
|
266
311
|
apiKey;
|
|
267
312
|
baseUrl;
|
|
268
313
|
timeout;
|
|
@@ -285,6 +330,7 @@ var Scavio = class {
|
|
|
285
330
|
this.youtube = new YouTubeNamespace(this);
|
|
286
331
|
this.reddit = new RedditNamespace(this);
|
|
287
332
|
this.tiktok = new TikTokNamespace(this);
|
|
333
|
+
this.instagram = new InstagramNamespace(this);
|
|
288
334
|
}
|
|
289
335
|
/** @internal */
|
|
290
336
|
async _post(path, body) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/rate-limiter.ts","../src/namespaces/amazon.ts","../src/namespaces/google.ts","../src/namespaces/reddit.ts","../src/namespaces/tiktok.ts","../src/namespaces/walmart.ts","../src/namespaces/youtube.ts","../src/client.ts"],"sourcesContent":["export class ScavioError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ScavioError\";\n }\n}\n\nexport class MissingAPIKeyError extends ScavioError {\n constructor() {\n super(\n \"No API key provided. Pass apiKey or set the SCAVIO_API_KEY \" +\n \"environment variable. Get your free key at https://dashboard.scavio.dev\",\n );\n this.name = \"MissingAPIKeyError\";\n }\n}\n\nexport class InvalidAPIKeyError extends ScavioError {\n constructor(message = \"Invalid API key\") {\n super(message);\n this.name = \"InvalidAPIKeyError\";\n }\n}\n\nexport class InsufficientCreditsError extends ScavioError {\n constructor(message = \"Insufficient credits\") {\n super(message);\n this.name = \"InsufficientCreditsError\";\n }\n}\n\nexport class BadRequestError extends ScavioError {\n constructor(message = \"Bad request\") {\n super(message);\n this.name = \"BadRequestError\";\n }\n}\n\nexport class RateLimitError extends ScavioError {\n constructor(message = \"Rate limit exceeded\") {\n super(message);\n this.name = \"RateLimitError\";\n }\n}\n\nexport class ScavioAPIError extends ScavioError {\n public readonly statusCode: number;\n\n constructor(statusCode: number, message: string) {\n super(`API error ${statusCode}: ${message}`);\n this.name = \"ScavioAPIError\";\n this.statusCode = statusCode;\n }\n}\n","import {\n BadRequestError,\n InsufficientCreditsError,\n InvalidAPIKeyError,\n RateLimitError,\n ScavioAPIError,\n} from \"./errors.js\";\nimport type { RateLimiter } from \"./rate-limiter.js\";\n\nexport const BASE_URL = \"https://api.scavio.dev\";\nexport const DEFAULT_TIMEOUT = 30_000;\n\nfunction buildHeaders(apiKey: string): Record<string, string> {\n return {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"X-Client-Source\": \"scavio-js\",\n };\n}\n\nfunction stripUndefined(\n obj: Record<string, unknown>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value !== undefined) {\n result[key] = value;\n }\n }\n return result;\n}\n\nfunction handleError(statusCode: number, body: Record<string, unknown>): never {\n let error = body.error ?? \"Unknown error\";\n if (typeof error === \"object\" && error !== null && \"message\" in error) {\n error = (error as { message: string }).message;\n }\n const msg = String(error);\n\n if (statusCode === 400) throw new BadRequestError(msg);\n if (statusCode === 401) throw new InvalidAPIKeyError(msg);\n if (statusCode === 402) throw new InsufficientCreditsError(msg);\n if (statusCode === 429) throw new RateLimitError(msg);\n throw new ScavioAPIError(statusCode, msg);\n}\n\nexport async function request(options: {\n method: \"GET\" | \"POST\";\n path: string;\n apiKey: string;\n baseUrl: string;\n timeout: number;\n rateLimiter: RateLimiter;\n body?: Record<string, unknown>;\n}): Promise<Record<string, unknown>> {\n await options.rateLimiter.wait();\n\n const url = `${options.baseUrl}${options.path}`;\n const headers = buildHeaders(options.apiKey);\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), options.timeout);\n\n try {\n const fetchOptions: RequestInit = {\n method: options.method,\n headers,\n signal: controller.signal,\n };\n\n if (options.method === \"POST\" && options.body) {\n fetchOptions.body = JSON.stringify(stripUndefined(options.body));\n }\n\n const response = await fetch(url, fetchOptions);\n\n if (!response.ok) {\n let body: Record<string, unknown> = {};\n try {\n body = (await response.json()) as Record<string, unknown>;\n } catch {\n // ignore parse failures\n }\n handleError(response.status, body);\n }\n\n return (await response.json()) as Record<string, unknown>;\n } finally {\n clearTimeout(timeoutId);\n }\n}\n","export class RateLimiter {\n private readonly maxPerSecond: number;\n private readonly timestamps: number[] = [];\n private pending: Promise<void> = Promise.resolve();\n\n constructor(maxPerSecond: number) {\n this.maxPerSecond = maxPerSecond;\n }\n\n async wait(): Promise<void> {\n const ticket = this.pending.then(() => this.acquire());\n this.pending = ticket;\n return ticket;\n }\n\n private async acquire(): Promise<void> {\n this.cleanup();\n if (this.timestamps.length >= this.maxPerSecond) {\n const sleepMs = 1000 - (Date.now() - this.timestamps[0]!);\n if (sleepMs > 0) {\n await new Promise<void>((resolve) => setTimeout(resolve, sleepMs));\n }\n this.cleanup();\n }\n this.timestamps.push(Date.now());\n }\n\n private cleanup(): void {\n const now = Date.now();\n while (this.timestamps.length > 0 && now - this.timestamps[0]! >= 1000) {\n this.timestamps.shift();\n }\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface AmazonSearchOptions {\n query: string;\n domain?: string;\n country?: string;\n language?: string;\n currency?: string;\n device?: string;\n sort_by?: string;\n start_page?: number;\n pages?: number;\n category_id?: string;\n merchant_id?: string;\n zip_code?: string;\n autoselect_variant?: boolean;\n}\n\nexport interface AmazonProductOptions {\n asin: string;\n domain?: string;\n country?: string;\n language?: string;\n currency?: string;\n device?: string;\n zip_code?: string;\n autoselect_variant?: boolean;\n}\n\nexport class AmazonNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: AmazonSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/amazon/search\", options);\n }\n\n async product(\n options: AmazonProductOptions,\n ): Promise<Record<string, unknown>> {\n const { asin, ...rest } = options;\n return this.client._post(\"/api/v1/amazon/product\", {\n query: asin,\n ...rest,\n });\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface GoogleSearchOptions {\n query: string;\n country_code?: string;\n language?: string;\n page?: number;\n search_type?: string;\n device?: string;\n nfpr?: boolean;\n light_request?: boolean;\n}\n\nexport class GoogleNamespace {\n constructor(private client: Scavio) {}\n\n async search(options: GoogleSearchOptions): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/google\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface RedditSearchOptions {\n query: string;\n type?: string;\n sort?: string;\n cursor?: string;\n}\n\nexport interface RedditPostOptions {\n url: string;\n}\n\nexport class RedditNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: RedditSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/reddit/search\", options);\n }\n\n async post(options: RedditPostOptions): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/reddit/post\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface TikTokProfileOptions {\n username?: string;\n sec_user_id?: string;\n}\n\nexport interface TikTokUserPostsOptions {\n sec_user_id: string;\n cursor?: string;\n count?: number;\n sort_type?: string;\n}\n\nexport interface TikTokVideoOptions {\n video_id: string;\n}\n\nexport interface TikTokVideoCommentsOptions {\n video_id: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokCommentRepliesOptions {\n video_id: string;\n comment_id: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokSearchVideosOptions {\n keyword: string;\n cursor?: string;\n count?: number;\n sort_type?: string;\n publish_time?: string;\n}\n\nexport interface TikTokSearchUsersOptions {\n keyword: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokHashtagOptions {\n hashtag_name?: string;\n hashtag_id?: string;\n}\n\nexport interface TikTokHashtagVideosOptions {\n hashtag_id: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokUserFollowersOptions {\n sec_user_id: string;\n count?: number;\n page_token?: string;\n min_time?: number;\n}\n\nexport interface TikTokUserFollowingsOptions {\n sec_user_id: string;\n count?: number;\n page_token?: string;\n min_time?: number;\n}\n\nexport class TikTokNamespace {\n constructor(private client: Scavio) {}\n\n async profile(\n options: TikTokProfileOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/profile\", options);\n }\n\n async userPosts(\n options: TikTokUserPostsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/user/posts\", options);\n }\n\n async video(\n options: TikTokVideoOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/video\", options);\n }\n\n async videoComments(\n options: TikTokVideoCommentsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/video/comments\", options);\n }\n\n async commentReplies(\n options: TikTokCommentRepliesOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/video/comments/replies\", options);\n }\n\n async searchVideos(\n options: TikTokSearchVideosOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/search/videos\", options);\n }\n\n async searchUsers(\n options: TikTokSearchUsersOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/search/users\", options);\n }\n\n async hashtag(\n options: TikTokHashtagOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/hashtag\", options);\n }\n\n async hashtagVideos(\n options: TikTokHashtagVideosOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/hashtag/videos\", options);\n }\n\n async userFollowers(\n options: TikTokUserFollowersOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/user/followers\", options);\n }\n\n async userFollowings(\n options: TikTokUserFollowingsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/user/followings\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface WalmartSearchOptions {\n query: string;\n domain?: string;\n device?: string;\n sort_by?: string;\n start_page?: number;\n min_price?: number;\n max_price?: number;\n fulfillment_speed?: string;\n fulfillment_type?: string;\n delivery_zip?: string;\n store_id?: string;\n}\n\nexport interface WalmartProductOptions {\n product_id: string;\n domain?: string;\n device?: string;\n delivery_zip?: string;\n store_id?: string;\n}\n\nexport class WalmartNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: WalmartSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/walmart/search\", options);\n }\n\n async product(\n options: WalmartProductOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/walmart/product\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface YouTubeSearchOptions {\n query: string;\n upload_date?: string;\n type?: string;\n duration?: string;\n sort_by?: string;\n hd?: boolean;\n subtitles?: boolean;\n creative_commons?: boolean;\n live?: boolean;\n}\n\nexport interface YouTubeMetadataOptions {\n video_id: string;\n}\n\nexport class YouTubeNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: YouTubeSearchOptions,\n ): Promise<Record<string, unknown>> {\n const { query, ...rest } = options;\n return this.client._post(\"/api/v1/youtube/search\", {\n search: query,\n ...rest,\n });\n }\n\n async metadata(\n options: YouTubeMetadataOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/youtube/metadata\", options);\n }\n}\n","import { MissingAPIKeyError, ScavioError } from \"./errors.js\";\nimport { BASE_URL, DEFAULT_TIMEOUT, request } from \"./http.js\";\nimport { RateLimiter } from \"./rate-limiter.js\";\nimport { AmazonNamespace } from \"./namespaces/amazon.js\";\nimport type { GoogleSearchOptions } from \"./namespaces/google.js\";\nimport { GoogleNamespace } from \"./namespaces/google.js\";\nimport { RedditNamespace } from \"./namespaces/reddit.js\";\nimport { TikTokNamespace } from \"./namespaces/tiktok.js\";\nimport { WalmartNamespace } from \"./namespaces/walmart.js\";\nimport { YouTubeNamespace } from \"./namespaces/youtube.js\";\n\nexport interface ScavioConfig {\n apiKey?: string;\n baseUrl?: string;\n timeout?: number;\n maxRequestsPerSecond?: number;\n}\n\nexport class Scavio {\n readonly google: GoogleNamespace;\n readonly amazon: AmazonNamespace;\n readonly walmart: WalmartNamespace;\n readonly youtube: YouTubeNamespace;\n readonly reddit: RedditNamespace;\n readonly tiktok: TikTokNamespace;\n\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly timeout: number;\n private readonly rateLimiter: RateLimiter;\n\n constructor(config?: ScavioConfig) {\n this.apiKey = config?.apiKey ?? process.env.SCAVIO_API_KEY ?? \"\";\n if (!this.apiKey) {\n throw new MissingAPIKeyError();\n }\n\n this.baseUrl = (config?.baseUrl ?? BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = config?.timeout ?? DEFAULT_TIMEOUT;\n\n const rps = config?.maxRequestsPerSecond ?? 1;\n if (rps < 1 || rps > 10) {\n throw new ScavioError(\"maxRequestsPerSecond must be between 1 and 10\");\n }\n this.rateLimiter = new RateLimiter(rps);\n\n this.google = new GoogleNamespace(this);\n this.amazon = new AmazonNamespace(this);\n this.walmart = new WalmartNamespace(this);\n this.youtube = new YouTubeNamespace(this);\n this.reddit = new RedditNamespace(this);\n this.tiktok = new TikTokNamespace(this);\n }\n\n /** @internal */\n async _post(\n path: string,\n body: object,\n ): Promise<Record<string, unknown>> {\n return request({\n method: \"POST\",\n path,\n apiKey: this.apiKey,\n baseUrl: this.baseUrl,\n timeout: this.timeout,\n rateLimiter: this.rateLimiter,\n body: body as Record<string, unknown>,\n });\n }\n\n /** @internal */\n async _get(path: string): Promise<Record<string, unknown>> {\n return request({\n method: \"GET\",\n path,\n apiKey: this.apiKey,\n baseUrl: this.baseUrl,\n timeout: this.timeout,\n rateLimiter: this.rateLimiter,\n });\n }\n\n async search(\n options: GoogleSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.google.search(options);\n }\n\n async getUsage(): Promise<Record<string, unknown>> {\n return this._get(\"/api/v1/usage\");\n }\n}\n"],"mappings":";AAAO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YAAY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A,SAAK,cAAc,IAAI,YAAY,GAAG;AAEtC,SAAK,SAAS,IAAI,gBAAgB,IAAI;AACtC,SAAK,SAAS,IAAI,gBAAgB,IAAI;AACtC,SAAK,UAAU,IAAI,iBAAiB,IAAI;AACxC,SAAK,UAAU,IAAI,iBAAiB,IAAI;AACxC,SAAK,SAAS,IAAI,gBAAgB,IAAI;AACtC,SAAK,SAAS,IAAI,gBAAgB,IAAI;AAAA,EACxC;AAAA;AAAA,EAGA,MAAM,MACJ,MACA,MACkC;AAClC,WAAO,QAAQ;AAAA,MACb,QAAQ;AAAA,MACR;AAAA,MACA,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,SAAS,KAAK;AAAA,MACd,aAAa,KAAK;AAAA,MAClB;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,KAAK,MAAgD;AACzD,WAAO,QAAQ;AAAA,MACb,QAAQ;AAAA,MACR;AAAA,MACA,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,SAAS,KAAK;AAAA,MACd,aAAa,KAAK;AAAA,IACpB,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,OACJ,SACkC;AAClC,WAAO,KAAK,OAAO,OAAO,OAAO;AAAA,EACnC;AAAA,EAEA,MAAM,WAA6C;AACjD,WAAO,KAAK,KAAK,eAAe;AAAA,EAClC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/rate-limiter.ts","../src/namespaces/amazon.ts","../src/namespaces/google.ts","../src/namespaces/reddit.ts","../src/namespaces/tiktok.ts","../src/namespaces/instagram.ts","../src/namespaces/walmart.ts","../src/namespaces/youtube.ts","../src/client.ts"],"sourcesContent":["export class ScavioError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ScavioError\";\n }\n}\n\nexport class MissingAPIKeyError extends ScavioError {\n constructor() {\n super(\n \"No API key provided. Pass apiKey or set the SCAVIO_API_KEY \" +\n \"environment variable. Get your free key at https://dashboard.scavio.dev\",\n );\n this.name = \"MissingAPIKeyError\";\n }\n}\n\nexport class InvalidAPIKeyError extends ScavioError {\n constructor(message = \"Invalid API key\") {\n super(message);\n this.name = \"InvalidAPIKeyError\";\n }\n}\n\nexport class InsufficientCreditsError extends ScavioError {\n constructor(message = \"Insufficient credits\") {\n super(message);\n this.name = \"InsufficientCreditsError\";\n }\n}\n\nexport class BadRequestError extends ScavioError {\n constructor(message = \"Bad request\") {\n super(message);\n this.name = \"BadRequestError\";\n }\n}\n\nexport class RateLimitError extends ScavioError {\n constructor(message = \"Rate limit exceeded\") {\n super(message);\n this.name = \"RateLimitError\";\n }\n}\n\nexport class ScavioAPIError extends ScavioError {\n public readonly statusCode: number;\n\n constructor(statusCode: number, message: string) {\n super(`API error ${statusCode}: ${message}`);\n this.name = \"ScavioAPIError\";\n this.statusCode = statusCode;\n }\n}\n","import {\n BadRequestError,\n InsufficientCreditsError,\n InvalidAPIKeyError,\n RateLimitError,\n ScavioAPIError,\n} from \"./errors.js\";\nimport type { RateLimiter } from \"./rate-limiter.js\";\n\nexport const BASE_URL = \"https://api.scavio.dev\";\nexport const DEFAULT_TIMEOUT = 30_000;\n\nfunction buildHeaders(apiKey: string): Record<string, string> {\n return {\n Authorization: `Bearer ${apiKey}`,\n \"Content-Type\": \"application/json\",\n \"X-Client-Source\": \"scavio-js\",\n };\n}\n\nfunction stripUndefined(\n obj: Record<string, unknown>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (value !== undefined) {\n result[key] = value;\n }\n }\n return result;\n}\n\nfunction handleError(statusCode: number, body: Record<string, unknown>): never {\n let error = body.error ?? \"Unknown error\";\n if (typeof error === \"object\" && error !== null && \"message\" in error) {\n error = (error as { message: string }).message;\n }\n const msg = String(error);\n\n if (statusCode === 400) throw new BadRequestError(msg);\n if (statusCode === 401) throw new InvalidAPIKeyError(msg);\n if (statusCode === 402) throw new InsufficientCreditsError(msg);\n if (statusCode === 429) throw new RateLimitError(msg);\n throw new ScavioAPIError(statusCode, msg);\n}\n\nexport async function request(options: {\n method: \"GET\" | \"POST\";\n path: string;\n apiKey: string;\n baseUrl: string;\n timeout: number;\n rateLimiter: RateLimiter;\n body?: Record<string, unknown>;\n}): Promise<Record<string, unknown>> {\n await options.rateLimiter.wait();\n\n const url = `${options.baseUrl}${options.path}`;\n const headers = buildHeaders(options.apiKey);\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), options.timeout);\n\n try {\n const fetchOptions: RequestInit = {\n method: options.method,\n headers,\n signal: controller.signal,\n };\n\n if (options.method === \"POST\" && options.body) {\n fetchOptions.body = JSON.stringify(stripUndefined(options.body));\n }\n\n const response = await fetch(url, fetchOptions);\n\n if (!response.ok) {\n let body: Record<string, unknown> = {};\n try {\n body = (await response.json()) as Record<string, unknown>;\n } catch {\n // ignore parse failures\n }\n handleError(response.status, body);\n }\n\n return (await response.json()) as Record<string, unknown>;\n } finally {\n clearTimeout(timeoutId);\n }\n}\n","export class RateLimiter {\n private readonly maxPerSecond: number;\n private readonly timestamps: number[] = [];\n private pending: Promise<void> = Promise.resolve();\n\n constructor(maxPerSecond: number) {\n this.maxPerSecond = maxPerSecond;\n }\n\n async wait(): Promise<void> {\n const ticket = this.pending.then(() => this.acquire());\n this.pending = ticket;\n return ticket;\n }\n\n private async acquire(): Promise<void> {\n this.cleanup();\n if (this.timestamps.length >= this.maxPerSecond) {\n const sleepMs = 1000 - (Date.now() - this.timestamps[0]!);\n if (sleepMs > 0) {\n await new Promise<void>((resolve) => setTimeout(resolve, sleepMs));\n }\n this.cleanup();\n }\n this.timestamps.push(Date.now());\n }\n\n private cleanup(): void {\n const now = Date.now();\n while (this.timestamps.length > 0 && now - this.timestamps[0]! >= 1000) {\n this.timestamps.shift();\n }\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface AmazonSearchOptions {\n query: string;\n domain?: string;\n country?: string;\n language?: string;\n currency?: string;\n device?: string;\n sort_by?: string;\n start_page?: number;\n pages?: number;\n category_id?: string;\n merchant_id?: string;\n zip_code?: string;\n autoselect_variant?: boolean;\n}\n\nexport interface AmazonProductOptions {\n asin: string;\n domain?: string;\n country?: string;\n language?: string;\n currency?: string;\n device?: string;\n zip_code?: string;\n autoselect_variant?: boolean;\n}\n\nexport class AmazonNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: AmazonSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/amazon/search\", options);\n }\n\n async product(\n options: AmazonProductOptions,\n ): Promise<Record<string, unknown>> {\n const { asin, ...rest } = options;\n return this.client._post(\"/api/v1/amazon/product\", {\n query: asin,\n ...rest,\n });\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface GoogleSearchOptions {\n query: string;\n country_code?: string;\n language?: string;\n page?: number;\n search_type?: string;\n device?: string;\n nfpr?: boolean;\n light_request?: boolean;\n}\n\nexport class GoogleNamespace {\n constructor(private client: Scavio) {}\n\n async search(options: GoogleSearchOptions): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/google\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface RedditSearchOptions {\n query: string;\n type?: string;\n sort?: string;\n cursor?: string;\n}\n\nexport interface RedditPostOptions {\n url: string;\n}\n\nexport class RedditNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: RedditSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/reddit/search\", options);\n }\n\n async post(options: RedditPostOptions): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/reddit/post\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface TikTokProfileOptions {\n username?: string;\n sec_user_id?: string;\n}\n\nexport interface TikTokUserPostsOptions {\n sec_user_id: string;\n cursor?: string;\n count?: number;\n sort_type?: string;\n}\n\nexport interface TikTokVideoOptions {\n video_id: string;\n}\n\nexport interface TikTokVideoCommentsOptions {\n video_id: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokCommentRepliesOptions {\n video_id: string;\n comment_id: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokSearchVideosOptions {\n keyword: string;\n cursor?: string;\n count?: number;\n sort_type?: string;\n publish_time?: string;\n}\n\nexport interface TikTokSearchUsersOptions {\n keyword: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokHashtagOptions {\n hashtag_name?: string;\n hashtag_id?: string;\n}\n\nexport interface TikTokHashtagVideosOptions {\n hashtag_id: string;\n cursor?: string;\n count?: number;\n}\n\nexport interface TikTokUserFollowersOptions {\n sec_user_id: string;\n count?: number;\n page_token?: string;\n min_time?: number;\n}\n\nexport interface TikTokUserFollowingsOptions {\n sec_user_id: string;\n count?: number;\n page_token?: string;\n min_time?: number;\n}\n\nexport class TikTokNamespace {\n constructor(private client: Scavio) {}\n\n async profile(\n options: TikTokProfileOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/profile\", options);\n }\n\n async userPosts(\n options: TikTokUserPostsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/user/posts\", options);\n }\n\n async video(\n options: TikTokVideoOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/video\", options);\n }\n\n async videoComments(\n options: TikTokVideoCommentsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/video/comments\", options);\n }\n\n async commentReplies(\n options: TikTokCommentRepliesOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/video/comments/replies\", options);\n }\n\n async searchVideos(\n options: TikTokSearchVideosOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/search/videos\", options);\n }\n\n async searchUsers(\n options: TikTokSearchUsersOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/search/users\", options);\n }\n\n async hashtag(\n options: TikTokHashtagOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/hashtag\", options);\n }\n\n async hashtagVideos(\n options: TikTokHashtagVideosOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/hashtag/videos\", options);\n }\n\n async userFollowers(\n options: TikTokUserFollowersOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/user/followers\", options);\n }\n\n async userFollowings(\n options: TikTokUserFollowingsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/tiktok/user/followings\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface InstagramProfileOptions {\n username?: string;\n user_id?: string;\n}\n\nexport interface InstagramUserFeedOptions {\n username?: string;\n user_id?: string;\n count?: number;\n cursor?: string;\n}\n\nexport interface InstagramStoriesOptions {\n username?: string;\n user_id?: string;\n}\n\nexport interface InstagramPostOptions {\n url?: string;\n media_id?: string;\n shortcode?: string;\n}\n\nexport interface InstagramPostCommentsOptions {\n shortcode?: string;\n url?: string;\n cursor?: string;\n sort_order?: string;\n}\n\nexport interface InstagramCommentRepliesOptions {\n media_id: string;\n comment_id: string;\n cursor?: string;\n}\n\nexport interface InstagramSearchOptions {\n keyword: string;\n cursor?: string;\n}\n\nexport interface InstagramFollowOptions {\n username?: string;\n user_id?: string;\n count?: number;\n cursor?: string;\n}\n\nexport class InstagramNamespace {\n constructor(private client: Scavio) {}\n\n async profile(\n options: InstagramProfileOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/profile\", options);\n }\n\n async userPosts(\n options: InstagramUserFeedOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/user/posts\", options);\n }\n\n async userReels(\n options: InstagramUserFeedOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/user/reels\", options);\n }\n\n async userTagged(\n options: InstagramUserFeedOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/user/tagged\", options);\n }\n\n async userStories(\n options: InstagramStoriesOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/user/stories\", options);\n }\n\n async post(\n options: InstagramPostOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/post\", options);\n }\n\n async postComments(\n options: InstagramPostCommentsOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/post/comments\", options);\n }\n\n async commentReplies(\n options: InstagramCommentRepliesOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/post/comments/replies\", options);\n }\n\n async searchUsers(\n options: InstagramSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/search/users\", options);\n }\n\n async searchHashtags(\n options: InstagramSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/search/hashtags\", options);\n }\n\n async userFollowers(\n options: InstagramFollowOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/user/followers\", options);\n }\n\n async userFollowings(\n options: InstagramFollowOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/instagram/user/followings\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface WalmartSearchOptions {\n query: string;\n domain?: string;\n device?: string;\n sort_by?: string;\n start_page?: number;\n min_price?: number;\n max_price?: number;\n fulfillment_speed?: string;\n fulfillment_type?: string;\n delivery_zip?: string;\n store_id?: string;\n}\n\nexport interface WalmartProductOptions {\n product_id: string;\n domain?: string;\n device?: string;\n delivery_zip?: string;\n store_id?: string;\n}\n\nexport class WalmartNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: WalmartSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/walmart/search\", options);\n }\n\n async product(\n options: WalmartProductOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/walmart/product\", options);\n }\n}\n","import type { Scavio } from \"../client.js\";\n\nexport interface YouTubeSearchOptions {\n query: string;\n upload_date?: string;\n type?: string;\n duration?: string;\n sort_by?: string;\n hd?: boolean;\n subtitles?: boolean;\n creative_commons?: boolean;\n live?: boolean;\n}\n\nexport interface YouTubeMetadataOptions {\n video_id: string;\n}\n\nexport class YouTubeNamespace {\n constructor(private client: Scavio) {}\n\n async search(\n options: YouTubeSearchOptions,\n ): Promise<Record<string, unknown>> {\n const { query, ...rest } = options;\n return this.client._post(\"/api/v1/youtube/search\", {\n search: query,\n ...rest,\n });\n }\n\n async metadata(\n options: YouTubeMetadataOptions,\n ): Promise<Record<string, unknown>> {\n return this.client._post(\"/api/v1/youtube/metadata\", options);\n }\n}\n","import { MissingAPIKeyError, ScavioError } from \"./errors.js\";\nimport { BASE_URL, DEFAULT_TIMEOUT, request } from \"./http.js\";\nimport { RateLimiter } from \"./rate-limiter.js\";\nimport { AmazonNamespace } from \"./namespaces/amazon.js\";\nimport type { GoogleSearchOptions } from \"./namespaces/google.js\";\nimport { GoogleNamespace } from \"./namespaces/google.js\";\nimport { RedditNamespace } from \"./namespaces/reddit.js\";\nimport { TikTokNamespace } from \"./namespaces/tiktok.js\";\nimport { InstagramNamespace } from \"./namespaces/instagram.js\";\nimport { WalmartNamespace } from \"./namespaces/walmart.js\";\nimport { YouTubeNamespace } from \"./namespaces/youtube.js\";\n\nexport interface ScavioConfig {\n apiKey?: string;\n baseUrl?: string;\n timeout?: number;\n maxRequestsPerSecond?: number;\n}\n\nexport class Scavio {\n readonly google: GoogleNamespace;\n readonly amazon: AmazonNamespace;\n readonly walmart: WalmartNamespace;\n readonly youtube: YouTubeNamespace;\n readonly reddit: RedditNamespace;\n readonly tiktok: TikTokNamespace;\n readonly instagram: InstagramNamespace;\n\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly timeout: number;\n private readonly rateLimiter: RateLimiter;\n\n constructor(config?: ScavioConfig) {\n this.apiKey = config?.apiKey ?? process.env.SCAVIO_API_KEY ?? \"\";\n if (!this.apiKey) {\n throw new MissingAPIKeyError();\n }\n\n this.baseUrl = (config?.baseUrl ?? BASE_URL).replace(/\\/+$/, \"\");\n this.timeout = config?.timeout ?? DEFAULT_TIMEOUT;\n\n const rps = config?.maxRequestsPerSecond ?? 1;\n if (rps < 1 || rps > 10) {\n throw new ScavioError(\"maxRequestsPerSecond must be between 1 and 10\");\n }\n this.rateLimiter = new RateLimiter(rps);\n\n this.google = new GoogleNamespace(this);\n this.amazon = new AmazonNamespace(this);\n this.walmart = new WalmartNamespace(this);\n this.youtube = new YouTubeNamespace(this);\n this.reddit = new RedditNamespace(this);\n this.tiktok = new TikTokNamespace(this);\n this.instagram = new InstagramNamespace(this);\n }\n\n /** @internal */\n async _post(\n path: string,\n body: object,\n ): Promise<Record<string, unknown>> {\n return request({\n method: \"POST\",\n path,\n apiKey: this.apiKey,\n baseUrl: this.baseUrl,\n timeout: this.timeout,\n rateLimiter: this.rateLimiter,\n body: body as Record<string, unknown>,\n });\n }\n\n /** @internal */\n async _get(path: string): Promise<Record<string, unknown>> {\n return request({\n method: \"GET\",\n path,\n apiKey: this.apiKey,\n baseUrl: this.baseUrl,\n timeout: this.timeout,\n rateLimiter: this.rateLimiter,\n });\n }\n\n async search(\n options: GoogleSearchOptions,\n ): Promise<Record<string, unknown>> {\n return this.google.search(options);\n }\n\n async getUsage(): Promise<Record<string, unknown>> {\n return this._get(\"/api/v1/usage\");\n }\n}\n"],"mappings":";AAAO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,qBAAN,cAAiC,YAAY;AAAA,EAClD,cAAc;AACZ;AAAA,MACE;AAAA,IAEF;AACA,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,qBAAN,cAAiC,YAAY;AAAA,EAClD,YAAY,UAAU,mBAAmB;AACvC,UAAM,OAAO;AACb,SAAK,OAAO;A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MACkC;AAClC,WAAO,QAAQ;AAAA,MACb,QAAQ;AAAA,MACR;AAAA,MACA,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,SAAS,KAAK;AAAA,MACd,aAAa,KAAK;AAAA,MAClB;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,KAAK,MAAgD;AACzD,WAAO,QAAQ;AAAA,MACb,QAAQ;AAAA,MACR;AAAA,MACA,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,SAAS,KAAK;AAAA,MACd,aAAa,KAAK;AAAA,IACpB,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,OACJ,SACkC;AAClC,WAAO,KAAK,OAAO,OAAO,OAAO;AAAA,EACnC;AAAA,EAEA,MAAM,WAA6C;AACjD,WAAO,KAAK,KAAK,eAAe;AAAA,EAClC;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scavio",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "TypeScript SDK for the Scavio Search API — real-time Google, Amazon, Walmart, YouTube, Reddit, and
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "TypeScript SDK for the Scavio Search API — real-time Google, Amazon, Walmart, YouTube, Reddit, TikTok, and Instagram data",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -46,7 +46,10 @@
|
|
|
46
46
|
"reddit",
|
|
47
47
|
"tiktok",
|
|
48
48
|
"serp",
|
|
49
|
-
"scraping"
|
|
49
|
+
"scraping",
|
|
50
|
+
"instagram",
|
|
51
|
+
"tavily-alternative",
|
|
52
|
+
"serpapi-alternative"
|
|
50
53
|
],
|
|
51
54
|
"license": "MIT",
|
|
52
55
|
"author": "Scavio <support@scavio.dev>",
|