TypeScript 97.5%
SQL 1.4%
Python 0.8%
1import type { Metadata } from "next";2import { CodeBlock } from "@/components/ui/code-block";3import { DocPage } from "@/components/docs/doc-page";4import { A, Code, H2, Li, P, Ul } from "@/components/docs/prose";5import { Callout, ComingSoon } from "@/components/docs/callout";6import { Endpoint } from "@/components/docs/endpoint";7import { ResponseExample } from "@/components/docs/response-example";89export const metadata: Metadata = {10 title: "Extraction",11 description: "Structured data extraction (POST /v1/extract) is coming soon. This page describes the planned schema format and what the endpoint returns today.",12};1314export default function ExtractionPage() {15 return (16 <DocPage path="/docs/extraction" eyebrow="Core API" title="Extraction" description="Turn a page into structured JSON by describing the fields you want. Extraction will run on top of a normal fetch, so routing, geography and sessions apply unchanged." status="Coming soon">17 <ComingSoon title="Structured extraction is not yet available">18 <Code>POST /v1/extract</Code> exists as a reserved route but performs no extraction. Everything below the “Current behaviour” section is design intent, published so you can19 plan integrations; names and shapes may change before launch.20 </ComingSoon>2122 <H2>Current behaviour</H2>23 <Endpoint method="POST" path="/v1/extract" status="Coming soon" />24 <P>Any call, with any body, returns a 400 with an explanatory message. No fetch is performed and nothing is counted against your quota.</P>25 <ResponseExample26 status={400}27 statusText="Bad Request"28 body={{ error: { code: "INVALID_REQUEST", message: "Structured extraction is not yet available on this plan. Follow the changelog at https://www.fetcha.co/changelog.", request_id: "req_3c4d5e6f7g8h9i0j" } }}29 />30 <P>31 In the meantime, the pragmatic path is <Code>{`format: "text"`}</Code> for readable content, or <Code>{`format: "json"`}</Code> against the JSON endpoints most modern sites expose. See the{" "}32 <A href="/docs/examples">Examples</A>.33 </P>3435 <H2>Planned request</H2>36 <P>37 The request will accept every <Code>/v1/fetch</Code> field plus a <Code>schema</Code> describing the output. Field types are expressed as short strings; arrays and nested objects are38 supported. Optional natural-language <Code>hints</Code> help disambiguate fields.39 </P>40 <CodeBlock41 lang="json"42 title="Planned request"43 code={JSON.stringify(44 {45 url: "https://www.example.ca/products/42",46 country: "CA",47 schema: {48 title: "string",49 price: "number",50 currency: "string",51 in_stock: "boolean",52 images: ["string"],53 specs: [{ name: "string", value: "string" }],54 },55 hints: { price: "The current sale price, not the crossed-out list price." },56 },57 null,58 2,59 )}60 />61 <CodeBlock62 lang="json"63 title="Planned response"64 code={JSON.stringify(65 {66 request_id: "req_…",67 success: true,68 status: 200,69 url: "https://www.example.ca/products/42",70 final_url: "https://www.example.ca/products/42",71 data: {72 title: "Example Product 42",73 price: 129.0,74 currency: "CAD",75 in_stock: true,76 images: ["https://cdn.example.ca/p/42-1.jpg", "https://cdn.example.ca/p/42-2.jpg"],77 specs: [{ name: "Weight", value: "1.2 kg" }],78 },79 metadata: { network: "residential", country: "CA", attempts: 1, duration_ms: 2140, bytes: 61233, session: null, cached: false, extraction_ms: 880 },80 },81 null,82 2,83 )}84 />85 <Ul>86 <Li>87 <Code>data</Code> follows your schema exactly; missing values are <Code>null</Code> rather than omitted.88 </Li>89 <Li>90 The fetch part behaves like <Code>/v1/fetch</Code>: blocked targets return <Code>success: false</Code> with no <Code>data</Code>, and the usual error codes apply.91 </Li>92 <Li>Extraction will be priced per successful extraction on top of the underlying fetch. Plan availability will be announced at launch.</Li>93 </Ul>94 <Callout variant="info" title="Tell us what you need">95 If you have a concrete extraction use case, email <A href="mailto:hello@fetcha.co">hello@fetcha.co</A> with an example URL and the fields you want. Early feedback shapes the schema.96 </Callout>97 </DocPage>98 );99}100