Get Parser
This guide explains how to retrieve a specific parser from your account using its ID.
#
Get a parser by ID#
API EndpointGET https://api.documentpro.ai/v1/templates/{template_id}
#
Path Parameterstemplate_id
(required): The unique identifier of the parser you want to retrieve.
#
Example implementation using Pythonimport requests
# Your API keyapi_key = 'YOUR_API_KEY'
template_id = 'YOUR_TEMPLATE_ID'url = f"https://api.documentpro.ai/v1/templates/{template_id}"
headers = { 'x-api-key': api_key}
response = requests.get(url, headers=headers)
if response.status_code == 200: print('Parser retrieved successfully') print(response.json())else: print('Failed to retrieve parser') print(response.text)
#
Successful response bodyExample response with status code 200
:
{ "template_id": "710a20fc-e280-43eb-9a9f-5436e600c710", "template_title": "Custom Invoice Parser", "template_type": "Invoice", "template_category": "other", "template_schema": { "fields": [ { "name": "buyer_name", "type": "text", "description": "name of the buyer" }, { "name": "total_amount", "type": "number" }, { "name": "line_items", "type": "table", "description": "invoice line items", "subFields": [ { "name": "description", "type": "text", "description": "description of item" }, { "name": "subtotal", "type": "number" } ] } ] }, "email_id": "test_parser_22_fbb499@inbox.documentpro-ai.com", "webhook_url": null, "parser_config": { "parse_email_attachments": true, "parse_email_body": false, "date_format": null, "outbound_integration": null, "ocr_config": { "engine": "aws_textract", "detect_layout": true, "detect_tables": false, "remove_headers": true, "remove_footers": true, "remove_tables": false }, "query_config": { "query_model": "gpt-4o-mini", "set_max_output_tokens": false, "include_example": false, "minimize_tokens": true, "selected_language": null } }, "created_at": "2023-11-15T12:13:12.056281"}
#
Error responses- If the parser is not found (status code
404
):
{ "success": false, "error": "not_found", "message": "Parser not found"}
- For other errors (status codes
400
,401
,403
, and500
):
{ "success": false, "error": "error_code", "message": "descriptive error message"}
#
Using the retrieved parserOnce you've successfully retrieved a parser, you can use its details to:
- Understand the structure of data it extracts (
template_schema
). - See its configuration settings (
parser_config
). - Use its
template_id
for other operations, such as updating the parser or processing documents with it. - Check its associated email address (
email_id
) for submitting documents via email.
Remember to handle potential errors in your application, especially the case where a parser might not be found.