Read SwissQR Code - Payment Data Extractor API
PDF4me Read SwissQR Code enables you to extract and read SwissQR codes from PDF documents using advanced OCR and barcode recognition technology. This API service processes PDF files and extracts structured payment information including amounts, currency, IBAN, creditor details, and payment references for seamless digital payment processing. The API receives PDF content through REST API calls, utilizing Base64 encoding for secure transmission. This solution is ideal for invoice processing, banking integration, payment automation, and financial reporting.
Authenticating Your API Request
To access the PDF4me REST API, every request must include proper authentication credentials. Authentication ensures secure communication and validates your identity as an authorized user of the REST API.
Key Features
- SwissQR Code Recognition: Extract and read SwissQR codes from PDF documents using advanced OCR and barcode recognition technology
- Structured Payment Data: Extract structured payment information including amounts, currency, IBAN, creditor details, and payment references
- Swiss Payment Standard: Support for Swiss QR-bill digital payment standard (June 2020)
- Asynchronous Processing: Support for async processing with polling for long-running operations
SwissQR Code Support
The API supports reading SwissQR codes from PDF documents. SwissQR codes contain structured payment information including amount, currency, IBAN, creditor details, and payment references. The extracted data is returned in a standardized format for integration with payment processing systems.
REST API Endpoint
The PDF4me REST API uses standard HTTP methods to interact with resources. All SwissQR code reading operations are performed through a single endpoint:
- Method: POST
- Endpoint:
/api/v2/ReadSwissQRBill
REST API Parameters
Complete list of parameters for the Read SwissQR Code REST API. Parameters are organized by category for better understanding and implementation.
Important: Parameters marked with an asterisk (*) are required and must be provided for the API to function correctly.
Required Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| docContent* | Base64 | PDF file content encoded in Base64 containing SwissQR codes | JVBERi... |
| docName* | String | PDF file name with .pdf extension | invoice.pdf |
| async* | Boolean | Enable asynchronous processing. When true, the API returns a 202 status and provides a polling URL in the Location header | true |
Output
The PDF4me Read SwissQR Code REST API returns different responses based on the processing mode. The API returns structured JSON data with SwissQR code information.
- Success Response
- Asynchronous Processing
- Error Responses
- Response Format Details
Synchronous Processing (Default)
When async is not set or set to false, the API processes the request immediately:
Status Code: 200 OK
Content-Type: application/json
Response Body:
{
"fileName": "invoice.pdf",
"mimeType": "application/pdf",
"fileSize": 2456789,
"success": true,
"swissQrCodeData": {
"amount": "100.00",
"currency": "CHF",
"iban": "CH9300762011623852957",
"creditorName": "Swiss Company AG",
"paymentReference": "INV-2024-001",
"dueDate": "2024-12-31",
"purpose": "Invoice payment"
}
}
Response Fields:
- fileName (string): The PDF file name
- mimeType (string): MIME type of the file (application/pdf)
- fileSize (number): Size of the PDF file in bytes
- success (boolean): Indicates if SwissQR code was successfully read
- swissQrCodeData (object): Extracted SwissQR code payment information
- amount (string): Payment amount
- currency (string): Currency code (CHF, EUR, USD)
- iban (string): IBAN of the creditor
- creditorName (string): Creditor name or company
- paymentReference (string): Payment reference number
- dueDate (string): Payment due date (if available)
- purpose (string): Payment purpose or description
Example (JavaScript):
const response = await fetch(url, options);
const data = await response.json();
if (data.success) {
console.log(`Amount: ${data.swissQrCodeData.amount} ${data.swissQrCodeData.currency}`);
console.log(`IBAN: ${data.swissQrCodeData.iban}`);
}
Asynchronous Processing
When async: true is set, the API processes the request asynchronously:
Status Code: 202 Accepted
Response Headers:
Location: https://api.pdf4me.com/api/v2/ReadSwissQRBill/poll/12345-abcde-67890
Polling Process:
- Extract the
Locationheader from the 202 response - Poll the URL using GET requests
- Continue polling until you receive a 200 OK status
- The final response contains the same JSON format with SwissQR code data
Polling Example:
// Initial request returns 202 with Location header
const response = await fetch(url, options);
const location = response.headers.get('Location');
// Poll until complete
while (true) {
const pollResponse = await fetch(location, { headers: { 'Authorization': 'Basic ' + apiKey } });
if (pollResponse.status === 200) {
const data = await pollResponse.json();
// Process data.swissQrCodeData
break;
}
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds
}
Error Responses
The API returns standard HTTP error codes with error details:
- Invalid request parameters
- Missing required fields (
docContent,docName,async) - Invalid Base64 encoding in
docContent - PDF does not contain SwissQR codes
- Invalid or missing API key
- API key not properly Base64 encoded in Authorization header
- Missing
Authorization: Basicheader
- Server-side processing error
- PDF processing failure
- SwissQR code recognition failure
Error Response Format:
{
"error": "Error message describing what went wrong"
}
Response Format Details
Important: The API always returns JSON with structured SwissQR code data.
Response Structure:
{
"fileName": "string", // PDF filename
"mimeType": "string", // MIME type
"fileSize": number, // File size in bytes
"success": boolean, // Success indicator
"swissQrCodeData": { // SwissQR code data object
"amount": "string", // Payment amount
"currency": "string", // Currency code
"iban": "string", // IBAN
"creditorName": "string", // Creditor name
"paymentReference": "string", // Payment reference
"dueDate": "string", // Due date (optional)
"purpose": "string" // Payment purpose (optional)
}
}
Content-Type Header:
- Success:
application/json
No SwissQR Code Found:
If no SwissQR code is found in the PDF, the response may indicate success: false or the swissQrCodeData field may be null or empty.
Request Example
Header
Content-Type: application/json
Authorization: Basic YOUR_BASE64_ENCODED_API_KEY
Note:
- Get your API key from the PDF4me Dashboard
- The API key must be Base64 encoded and prefixed with "Basic " in the Authorization header
- Example: If your API key is
abc123, encode it to Base64 and useAuthorization: Basic YWJjMTIz
Payload
Example:
{
"docContent": "JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9LaWRzIFszIDAgUl0KL0NvdW50IDEKPD4KZW5kb2JqCjMgMCBvYmoKPDwKL1R5cGUgL1BhZ2UKL1BhcmVudCAyIDAgUgovTWVkaWFCb3ggWzAgMCA2MTIgNzkyXQovUmVzb3VyY2VzIDw8Ci9Gb250IDw8Ci9GMSA0IDAgUgo+Pgo+PgovQ29udGVudHMgNSAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwKL1R5cGUgL0ZvbnQKL1N1YnR5cGUgL1R5cGUxCi9CYXNlRm9udCAvSGVsdmV0aWNhCj4+CmVuZG9iago1IDAgb2JqCjw8Ci9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCi9GMSAxMiBUZgoxMDAgNzAwIFRkCihIZWxsbyBXb3JsZCkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagp4cmVmCjAgNgowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMDkgMDAwMDAgbiAKMDAwMDAwMDA1NCAwMDAwMCBuIAowMDAwMDAwMTAxIDAwMDAwIG4gCjAwMDAwMDAxNzAgMDAwMDAgbiAKMDAwMDAwMDI0NCAwMDAwMCBuIAp0cmFpbGVyCjw8Ci9TaXplIDYKL1Jvb3QgMSAwIFIKPj4Kc3RhcnR4cmVmCjM0MQolJUVPRg==",
"docName": "invoice.pdf",
"async": true
}
Code Samples
The PDF4me Read SwissQR Code REST API provides code samples in multiple programming languages. Choose the language that best fits your development environment:
- C#
- Java
- JavaScript
- Python
- Salesforce
- n8n
- Google Script
- AWS Lambda
C# (CSharp) Sample
Complete C# implementation for reading SwissQR codes from PDF documents:
Google Script Sample
Google Apps Script implementation for Google Workspace integration:
Industry Use Cases & Applications
- Finance & Banking
- Business & Enterprise
- Government & Compliance
Finance & Banking Use Cases
- Invoice Processing: Extract payment information from Swiss QR invoices for automated payment processing
- Banking Integration: Integrate SwissQR code reading into banking applications and payment systems
- Payment Automation: Streamline payment workflows and reduce manual data entry
- Bill Processing: Automate Swiss QR bill processing and payment verification
- Payment Reconciliation: Automate payment matching and reconciliation processes
- Financial Reporting: Extract payment data from Swiss QR codes for financial reporting and analysis
Business & Enterprise Use Cases
- Invoice Management: Automate invoice processing and payment tracking
- Accounting Systems: Integrate SwissQR code reading into accounting and ERP systems
- Financial Documents: Process financial documents containing Swiss QR codes
- Payment Integration: Integrate Swiss QR codes into existing payment processing systems
- Digital Transformation: Modernize payment processing workflows
- Business Process Automation: Automate payment workflows for enterprise operations
Government & Compliance Use Cases
- Compliance Management: Ensure compliance with Swiss banking regulations and payment standards
- Regulatory Compliance: Process Swiss QR codes for regulatory compliance and auditing
- Government Payments: Process government payment documents with Swiss QR codes
- Financial Compliance: Ensure compliance with Swiss financial regulations