Skip to content

gsemyong/parsedog-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Parsedog SDK for TypeScript

This SDK provides a typesafe way to interact with the Parsedog API.

We use JSR, so you can checkout https://jsr.io/@parsedog/sdk for autogenerated docs. You can also download OpenAPI schema from the https://api.parsedog.io/swagger.

To get API key, please visit the https://parsedog.io.

Note: This SDK is currently in beta, so the API may change before reaching a stable version.

Installation

You can install the SDK using your favorite package manager:

# bun
bunx jsr add @parsedog/sdk@latest

# pnpm
pnpm dlx jsr add @parsedog/sdk@latest

# deno
deno add @parsedog/sdk@latest

Obtain your API key from the Parsedog dashboard and following to your .env file:

PARSEDOG_API_KEY="Your API key here"

Extract data

Extract data from document using URL

// z is a zod instance
import {z, extractData} from "@parsedog/sdk"

// Document can be url of a PDF, PNG, JPEG, GIF or WEBP
const data = await extractData({
    schema: z.object({
        products: z.array(z.object({
            name: z.string(),
            price: z.number(),
        }))
    }),
    document: "https://example.com/receipt.pdf"
})

Extract data using TypeBox

import {t, extractData} from "@parsedog/sdk"

const data = await extractData({
    schema: t.Object({
        products: t.Array(t.Object({
            name: t.String(),
            price: t.Number(),
        }))
    }),
    document: "https://example.com/receipt.pdf"
})

Extract data from document using Bun

import {z, extractData} from "@parsedog/sdk"

const document = Buffer.from(await Bun.file("receipt.pdf").arrayBuffer()).toString("binary")

const data = await extractData({
    schema: z.object({
        products: z.array(z.object({
            name: z.string(),
            price: z.number(),
        }))
    }),
    document
})

Answer questions

Answer questions about document's content using URL

// z is a zod instance
import {z, answerQuestions} from "@parsedog/sdk"

// Document can be url of a PDF, PNG, JPEG, GIF or WEBP
const data = await answerQuestions({
    questions: ["What is the total amount?", "What is the total tax?"],
    document: "https://example.com/receipt.pdf"
})

Answer questions about document content using Bun

import {z, answerQuestions} from "@parsedog/sdk"

const document = Buffer.from(await Bun.file("receipt.pdf").arrayBuffer()).toString("binary")

const data = await answerQuestions({
    questions: ["What is the total amount?", "What is the total tax?"],
    document
})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published