Name | doctly JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | Python client library for the Doctly API |
upload_time | 2024-10-10 04:42:54 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | None |
keywords |
doctly
api
client
pdf
markdown
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Doctly
Doctly is a Python client library that provides a simple way to interact with the Doctly backend API. With Doctly, you can effortlessly upload PDF documents, convert them to Markdown, and retrieve the converted files—all with just a few lines of code.
## Table of Contents
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Initialization](#initialization)
- [Convert PDF to Markdown](#convert-pdf-to-markdown)
- [Customizing Polling Parameters](#customizing-polling-parameters)
- [Error Handling](#error-handling)
- [API Reference](#api-reference)
- [`Client` Class](#client-class)
- [`DoctlyError` Exception](#doctlyerror-exception)
- [Contributing](#contributing)
- [Contact](#contact)
## Installation
Doctly can be easily installed using `pip`. Run the following command in your terminal:
```bash
pip install doctly
```
## Quick Start
Here's a quick example to get you started with Doctly:
```python
import doctly
# Initialize the Doctly client with your API key
client = doctly.Client(api_key='YOUR_API_KEY')
# Convert a PDF file to Markdown
try:
markdown_content = client.to_markdown('path/to/your/file.pdf')
# Save the Markdown content to a file
with open('output.md', 'w') as f:
f.write(markdown_content)
print("Conversion successful! Markdown file saved as 'output.md'")
except doctly.DoctlyError as e:
print(f"An error occurred: {e}")
```
## Usage
### Initialization
To begin using Doctly, initialize the `Client` class with your API key:
```python
import doctly
# Replace 'YOUR_API_KEY' with your actual API key
client = doctly.Client(api_key='YOUR_API_KEY')
```
### Convert PDF to Markdown
The primary functionality of Doctly is to upload a PDF file, convert it to Markdown, and retrieve the converted content. Here's how to do it:
```python
try:
markdown_content = client.to_markdown('path/to/your/file.pdf')
# Optional: Save the Markdown content to a file
with open('output.md', 'w') as f:
f.write(markdown_content)
print("Conversion successful!")
except doctly.DoctlyError as e:
print(f"An error occurred: {e}")
```
### Customizing Polling Parameters
Doctly handles the asynchronous nature of the backend API by polling the document status. You can customize the polling interval (`wait_time`) and the maximum waiting duration (`timeout`) as needed:
```python
markdown_content = client.to_markdown(
'path/to/your/file.pdf',
wait_time=10, # Time in seconds between each status check
timeout=600 # Maximum time in seconds to wait for processing
)
```
### Error Handling
Errors are handled with the `DoctlyError` exception. Catch this exception to handle any issues that arise during the upload, conversion, or download processes:
```python
try:
markdown_content = client.to_markdown('file.pdf')
except doctly.DoctlyError as e:
print(f"Error: {e}")
# Additional error handling logic
```
## API Reference
### `Client` Class
The `Client` class encapsulates all interactions with the Doctly backend API.
#### `__init__(api_key: str)`
- **Description**: Initializes the Doctly client with the provided API key and optional base URL.
- **Parameters**:
- `api_key` (str): Your Doctly API key.
- **Example**:
```python
client = doctly.Client(api_key='YOUR_API_KEY')
```
#### `to_markdown(file_path: str, wait_time: int = 5, timeout: int = 300) -> str`
- **Description**: Uploads a PDF file to the backend, polls for processing status, and returns the converted Markdown content.
- **Parameters**:
- `file_path` (str): Path to the PDF file to upload.
- `wait_time` (int, optional): Time in seconds between each status check. Defaults to `5` seconds.
- `timeout` (int, optional): Maximum time in seconds to wait for processing. Defaults to `300` seconds (5 minutes).
- **Returns**:
- `markdown_content` (str): The content of the converted Markdown file.
- **Raises**:
- `DoctlyError`: If there's an error during upload, processing, or download.
- **Example**:
```python
markdown = client.to_markdown('document.pdf')
```
### `DoctlyError` Exception
A custom exception class for handling errors specific to the Doctly library.
#### Example Usage
```python
try:
markdown_content = client.to_markdown('file.pdf')
except doctly.DoctlyError as e:
print(f"Doctly encountered an error: {e}")
```
## Contributing
Contributions are welcome! To contribute to Doctly, please follow these steps:
Please ensure that your code follows the project's coding standards and includes relevant tests.
## Contact
For any questions, issues, or feature requests, please open an issue on [GitHub](https://github.com/doctly/doctly/issues)
Raw data
{
"_id": null,
"home_page": null,
"name": "doctly",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "doctly, api, client, pdf, markdown",
"author": null,
"author_email": "Doctly <support@doctly.ai>",
"download_url": "https://files.pythonhosted.org/packages/fe/fe/e79e5ada38235f72aa95e0513c726e0b986a25c25c5cc970d783658bba77/doctly-0.1.0.tar.gz",
"platform": null,
"description": "# Doctly\n\nDoctly is a Python client library that provides a simple way to interact with the Doctly backend API. With Doctly, you can effortlessly upload PDF documents, convert them to Markdown, and retrieve the converted files\u2014all with just a few lines of code.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Usage](#usage)\n - [Initialization](#initialization)\n - [Convert PDF to Markdown](#convert-pdf-to-markdown)\n - [Customizing Polling Parameters](#customizing-polling-parameters)\n - [Error Handling](#error-handling)\n- [API Reference](#api-reference)\n - [`Client` Class](#client-class)\n - [`DoctlyError` Exception](#doctlyerror-exception)\n- [Contributing](#contributing)\n- [Contact](#contact)\n\n## Installation\n\nDoctly can be easily installed using `pip`. Run the following command in your terminal:\n\n```bash\npip install doctly\n```\n\n## Quick Start\n\nHere's a quick example to get you started with Doctly:\n\n```python\nimport doctly\n\n# Initialize the Doctly client with your API key\nclient = doctly.Client(api_key='YOUR_API_KEY')\n\n# Convert a PDF file to Markdown\ntry:\n markdown_content = client.to_markdown('path/to/your/file.pdf')\n \n # Save the Markdown content to a file\n with open('output.md', 'w') as f:\n f.write(markdown_content)\n \n print(\"Conversion successful! Markdown file saved as 'output.md'\")\nexcept doctly.DoctlyError as e:\n print(f\"An error occurred: {e}\")\n```\n\n## Usage\n\n### Initialization\n\nTo begin using Doctly, initialize the `Client` class with your API key:\n\n```python\nimport doctly\n\n# Replace 'YOUR_API_KEY' with your actual API key\nclient = doctly.Client(api_key='YOUR_API_KEY')\n```\n\n### Convert PDF to Markdown\n\nThe primary functionality of Doctly is to upload a PDF file, convert it to Markdown, and retrieve the converted content. Here's how to do it:\n\n```python\ntry:\n markdown_content = client.to_markdown('path/to/your/file.pdf')\n \n # Optional: Save the Markdown content to a file\n with open('output.md', 'w') as f:\n f.write(markdown_content)\n \n print(\"Conversion successful!\")\nexcept doctly.DoctlyError as e:\n print(f\"An error occurred: {e}\")\n```\n\n### Customizing Polling Parameters\n\nDoctly handles the asynchronous nature of the backend API by polling the document status. You can customize the polling interval (`wait_time`) and the maximum waiting duration (`timeout`) as needed:\n\n```python\nmarkdown_content = client.to_markdown(\n 'path/to/your/file.pdf',\n wait_time=10, # Time in seconds between each status check\n timeout=600 # Maximum time in seconds to wait for processing\n)\n```\n\n### Error Handling\n\nErrors are handled with the `DoctlyError` exception. Catch this exception to handle any issues that arise during the upload, conversion, or download processes:\n\n```python\ntry:\n markdown_content = client.to_markdown('file.pdf')\nexcept doctly.DoctlyError as e:\n print(f\"Error: {e}\")\n # Additional error handling logic\n```\n\n## API Reference\n\n### `Client` Class\n\nThe `Client` class encapsulates all interactions with the Doctly backend API.\n\n#### `__init__(api_key: str)`\n\n- **Description**: Initializes the Doctly client with the provided API key and optional base URL.\n- **Parameters**:\n - `api_key` (str): Your Doctly API key.\n- **Example**:\n\n ```python\n client = doctly.Client(api_key='YOUR_API_KEY')\n ```\n\n#### `to_markdown(file_path: str, wait_time: int = 5, timeout: int = 300) -> str`\n\n- **Description**: Uploads a PDF file to the backend, polls for processing status, and returns the converted Markdown content.\n- **Parameters**:\n - `file_path` (str): Path to the PDF file to upload.\n - `wait_time` (int, optional): Time in seconds between each status check. Defaults to `5` seconds.\n - `timeout` (int, optional): Maximum time in seconds to wait for processing. Defaults to `300` seconds (5 minutes).\n- **Returns**:\n - `markdown_content` (str): The content of the converted Markdown file.\n- **Raises**:\n - `DoctlyError`: If there's an error during upload, processing, or download.\n- **Example**:\n\n ```python\n markdown = client.to_markdown('document.pdf')\n ```\n\n### `DoctlyError` Exception\n\nA custom exception class for handling errors specific to the Doctly library.\n\n#### Example Usage\n\n```python\ntry:\n markdown_content = client.to_markdown('file.pdf')\nexcept doctly.DoctlyError as e:\n print(f\"Doctly encountered an error: {e}\")\n```\n\n## Contributing\n\nContributions are welcome! To contribute to Doctly, please follow these steps:\nPlease ensure that your code follows the project's coding standards and includes relevant tests.\n\n## Contact\n\nFor any questions, issues, or feature requests, please open an issue on [GitHub](https://github.com/doctly/doctly/issues)\n",
"bugtrack_url": null,
"license": null,
"summary": "Python client library for the Doctly API",
"version": "0.1.0",
"project_urls": {
"Bug Tracker": "https://github.com/doctly/doctly/issues",
"Documentation": "https://github.com/doctly/doctly#readme",
"Homepage": "https://doctly.ai",
"Source": "https://github.com/doctly/doctly"
},
"split_keywords": [
"doctly",
" api",
" client",
" pdf",
" markdown"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d05c81a9d3721f4fc89e8d28ca3cae585081ddf18a5196ce99ce3feb0657b2a5",
"md5": "c4762bc93ee146496b477ffd6d647d8c",
"sha256": "bf5502ff0f9f839dc555eb57074ea809b7a2d759918763678c1bf1813f500a74"
},
"downloads": -1,
"filename": "doctly-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c4762bc93ee146496b477ffd6d647d8c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 5118,
"upload_time": "2024-10-10T04:42:52",
"upload_time_iso_8601": "2024-10-10T04:42:52.842461Z",
"url": "https://files.pythonhosted.org/packages/d0/5c/81a9d3721f4fc89e8d28ca3cae585081ddf18a5196ce99ce3feb0657b2a5/doctly-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fefee79e5ada38235f72aa95e0513c726e0b986a25c25c5cc970d783658bba77",
"md5": "1c7d36a97f3aec11cd78fce6489665fd",
"sha256": "00708a46bfa9360014f310419ff91149aaf92cf2fb073e0fb966224c2c581a24"
},
"downloads": -1,
"filename": "doctly-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "1c7d36a97f3aec11cd78fce6489665fd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 5752,
"upload_time": "2024-10-10T04:42:54",
"upload_time_iso_8601": "2024-10-10T04:42:54.635884Z",
"url": "https://files.pythonhosted.org/packages/fe/fe/e79e5ada38235f72aa95e0513c726e0b986a25c25c5cc970d783658bba77/doctly-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-10 04:42:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "doctly",
"github_project": "doctly",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "doctly"
}