Download the PHP package docxtract/php-sdk without Composer
On this page you can find all versions of the php package docxtract/php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download docxtract/php-sdk
More information about docxtract/php-sdk
Files in docxtract/php-sdk
Package php-sdk
Short Description Official PHP SDK for the DocXtract document extraction API
License MIT
Homepage https://docxtract.io
Informations about the package php-sdk
DocXtract PHP SDK
Official PHP client for the DocXtract document extraction API.
Extract structured JSON from invoices, KYC documents, bank statements, HR paperwork, and 20+ other document types.
Requirements
PHP 8.1+ with the curl and json extensions. No other dependencies — no Guzzle, no
PSR-18. The SDK uses plain cURL so it drops into shared hosting without version conflicts.
Install
Get an API key
The SDK is free and open source. The API it talks to needs an account.
- Go to docxtract.io and choose Start Free Trial
- Credentials arrive by email — no card required, no sales call
- Sign in at app.docxtract.io and copy your key from Settings
Keep the key in an environment variable, never in source control:
Two calls cost no credits, so you can confirm setup before spending anything:
Need higher limits, more credits, or a custom document type? [email protected].
Quickstart
The key separator matters. DocXtract keys are
sk_with an underscore. A hyphen afterskmeans the key belongs to a different API provider — the SDK rejects it up front rather than letting you debug a 401.
Large PDFs are the point of this SDK
The API does not process a PDF over 3 pages synchronously. It splits the document and
returns 202 with a chunk manifest; you must then call process once per chunk and
result to collect — handling retries, single-flight conflicts, a 2-hour job TTL, and
partial results along the way.
extract() does all of that for you:
Same call, any page count. With progress reporting:
Why chunks are processed sequentially
The API's default rate limit is 10 requests per minute. Firing chunks in parallel does not
finish sooner — it converts the work into 429s. If your key has tighter limits, pace the
calls:
Manual control
The three raw calls are public if you want to drive the flow yourself — for example to distribute chunks across workers:
collectResult() is a pure read, re-fetchable within the TTL — so it doubles as a progress
poll from another process.
collectResult($jobId, finalize: true)is irreversible. It permanently deletes all extracted data for the job. Only passtrueonce the result is stored on your side.
Discovering document types
models() costs no credits, so it is safe on every page load or to populate a dropdown.
It returns only the types your key is permitted to use.
Error handling
Every API error code maps to a typed exception, so you can branch with catch instead of
string-matching messages:
For finer branching, read the code off the base class:
| Exception | Codes |
|---|---|
AuthenticationException |
invalid_api_key, expired_api_key |
QuotaException |
usage_limit_exceeded, insufficient_credits |
RateLimitException |
rate_limit_exceeded, too_many_open_jobs |
RequestException |
invalid_request, invalid_file, invalid_file_type, file_too_large, invalid_options, unknown_model, page_limit_exceeded, method_not_allowed |
ExtractionFailedException |
extraction_failed |
JobException |
job_not_found, job_expired, chunk_in_progress, chunk_source_lost |
ServerException |
server_error, persist_failed, server_busy |
TransportException |
network failure — the API never answered |
An unrecognised code falls back to DocXtractException rather than throwing, so a new
server-side code will not break a deployed copy of this SDK.
Billing note.
extraction_failedon the synchronous path still deducts 1 credit. Budget for it when reconciling usage. On the multi-page path the chunk stays available and is not charged until it succeeds.persist_failedcharges nothing.
Pre-flight validation
File type and size are checked locally before any network call, so an unsupported file costs no round trip and no credits. Accepted: PDF, JPG, PNG, up to 10 MB and 150 pages.
Configuration
The base URL has no
/apiprefix./apiis the server's docroot, not part of the public path. If you see aTransportExceptionabout non-JSON output, this is usually why.
Pinning to v3
base_path exists for customers still on the older version:
v3 has no models and no multi-page support, and accepts PDF only. models() throws a
clear error rather than a confusing 404. New integrations should stay on v3.1.
Tests
The suite is offline — no API key or network needed. tests/bootstrap.php falls back to a
built-in PSR-4 autoloader if vendor/ is absent.
Links
- Documentation — https://docs.docxtract.io
- Interactive API reference — https://app.docxtract.io/api-reference.php
- OpenAPI spec —
docs/openapi.yamlin the platform repo - Support — [email protected]
Built by RPATech | docxtract.io
All versions of php-sdk with dependencies
ext-curl Version *
ext-json Version *