Documind's API Transforms PDF Management with Advanced Document Processing
Documind offers powerful document management capabilities through its API, enabling users to upload, retrieve, and analyze PDF content. This comprehensive documentation outlines API fundamentals, including authentication requirements and error handling mechanisms. The guide then delves into core API functionalities, such as file management, content retrieval, and conversation management, providing detailed examples and implementation guidance. Understanding this documentation is crucial for developers integrating Documind's advanced document processing capabilities into their applications.
The Documind API requires authentication through a secretkey parameter. All API requests must include this key to be processed, which can be obtained from the user's profile page.
To authenticate API requests, include the secretkey parameter in every API call. This key serves as the authorization mechanism for access to API functionality.
The API supports several fundamental operations for managing Documind accounts and interacting with documents:
Upload files using the endpoint http://documind.onrender.com/api-upload-file. The request requires a secretkey parameter and a file parameter (the PDF file as a Blob). You may also specify a folder_id to upload files into a specific folder.
Retrieve documents using the http://documind.onrender.com/api-get-summary endpoint. This operation requires both secretkey and documentId parameters.
Interact with PDF content through the http://documind.onrender.com/api-ask-from-collection endpoint. This endpoint requires secretkey and question parameters.
The API responds with JSON formatted data containing the answer, index, and documents array. Each document entry includes details such as id, file, page, score, paragraph, and file_url.
The API follows standard HTTP error codes for communication. Common error responses include:
500: Server-related or OpenAI errors, with specific error messages provided
402: Billing-related errors
The Documind API supports several operations for managing documents directly within the system. These operations include file upload, document retrieval, and conversation management.
Files can be uploaded to the system using the endpoint http://documind.onrender.com/api-upload-file. This operation requires an API key and the file content as a Blob. Optionally, the folder ID can be specified to upload files into a designated directory. Upon successful upload, the API returns an idOfDocument, file_url, and other metadata details.
Retrieve document summaries using the http://documind.onrender.com/api-get-summary endpoint. This operation requires both the API key and the document ID. The response contains the summary text, its index position, and references to the underlying documents.
The API includes functionality for managing conversations related to documents. Requests to this endpoint require the API key and a question parameter. The response provides the answer, along with metadata about the source documents, including their IDs, file names, and URLs.
The system also supports basic folder management operations, including creating and deleting folders, as well as retrieving folder information. These operations typically require similar authentication mechanisms as other API calls, though specific endpoint details were not provided in the available documentation.
The Content Retrieval functionality of the Documind API enables users to extract structured information from their uploaded documents. Two primary operations are supported: retrieving document summaries and chatting with PDF content.
Summarizing documents is achieved through the http://documind.onrender.com/api-get-summary endpoint. This operation requires both the secrets key and document ID as parameters. The API responds with a JSON object containing the summary text, its index position, and references to the underlying documents. Each document reference includes details such as ID, file name, page number, relevance score, specific paragraph, and full file URL.
Example usage of the API endpoint is demonstrated via the curl command:
curl -X POST http://documind.onrender.com/api-get-summary \
-F 'secretkey=your_api_key' \
-F 'documentId=u53232d9-511b-4ab2-861c-af88414bd73e'
The API also provides capabilities for interacting with the content of PDF documents through the http://documind.onrender.com/api-ask-from-collection endpoint. This operation requires the secretkey parameter along with a question parameter. The API responds with the answer to the question, along with metadata about the source documents, including their IDs, file names, and URLs.
The response structure for the content chat operation includes the following elements:
Answer: The direct response to the question
Index: The location indicator for the answer within the document
Documents: An array of document references containing detailed information about the source documents, including their file name and URL
The API employs a multi-step processing flow when handling content chat requests. First, the API attempts to locate all relevant passages within the indexed documents that may contain the answer. For each relevant passage, it calculates a relevance score based on factors such as textual proximity and semantic similarity. The passages with the highest scores are then selected for inclusion in the final response, along with their metadata.
While the standard HTTP error codes (such as 500 for server-related errors or 402 for billing errors) apply to these operations, the API also provides specific error handling mechanisms for document retrieval failures. For instance, if a requested document ID is invalid or the document cannot be accessed, the API returns a 404 Not Found error with an appropriate error message. Similarly, database errors during the processing stage are indicated by a 500 Internal Server Error response, which includes the specific error message for troubleshooting purposes.
The API follows standard HTTP error codes for communication, with specific error messages indicating the nature of the failure. Upon encountering an error, the API returns a JSON response containing the error code, error message, and additional details as appropriate.
The most common error codes include:
500 Internal Server Error: Indicates a server-related issue, including OpenAI errors. The response includes an error message that helps with troubleshooting.
402 Payment Required: Signifies a billing-related error. This code appears when API usage exceeds the free tier limits or when payment information is required.
Developers implementing the API should incorporate error handling logic to manage different response scenarios:
Successful requests receive a 200 OK response with a JSON payload containing the requested data.
For invalid requests (e.g., missing parameters), the API returns a 400 Bad Request response with appropriate error details.
Network errors should be handled separately, as they may occur before the API receives the request.
To ensure reliable API usage:
Validate API key parameters to prevent unauthorized requests
Implement retry mechanisms for transient errors (e.g., 500 errors)
Provide clear error messages to users when a request fails
Monitor API usage to detect and address billing issues (402 errors)
By following these guidelines and understanding the specific error responses, developers can create robust systems that seamlessly interact with the Documind API.
API keys serve as the primary mechanism for authenticating requests to the Documind API. These keys must be included in every API call as a secretkey parameter to verify the request's legitimacy.
Secure Storage: Keep API keys in secure locations and never store them in plaintext within your source code. Utilize environment variables or secure secret management services to protect API keys.
Limit Key Usage: Restrict API key usage to specific development environments when testing. During production, use API keys scoped to the minimum necessary access level.
Rotate Keys Regularly: Implement a key rotation policy to ensure that compromised keys can be quickly replaced. This best practice helps maintain security even if keys are exposed.
Request Validation: Always validate the secretkey parameter on the server-side to prevent unauthorized requests. Verify the key format and immediately reject requests with invalid keys.
Rate Limiting: Apply rate limiting based on IP addresses or API keys to prevent abuse. This measure helps protect against brute-force attacks and excessive API usage.
Error Handling: Implement proper error handling for authentication failures. Instead of detailed error messages, return generic error responses to avoid exposing sensitive information.
By following these guidelines, developers can ensure that API keys are managed securely, protecting both their own systems and the Documind service from unauthorized access and misuse.