Lewati ke konten utama

Uraikan Dokumen API

Fungsi dari endpoint ini

PDF4me Uraikan Dokumen menjalankan templat parse yang Anda simpan terhadap PDF dan mengembalikan bidang yang diekstrak sebagai JSON dalam satu REST Telepon. Kirim PDF sebagai Base64, itu ID Templat dari dasbor, dan yang dihasilkan oleh klien. ParseId, dan menerima respons terstruktur yang dikunci berdasarkan nama yang Anda definisikan dalam templat. Templat tersebut memuat logika ekstraksi (Ekspresi Regex untuk pola yang stabil, JavaScript Ekspresi (untuk aturan bersyarat), jadi panggilan yang sama ini mengekstrak faktur, kontrak, tanda terima, dan tata letak dokumen khusus apa pun yang telah Anda konfigurasi.

Postingan Blog Terkait
Belum ada postingan blog untuk fitur ini — akan segera hadir.
Sementara itu, jelajahi blog PDF4me untuk menemukan tutorial dan alur kerja di berbagai platform.
Kunjungi blog ini →

Sebelum Anda memanggil endpoint ini: buat templat parse di PDF4me Dasbor. Lihat Siapkan Informasi Penguraian untuk Dokumen untuk panduan pengaturan lengkap, contoh Ekspresi Regex (INV-\d{6,10} untuk nomor faktur, \d{2}/\d{2}/\d{4} (untuk tanggal), dan dua orang yang bekerja JavaScript Contoh pengklasifikasi ekspresi.

Memverifikasi Identitas Anda API Meminta​

Setiap PDF4me REST panggilan harus menyertakan Anda API kunci di Authorization header. Buat atau pilih kunci dari dasbor pengembang dan simpan di sisi server. Jangan pernah mengeksposnya dalam kode browser.

Fakta Penting yang Tidak Boleh Anda Lewatkan​

Muatan minimum adalah tiga bidang, bukan lima.
Hanya Konten dokumen, Nama dokumen, Dan asinkron diperlukan. ID Templat, Nama Templat, Dan ParseId bersifat opsional dan hanya diperlukan jika Anda ingin respons dikunci berdasarkan kolom tangkapan kustom Anda. Tanpa kolom tersebut, API tetap mengembalikan kolom default yang berguna seperti Jenis dokumen Dan Jumlah halaman.
Jawabannya adalah JSON, bukan biner
Hasil penguraian dokumen aplikasi/json dengan satu field per kunci pengambilan data di template Anda ditambah field default. Ini berbeda dari endpoint Protect, Compress, dan Convert yang mengembalikan data biner mentah. PDFs. Parse Document selalu mengembalikan JSON karena mengembalikan data terstruktur, bukan file.
Gunakan TemplateId, bukan TemplateName, dalam produksi.
TemplateId adalah sebuah nilai yang stabil. GUID Ditetapkan oleh dasbor saat Menyimpan Perubahan. Nilai ini tidak pernah berubah selama masa berlaku templat. TemplateName berfungsi sebagai alternatif pencarian tetapi akan rusak jika Anda mengganti nama templat. Selalu salin TemplateId dari panel detail templat dan sematkan di kode Anda.

REST API titik akhir​

Metode: POS
URL: https://api.pdf4me.com/api/v2/ParseDocument

Mengirim Content-Type: application/json dan sebuah Otorisasi header dengan milik Anda API kunci. Atur asinkron ke PALSU untuk respons sinkron (HTTP 200 dengan diuraikan JSON), atau BENAR untuk menerima HTTP 202 ditambah a Lokasi header yang Anda periksa terus-menerus hingga mengembalikan kode 200 dengan data yang telah diuraikan. JSON.

Pengaturan permintaan Postman​

PengaturanNilai
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.

Parameter​

Selalu diperlukan: Konten dokumen, Nama dokumen, asinkron. Bersyarat (ekstraksi berbasis templat): ID Templat (disarankan) atau Nama Templat plus ParseIdTanpa ini, API masih mengembalikan kolom default yang berguna (documentType, pageCount) tetapi tidak ada nilai dengan kunci khusus.

ParameterDiperlukanApa fungsinya?Contoh
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

Minta contoh​

Contoh A: Muatan minimum (tanpa templat)​

Panggilan terkecil API Menerima. Mengembalikan bidang default (documentType, pageCount) tetapi tidak ada nilai kunci khusus karena tidak ada templat yang dirujuk.

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

Contoh B: Ekstraksi berbasis templat (pola produksi)​

Payload produksi yang direkomendasikan. Mengembalikan satu field per kunci pengambilan data yang ditentukan dalam template Anda ditambah field default.

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

Contoh C: Pencarian templat berdasarkan nama​

Alternatif pencarian saat Anda tidak memiliki TemplateId. Hindari penggunaan di lingkungan produksi karena penggantian nama templat akan merusak panggilan ini.

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

Respons berhasil (sinkronisasi, async: false)​

HTTP 200 dengan yang diuraikan JSONSetiap kunci tangkapan dari templat Anda menjadi sebuah field. Field default (documentType, pageCount) selalu dikembalikan.

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

Respons berhasil (asinkron, async: true)​

HTTP 202 dengan sebuah Location Judul. Lakukan jajak pendapat tentang itu. URL dengan GET (header Otorisasi yang sama) hingga Anda menerima HTTP 200 dengan yang diuraikan JSON.

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

contoh 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
}'

Pengaturan templat​

Template parse berisi semua logika ekstraksi. Konfigurasikan sekali di dasbor, lalu panggil dengan TemplateId dari mana saja.

Ekspresi RegexPola yang stabil
Nomor faktur (INV-\d{6,10}), tanggal (\d{2}/\d{2}/\d{4}), jumlah ($?\d{1,3}(?:,\d{3})*(?:.\d{2})?), nomor identifikasi pajak, kode pos. Digunakan untuk sekitar 80% kunci produksi.
Ekspresi JavaScriptLogika kondisional dan pengklasifikasi
Klasifikasi multi-marker, aturan cadangan, deteksi tipe dokumen. Teks yang diekstrak diteruskan sebagai variabel. teksFungsi Anda mengembalikan string. Lihat Siapkan Informasi Penguraian untuk Dokumen untuk dua contoh pengklasifikasi yang berfungsi (functionFormatTextDate1 dan functionGetInvoiceOrder).

Contoh kode​

Sampel yang sudah jadi yang memuat PDF, mengkodekannya sebagai Base64, POST ke /api/v2/ParseDocumentdan menangani respons sinkron/asinkron.

Contoh integrasi​

Pola integrasi REST umumTypical ways developers call Parse Document.
Kotak masuk faktur ke basis data akuntansi
  1. Seorang pengamat menemukan vendor baru. PDFs dari kotak masuk email atau folder cloud.
  2. Layanan Anda membaca setiap PDF sebagai byte dan mengkodekannya sebagai Base64.
  3. POST ke /api/v2/ParseDocument dengan TemplateId faktur dan ParseId baru.
  4. Petakan yang dikembalikan Nomor faktur, Jumlah total, Dan Tanggal faktur langsung ke dalam basis data INSERT.
Pengklasifikasi dan ekstraktor dokumen campuran
  1. A JavaScript Kunci ekspresi dalam templat mengembalikan tipe dokumen (faktur, pesanan, syarat pembayaran).
  2. POST mengembalikan tipe beserta kolom yang diekstrak menggunakan regex dalam satu tampilan. JSON tanggapan.
  3. Kode Anda bercabang berdasarkan bidang tipe dan mengarahkan data terstruktur ke sistem hilir yang tepat.
Pemrosesan asinkron batch untuk data besar. PDFs
  1. Untuk file yang berukuran lebih dari beberapa MB, POST dengan asinkron: benar.
  2. Bacalah Lokasi Header dari respons 202.
  3. Jajak pendapat URL dengan GET setiap 10 detik ( Python Contoh ini menggunakan maksimal 15 kali percobaan ulang.
  4. Ketika status responsnya adalah 200, uraikan JSON tubuh dan melanjutkan pemrosesan hilir.

Pertanyaan yang Sering Diajukan​

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.

Tindakan terkait​

Tugas yang sama di platform lain​

Dapatkan Bantuan​