メインコンテンツへスキップ

ドキュメントを解析する API

このエンドポイントの機能

PDF4me ドキュメントを解析する 保存した解析テンプレートを PDF 抽出されたフィールドを以下のように返します。 JSON 1回で REST 電話してください。 PDF として Base64、 テンプレートID ダッシュボードから、クライアントが生成した ParseId、テンプレートで定義した名前をキーとする構造化された応答を受け取ります。テンプレートには抽出ロジックが含まれています(正規表現 安定したパターンについては、 JavaScript 表現 (条件付きルールの場合)この同じ呼び出しで、請求書、契約書、領収書、および設定したカスタムドキュメントレイアウトが抽出されます。

関連ブログ記事
この機能に関するブログ記事はまだありません。近日公開予定です。
その間、PDF4me ブログを閲覧して、あらゆるプラットフォームのチュートリアルやワークフローをご覧ください。
ブログをご覧ください →

このエンドポイントを呼び出す前に: 解析テンプレートを作成する PDF4me ダッシュボードを参照してください。 ドキュメントの解析情報を準備する 完全なセットアップ手順については、正規表現の例 (INV-\d{6,10} 請求書番号については、 \d{2}/\d{2}/\d{4} 日付用)、および2人の労働者 JavaScript 表現分類器のサンプル。

認証 API リクエスト​

毎 PDF4me REST 電話にはあなたの API キー Authorization ヘッダー。開発者ダッシュボードからキーを作成または選択し、サーバー側に保持してください。ブラウザのコードに公開しないでください。

見逃してはならない重要な事実​

最小ペイロードは3フィールドであり、5フィールドではない。
のみ ドキュメントコンテンツ、 ドキュメント名、 そして 非同期 必須です。 テンプレートID、 テンプレート名、 そして ParseId これらはオプションであり、カスタムキャプチャフィールドでキー付けされたレスポンスが必要な場合にのみ必要です。これらがない場合、 API それでも、次のような便利なデフォルトフィールドを返します ドキュメントタイプ そして ページ数。
応答は JSONバイナリではない
ドキュメントの解析結果 アプリケーション/json テンプレート内のキャプチャキーごとに1つのフィールドとデフォルトフィールドがあります。これは、生のバイナリを返すProtect、Compress、Convertエンドポイントとは異なります。 PDFs. Parse Document は常に次の値を返します JSON なぜなら、ファイルではなく構造化データを返すからです。
本番環境では、TemplateNameではなくTemplateIdを使用してください。
TemplateId は安定しています GUID ダッシュボードで「変更を保存」時に割り当てられます。テンプレートの有効期間中は変更されません。TemplateName はルックアップの代替手段として機能しますが、テンプレートの名前を変更すると機能しなくなります。必ずテンプレート詳細パネルから TemplateId をコピーし、コードに固定してください。

REST API 終点​

方法: 役職
URL: https://api.pdf4me.com/api/v2/ParseDocument

送信 コンテンツタイプ: application/json そして 承認 ヘッダーにあなたの API キーを設定します。 非同期 に 間違い 同期応答の場合(HTTP 解析済みで200 JSON)、 または 真実 受け取る HTTP 202プラスa 位置 解析されたヘッダーが200を返すまでポーリングします JSON。

Postmanリクエストの設定​

設定価値
MethodPOST
URLhttps://api.pdf4me.com/api/v2/ParseDocument
HeadersContent-Type: application/json
AuthorizationBasic Auth with your API key, or header Authorization: Basic YOUR_API_KEY
Bodyraw JSON with docContent, docName, async (and optional TemplateId, TemplateName, ParseId)
Response (sync)When async is false: HTTP 200 with parsed JSON containing one field per template key plus default fields such as documentType and pageCount.
Response (async)When async is true: HTTP 202 with a Location header. GET that URL until you receive 200 with the parsed JSON. Useful for large PDFs or batch processing.

パラメータ​

常に必須: ドキュメントコンテンツ、 ドキュメント名、 非同期。 条件付き(テンプレートベースの抽出): テンプレートID (推奨)または テンプレート名 プラス ParseIdこれらがなければ API 依然として有用なデフォルトフィールド(documentType、pageCount)は返されますが、カスタムキーの値は返されません。

パラメータ必須その機能例
jobIdExtOptionalYour own reference for this call. It is stored with the API call log so you can correlate calls with your jobs. Type: string.
integrationsOptionalIntegration identifiers, forwarded unchanged with the job's notification settings. Type: array.
isAsyncOptionalSet to `true` to process the action asynchronously and get a job to poll at `/api/v2/GetActionStatus`. Only honoured by actions that support asynchronous processing. Type: boolean.true
docNameOptionalSource file name including its extension. Several actions dispatch on the extension, so it should always be set; when omitted a per-action default is used. Type: string.invoice.pdf
docContentRequiredThe source file. Accepts the base64-encoded file content, a `pdf4meblobid://<id>` reference to a previously uploaded blob, or an `https` URL to the source document. Required: an empty value fails with `File is empty`. Type: string.JVBERi0xLjQK...
docContentBytesOptionalAlternative raw byte payload for the source file. Type: string.
callBackUrlOptionalOptional URL notified when an asynchronous job completes. Type: string.
templateIdOptionalID (GUID) of a parse template saved in the PDF4me Dashboard (https://dev.pdf4me.com/dashboard/#/parse-document/). Overridden by `parseId` and by a matching `templateName`. The call fails with `TemplateId is empty` when no template is given. Type: string.12345678-1234-1234-1234-123456789abc
parseIdOptionalID (GUID) of a parse template saved in the PDF4me Dashboard (https://dev.pdf4me.com/dashboard/#/parse-document/). When set, it is used instead of `templateId`. Type: string.87654321-4321-4321-4321-cba987654321
templateNameOptionalName of a parse template saved in your PDF4me Dashboard account (https://dev.pdf4me.com/dashboard/#/parse-document/), matched case-insensitively. When a template with this name exists, it takes precedence over `templateId` and `parseId`. Type: string.invoice_template

リクエスト例​

例A:最小限のペイロード(テンプレートなし)​

最も小さな呼び出しは API 受け入れます。デフォルトのフィールド(documentType、pageCount)を返しますが、テンプレートが参照されていないため、カスタムキーの値は返されません。

{
"docContent": "JVBERi0xLjQK...",
"docName": "invoice.pdf",
"async": true
}

例B:テンプレートベースの抽出(プロダクションパターン)​

推奨される本番環境用ペイロード。テンプレートで定義されたキャプチャキーごとに1つのフィールドと、デフォルトフィールドを返します。

{
"docContent": "JVBERi0xLjQK...",
"docName": "invoice.pdf",
"TemplateId": "12345678-1234-1234-1234-123456789abc",
"ParseId": "87654321-4321-4321-4321-cba987654321",
"async": true
}

例C:名前によるテンプレート検索​

TemplateId が手元にない場合の代替手段としてルックアップを使用できます。ただし、テンプレートの名前を変更するとこの呼び出しが機能しなくなるため、本番環境での使用は避けてください。

{
"docContent": "JVBERi0xLjQK...",
"docName": "invoice.pdf",
"TemplateName": "invoice_template",
"ParseId": "87654321-4321-4321-4321-cba987654321",
"async": true
}

応答成功 (同期、 async: false)​

HTTP 解析された200 JSONテンプレートからの各キャプチャキーがフィールドになります。デフォルトのフィールド(documentType、 pageCount)は常に返されます。

{
"parsedData": {
"invoiceNumber": "INV-2024-001",
"invoiceDate": "15/01/2024",
"totalAmount": "$1,250.50",
"customerName": "Acme Corporation"
},
"documentType": "invoice",
"pageCount": 1
}

応答成功 (非同期、 async: true)​

HTTP 202で Location ヘッダー。それをポーリングします。 URL と GET (同じ認証ヘッダー) HTTP 解析された200 JSON。

HTTP/1.1 202 Accepted
Location: https://api.pdf4me.com/api/v2/ParseDocumentStatus/<job-id>

curlの例​

curl -X POST https://api.pdf4me.com/api/v2/ParseDocument \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"docContent": "JVBERi0xLjQK...",
"docName": "invoice.pdf",
"TemplateId": "12345678-1234-1234-1234-123456789abc",
"ParseId": "87654321-4321-4321-4321-cba987654321",
"async": true
}'

テンプレート設定​

解析テンプレートには、すべての抽出ロジックが含まれています。ダッシュボードで一度設定すれば、あとは次のように呼び出すことができます。 TemplateId どこからでも。

正規表現安定したパターン
請求書番号(INV-\d{6,10})、日付(\d{2}/\d{2}/\d{4})、量($?\d{1,3}(?:,\d{3})*(?:.\d{2})?)、納税者番号、郵便番号。生産キーの約80%で使用されます。
JavaScript式条件論理と分類器
マルチマーカー分類、フォールバックルール、文書タイプ検出。抽出されたテキストは変数として渡されます。 文章; 関数は文字列を返します。参照 ドキュメントの解析情報を準備する 2 つの動作中の分類器サンプル (functionFormatTextDate1 と functionGetInvoiceOrder) について。

コードサンプル​

事前に構築されたサンプルをロードします PDFエンコードして Base64、 POST に /api/v2/ParseDocument同期/非同期応答を処理します。

統合例​

一般的なREST統合パターンTypical ways developers call Parse Document.
請求書受信箱から会計データベースへ
  1. 監視員が新しいベンダーをピックアップする PDFs メールの受信トレイまたはクラウドフォルダから。
  2. サービスは各項目を読み取ります PDF バイトとしてエンコードし、 Base64。
  3. POST に /api/v2/ParseDocument 請求書のTemplateIdと新しいParseIdを使用します。
  4. 返されたマップ 請求書番号、 合計金額、 そして 請求書発行日 直接データベースへ INSERT。
混合文書分類器と抽出器
  1. A JavaScript テンプレート内の式キーは、文書の種類(請求書、注文書、利用規約)を返します。
  2. POST 正規表現で抽出されたフィールドとともに型を返します JSON 応答。
  3. あなたのコードは型フィールドに基づいて分岐し、構造化データを適切な下流システムにルーティングします。
大規模なバッチ非同期処理 PDFs
  1. 数MBを超えるファイルの場合、 POST と 非同期: true。
  2. 読んでください 位置 202レスポンスのヘッダー。
  3. 投票する URL と GET 10秒ごとに( Python サンプルでは最大15回の再試行を使用します。
  4. レスポンスステータスが200の場合は、 JSON 本体を操作し、下流の処理を続行する。

よくある質問​

What is the minimum payload required by the Parse Document REST API?+
Three fields: docContent (the PDF as Base64), docName (filename with .pdf), and async (boolean for sync vs polling). TemplateId, TemplateName, and ParseId are optional. Without a template the API returns default information (documentType, pageCount) but no custom-keyed values.
Should I use TemplateId or TemplateName?+
Use TemplateId in production. It is a stable GUID generated by the dashboard at Save Changes and never changes for the life of the template. TemplateName works as a lookup alternative but breaks if you rename the template. Always pin TemplateId in your code.
What is ParseId and where does it come from?+
ParseId is a client-generated GUID you create per call: uuid.uuid4 in Python, Guid.NewGuid in C#, UUID.randomUUID in Java. Pass it in the request body for logging and audit trail correlation. The API does not validate it against a registry, so any valid GUID works.
Is the response JSON or binary?+
JSON. The response body is application/json containing one field per capture key in your template plus default fields such as documentType and pageCount. This is different from Protect, Compress, and Convert endpoints which return raw binary PDFs.
How does async work for large or batch PDFs?+
Set async to true. The API responds with 202 Accepted plus a Location header containing a poll URL. GET that URL with the same Authorization header. While the document is still processing the poll URL returns 202; when finished it returns 200 with the parsed JSON. Use async true for files over a few MB or when processing in batches.
How is this different from regex parsing in Python with pdfplumber?+
Python libraries like pdfplumber, PyMuPDF, and pdfminer give you raw text extraction primitives and you write the matching logic in your application code. PDF4me Parse Document uses templates you configure once in a hosted dashboard, then calls run that template from any language or platform. The matching logic lives in the template, not your code, which keeps it consistent across systems.
Where do I learn the Regex Expression and JavaScript Expression syntax?+
See the full Prepare Parse Info for Document setup guide. It covers Regex patterns for invoice numbers, dates, and amounts, and includes two working JavaScript Expression classifier samples (functionFormatTextDate1 for Terms and Conditions vs Order classification, functionGetInvoiceOrder for invoice vs order detection).
Can I run the same template from Make, Zapier, Power Automate, or n8n?+
Yes. The TemplateId is the same across all platforms. The Make, Zapier, Power Automate, and n8n PDF4me modules call this same endpoint under the hood. Build and test the template once in the dashboard, then reference its TemplateId from any platform.

関連アクション​

他のプラットフォームでも同じタスクを実行​

ヘルプが必要な場合​