Skip to main content

Command-line tool for recursively traversing directories to print file paths and their contents.

Project description

A-Parser Async Python Library

Overview

The A-Parser Async Python Library is a powerful, modern, and feature-rich solution for interacting with the A-Parser API using Python. Designed for developers who require robust and efficient API integration, this library leverages Python's asynchronous capabilities and the Pydantic library for schema validation, ensuring performance, reliability, and ease of use.


Key Features

🌟 Asynchronous API

The library is fully asynchronous, built on Python's asyncio and httpx to maximize performance and responsiveness. It allows for non-blocking API requests, enabling efficient parallel task management.

📜 Pydantic-Based Validation

Every request and response is validated using Pydantic models. This ensures data integrity, provides clear error messages, and reduces the risk of bugs caused by malformed data.

💡 Simplified API Integration

With thoughtfully designed methods, the library simplifies interaction with the A-Parser API, including task management, proxy checker control, and result retrieval.

🔧 Comprehensive Functionality

The library supports a wide range of features offered by the A-Parser API:

  • Add tasks to the queue
  • Retrieve task states and results
  • Manage and delete tasks
  • Control proxy checker states
  • Handle task results with ease

Installation

pip install aparser-async

Usage

Import the Library

from aparser_async import AParser, schemas, AParserError

Initialize the Client

aparser = AParser(address="http://127.0.0.1", password="your_password", port=9091)

Examples

1. Ping the API

import asyncio

async def check_api():
    response = await aparser.ping()
    print(f"Ping response: {response}")

asyncio.run(check_api())

2. Add a Task

task_data = schemas.Data(
    preset="example_preset",
    parsers=[["parser1"], ["parser2"]],
    queries="example_query"
)

async def create_task():
    task_id = await aparser.add_task(task_data)
    print(f"Task created with ID: {task_id}")

asyncio.run(create_task())

3. Get Task Status

async def get_status(task_id):
    status = await aparser.get_task_state(task_id)
    print(f"Task {task_id} Status: {status.status}")

asyncio.run(get_status(task_id=12345))

4. Wait for Task Completion

async def wait_for_task(task_id):
    try:
        await aparser.wait_for_task(task_id, delay=2, timeout=60)
        print(f"Task {task_id} completed successfully!")
    except AParserError as e:
        print(f"Task {task_id} failed: {e}")

asyncio.run(wait_for_task(task_id=12345))

Benefits

🚀 Performance

Asynchronous programming allows you to handle multiple tasks efficiently, saving time and system resources.

✅ Reliability

The library ensures every interaction with the A-Parser API is validated, reducing the chance of runtime errors.

🛠️ Developer-Friendly

With clear documentation, intuitive APIs, and detailed logging, this library is designed for seamless integration into your Python projects.


Requirements

  • Python 3.8+
  • A running instance of A-Parser
  • httpx for HTTP requests
  • pydantic for schema validation

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes. Ensure your code adheres to PEP 8 and includes tests for new functionality.


License

This library is licensed under the MIT License. See the LICENSE file for more details.


Acknowledgements

Special thanks to the developers of:


With A-Parser Async, managing your API tasks has never been easier or more efficient. 🎉

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aparser_async-0.0.3.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aparser_async-0.0.3-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file aparser_async-0.0.3.tar.gz.

File metadata

  • Download URL: aparser_async-0.0.3.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for aparser_async-0.0.3.tar.gz
Algorithm Hash digest
SHA256 f8c5afb732bb8f393f20d9d0b2af6bd77f263a06856c084b58449f3a75819aa3
MD5 591a18fe02a4280edee55f64128430c9
BLAKE2b-256 fe13de10da01de82e13093349e87f4153e03f00a0e02be5bcf45690d43cc4f87

See more details on using hashes here.

File details

Details for the file aparser_async-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: aparser_async-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for aparser_async-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 38627c1eb10f1533deea9d461b394b1bc2f94af25986bddd586c7fe9f1637321
MD5 bcb9aed5fcc1fc7df8419c5d7a7e1a5f
BLAKE2b-256 6b51a1a704281cddcf10b2a4bc804bb1eeb4a351bde203c93cdeb646ac67f79e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page