Getting Started with Anyparser
Welcome to Anyparser! This guide will help you quickly get started with integrating Anyparser into your application. Whether you’re processing PDFs, Word documents, images, audio, or more, Anyparser provides an easy-to-use solution for transforming unstructured data into structured formats like Markdown and JSON.
Prerequisites
Before using Anyparser, ensure you have:
- An active Anyparser account. Sign up here.
- An API key. You can obtain this from the API Keys page.
- A programming environment for working with your preferred SDK (Python, Node.js, Go, C#, etc.).
Installation
Anyparser is simple to integrate into your system using the SDK of your choice. Here’s how to get started with the SDKs for popular programming languages:
Python
- Install the Python SDK:
pip install anyparser-core
- Initialize the client with your API key:
import anyparser
client = anyparser.Client(api_key="your-api-key")
- Parse a file:
output = client.parse("path/to/document.pdf")print(output.markdown) # Markdown output
Node.js
- Install the Node.js SDK:
npm install @anyparser/core
- Initialize the client:
const Anyparser = require('@anyparser/core');
const client = new Anyparser.Client({ apiKey: 'your-api-key' });
- Parse a file:
client.parse("path/to/document.pdf") .then(response => console.log(response.markdown)); // Markdown output
Go
- Install the Go SDK:
go get github.com/anyparser/core
- Initialize the client:
package main
import ( "fmt" "github.com/anyparser/core")
func main() { client := anyparser.NewClient("your-api-key") output, _ := client.Parse("path/to/document.pdf") fmt.Println(output.Markdown) // Markdown output}
C#
- Install the .NET SDK:
dotnet add package Anyparser.Core
- Initialize the client:
using Anyparser.Core;
var client = new AnyparserClient("your-api-key");var output = await client.ParseAsync("path/to/document.pdf");Console.WriteLine(output.Markdown); // Markdown output
First Example
Now that you’ve installed the SDK and set up your API key, let’s run through a simple example. Here’s how you can parse a PDF document and retrieve its contents in Markdown format.
Example Request
curl -X POST https://api.anyparser.com/v1/parse \ -H "Authorization: Bearer your-api-key" \ -F "file=@/path/to/document.pdf"
Example Response
{ "markdown": "# Sample Document\n\nThis is the content of the document..."}
Troubleshooting
If you run into issues during setup, ensure that:
- Your API key is valid.
- You’ve correctly installed the SDK for your chosen programming language.
- Your file paths are correct.