Typescript
Scrape API

Scrape API

The Scrape API extracts content from files or URLs.

Basic Usage

async function scrapeContent(file: File): Promise<void> {
  const formData = new FormData();
  formData.append("files", file);
  formData.append("text_only", "true");
 
  const response = await fetch(`${API_URL}/scrape`, {
    method: "POST",
    headers: { "Authorization": `Bearer ${API_KEY}` },
    body: formData,
  });
 
  const reader = response.body?.getReader();
  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    const chunk = new TextDecoder().decode(value);
    const lines = chunk.split("\n").filter(Boolean);
    lines.forEach(line => {
      const { result, tokens_used } = JSON.parse(line);
      console.log("Scraped content:", result);
      console.log("Tokens used:", tokens_used);
    });
  }
}

Options

  • text_only (boolean): Extract only text content
  • ai_extraction (boolean): Use AI for layout analysis
  • chunking_method (string): Content chunking method