Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(api): update X/Twitter scrape billing

mogeryadaecf1c6ea1
diff --git a/apps/api/src/lib/scrape-billing.test.ts b/apps/api/src/lib/scrape-billing.test.ts
new file mode 100644
index 000000000..9f4c72cb2
--- /dev/null
+++ b/apps/api/src/lib/scrape-billing.test.ts
@@ -0,0 +1,27 @@
+import { calculateCreditsToBeBilled } from "./scrape-billing";
+
+describe("calculateCreditsToBeBilled", () => {
+ it("bills X/Twitter scrapes at 30 credits", async () => {
+ const credits = await calculateCreditsToBeBilled(
+ {
+ formats: [{ type: "markdown" }],
+ } as any,
+ {
+ teamId: "team-id",
+ },
+ {
+ metadata: {
+ statusCode: 200,
+ proxyUsed: "basic",
+ postprocessorsUsed: ["x-twitter"],
+ },
+ } as any,
+ {
+ totalCost: 0,
+ } as any,
+ {} as any,
+ );
+
+ expect(credits).toBe(30);
+ });
+});
diff --git a/apps/api/src/lib/scrape-billing.ts b/apps/api/src/lib/scrape-billing.ts
index dd5bee7d3..7b5f0dcd3 100644
--- a/apps/api/src/lib/scrape-billing.ts
+++ b/apps/api/src/lib/scrape-billing.ts
@@ -14,7 +14,7 @@ import { isUrlBlocked } from "../scraper/WebScraper/utils/blocklist";
const creditsPerPDFPage = 1;
const stealthProxyCostBonus = 4;
const unblockedDomainCostBonus = 4;
-const xTwitterCostBonus = 9;
+const xTwitterCostBonus = 29;
export async function calculateCreditsToBeBilled(
options: ScrapeOptions,