scavio 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -14
- package/dist/index.cjs +125 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +187 -23
- package/dist/index.d.ts +187 -23
- package/dist/index.js +125 -15
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -430,6 +430,114 @@ var TikTokNamespace = class {
|
|
|
430
430
|
}
|
|
431
431
|
};
|
|
432
432
|
|
|
433
|
+
// src/namespaces/tiktok-shop.ts
|
|
434
|
+
var TikTokShopNamespace = class {
|
|
435
|
+
constructor(client) {
|
|
436
|
+
this.client = client;
|
|
437
|
+
}
|
|
438
|
+
client;
|
|
439
|
+
/**
|
|
440
|
+
* Search TikTok Shop products by keyword (US catalog), up to 30 per page with
|
|
441
|
+
* exact prices, ratings, and shop details. Paginate with next_cursor and dedupe
|
|
442
|
+
* by product_id across pages.
|
|
443
|
+
*
|
|
444
|
+
* This is one of the three endpoints that return exact prices; tiktokShop.product()
|
|
445
|
+
* does not return a price. A product_id returned here is not guaranteed to resolve
|
|
446
|
+
* on tiktokShop.product() - only about 44% do.
|
|
447
|
+
*/
|
|
448
|
+
async search(options) {
|
|
449
|
+
return this.client._post("/api/v1/tiktok-shop/search", options);
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Keyword autocomplete and expansion for a partial query, across 8 marketplace
|
|
453
|
+
* regions. Suggestions are not guaranteed prefix matches: a misspelling returns
|
|
454
|
+
* typo corrections, and results can include brand and shop names.
|
|
455
|
+
*/
|
|
456
|
+
async searchSuggestions(options) {
|
|
457
|
+
return this.client._post("/api/v1/tiktok-shop/search/suggestions", options);
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Full product detail: description, images, variants with stock, shipping, shop
|
|
461
|
+
* profile, category path, and top reviews.
|
|
462
|
+
*
|
|
463
|
+
* Two limits worth knowing before you build on this:
|
|
464
|
+
*
|
|
465
|
+
* 1. It resolves only about 44% of the product ids returned by tiktokShop.search().
|
|
466
|
+
* Upstream has no detail data for the rest, so an HTTP 404 is a normal outcome,
|
|
467
|
+
* not an error. Skip the item rather than retrying - retries do not help and no
|
|
468
|
+
* other region carries it. Search to product is not a reliable pipeline.
|
|
469
|
+
*
|
|
470
|
+
* This method throws `NotFoundError` on that 404 (there is no `data` field in
|
|
471
|
+
* the response body to test), so a loop over search ids must catch it or it
|
|
472
|
+
* dies on the first miss:
|
|
473
|
+
*
|
|
474
|
+
* ```ts
|
|
475
|
+
* import { NotFoundError } from "scavio";
|
|
476
|
+
*
|
|
477
|
+
* for (const productId of productIds) {
|
|
478
|
+
* try {
|
|
479
|
+
* const detail = await client.tiktokShop.product({ product_id: productId });
|
|
480
|
+
* } catch (e) {
|
|
481
|
+
* if (e instanceof NotFoundError) continue; // no detail upstream; skip
|
|
482
|
+
* throw e;
|
|
483
|
+
* }
|
|
484
|
+
* }
|
|
485
|
+
* ```
|
|
486
|
+
*
|
|
487
|
+
* tiktokShop.productReviews() often works for ids product() cannot resolve: of
|
|
488
|
+
* 8 such ids tested, 8 returned HTTP 200 and 7 carried at least one review, so
|
|
489
|
+
* it is a useful fallback source of product detail.
|
|
490
|
+
* 2. It does NOT return a price. Upstream masks the price on the product page.
|
|
491
|
+
* Exact prices come from tiktokShop.search(), tiktokShop.shopProducts(), and
|
|
492
|
+
* tiktokShop.categoryProducts().
|
|
493
|
+
*/
|
|
494
|
+
async product(options) {
|
|
495
|
+
return this.client._post("/api/v1/tiktok-shop/product", options);
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Paginated product reviews with text, images, star histogram, and
|
|
499
|
+
* verified-purchase flags, up to 200 per call. total_reviews drifts between calls
|
|
500
|
+
* and must not be used to compute a page count; page with has_more instead.
|
|
501
|
+
*/
|
|
502
|
+
async productReviews(options) {
|
|
503
|
+
return this.client._post("/api/v1/tiktok-shop/product/reviews", options);
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* The global TikTok Shop category tree: 28 top-level categories, 240 nodes, two
|
|
507
|
+
* levels deep. Category ids are identical in every region and names are always
|
|
508
|
+
* English.
|
|
509
|
+
*/
|
|
510
|
+
async categories() {
|
|
511
|
+
return this.client._post("/api/v1/tiktok-shop/categories", {});
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Products listed under a category id from tiktokShop.categories(), with exact
|
|
515
|
+
* prices. Page size is inconsistent upstream (15 to 20 per page), so always
|
|
516
|
+
* paginate with next_cursor rather than assuming a fixed page size. Category
|
|
517
|
+
* listings are shallow: after a few pages the source stops returning new products
|
|
518
|
+
* and has_more turns false, which is the end of the listing rather than an error.
|
|
519
|
+
*/
|
|
520
|
+
async categoryProducts(options) {
|
|
521
|
+
return this.client._post("/api/v1/tiktok-shop/category/products", options);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* A shop's product catalog, 30 per page, with exact prices. Shop follower count,
|
|
525
|
+
* location, and shop-level rating are not available here; call
|
|
526
|
+
* tiktokShop.product() for the full shop profile.
|
|
527
|
+
*/
|
|
528
|
+
async shopProducts(options) {
|
|
529
|
+
return this.client._post("/api/v1/tiktok-shop/shop/products", options);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Resolve any TikTok Shop URL or share link to a product_id or shop_id, ready to
|
|
533
|
+
* pass to the other methods. Accepts canonical product and store pages,
|
|
534
|
+
* tiktok.com/view links, affiliate share links, and vt.tiktok.com short links.
|
|
535
|
+
*/
|
|
536
|
+
async resolve(options) {
|
|
537
|
+
return this.client._post("/api/v1/tiktok-shop/resolve", options);
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
|
|
433
541
|
// src/namespaces/instagram.ts
|
|
434
542
|
var InstagramNamespace = class {
|
|
435
543
|
constructor(client) {
|
|
@@ -565,44 +673,44 @@ var YouTubeNamespace = class {
|
|
|
565
673
|
}
|
|
566
674
|
};
|
|
567
675
|
|
|
568
|
-
// src/namespaces/
|
|
569
|
-
var
|
|
676
|
+
// src/namespaces/x.ts
|
|
677
|
+
var XNamespace = class {
|
|
570
678
|
constructor(client) {
|
|
571
679
|
this.client = client;
|
|
572
680
|
}
|
|
573
681
|
client;
|
|
574
682
|
async search(options) {
|
|
575
|
-
return this.client._post("/api/v1/
|
|
683
|
+
return this.client._post("/api/v1/x/search", options);
|
|
576
684
|
}
|
|
577
685
|
async tweet(options) {
|
|
578
|
-
return this.client._post("/api/v1/
|
|
686
|
+
return this.client._post("/api/v1/x/tweet", options);
|
|
579
687
|
}
|
|
580
688
|
async tweetComments(options) {
|
|
581
|
-
return this.client._post("/api/v1/
|
|
689
|
+
return this.client._post("/api/v1/x/tweet/comments", options);
|
|
582
690
|
}
|
|
583
691
|
async tweetRetweeters(options) {
|
|
584
|
-
return this.client._post("/api/v1/
|
|
692
|
+
return this.client._post("/api/v1/x/tweet/retweeters", options);
|
|
585
693
|
}
|
|
586
694
|
async user(options) {
|
|
587
|
-
return this.client._post("/api/v1/
|
|
695
|
+
return this.client._post("/api/v1/x/user", options);
|
|
588
696
|
}
|
|
589
697
|
async userTweets(options) {
|
|
590
|
-
return this.client._post("/api/v1/
|
|
698
|
+
return this.client._post("/api/v1/x/user/tweets", options);
|
|
591
699
|
}
|
|
592
700
|
async userReplies(options) {
|
|
593
|
-
return this.client._post("/api/v1/
|
|
701
|
+
return this.client._post("/api/v1/x/user/replies", options);
|
|
594
702
|
}
|
|
595
703
|
async userMedia(options) {
|
|
596
|
-
return this.client._post("/api/v1/
|
|
704
|
+
return this.client._post("/api/v1/x/user/media", options);
|
|
597
705
|
}
|
|
598
706
|
async userFollowers(options) {
|
|
599
|
-
return this.client._post("/api/v1/
|
|
707
|
+
return this.client._post("/api/v1/x/user/followers", options);
|
|
600
708
|
}
|
|
601
709
|
async userFollowings(options) {
|
|
602
|
-
return this.client._post("/api/v1/
|
|
710
|
+
return this.client._post("/api/v1/x/user/followings", options);
|
|
603
711
|
}
|
|
604
712
|
async trending(options = {}) {
|
|
605
|
-
return this.client._post("/api/v1/
|
|
713
|
+
return this.client._post("/api/v1/x/trending", options);
|
|
606
714
|
}
|
|
607
715
|
};
|
|
608
716
|
|
|
@@ -664,8 +772,9 @@ var Scavio = class {
|
|
|
664
772
|
youtube;
|
|
665
773
|
reddit;
|
|
666
774
|
tiktok;
|
|
775
|
+
tiktokShop;
|
|
667
776
|
instagram;
|
|
668
|
-
|
|
777
|
+
x;
|
|
669
778
|
linkedin;
|
|
670
779
|
apiKey;
|
|
671
780
|
baseUrl;
|
|
@@ -691,8 +800,9 @@ var Scavio = class {
|
|
|
691
800
|
this.youtube = new YouTubeNamespace(this);
|
|
692
801
|
this.reddit = new RedditNamespace(this);
|
|
693
802
|
this.tiktok = new TikTokNamespace(this);
|
|
803
|
+
this.tiktokShop = new TikTokShopNamespace(this);
|
|
694
804
|
this.instagram = new InstagramNamespace(this);
|
|
695
|
-
this.
|
|
805
|
+
this.x = new XNamespace(this);
|
|
696
806
|
this.linkedin = new LinkedInNamespace(this);
|
|
697
807
|
}
|
|
698
808
|
/** @internal */
|