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.4.tar.gz (8.5 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.4-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aparser_async-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9f55c46337b6f26ec11b9830027854c8589669719f9f0df8829d417d58d3526c
MD5 cf31b1b5218dbba0de7f4656b8da5940
BLAKE2b-256 a70cb64ff441df36b1d15d3b4e2dcaded9bddd06ae2e6d94fe6d2d4c6df7decb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aparser_async-0.0.4-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.2

File hashes

Hashes for aparser_async-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cdab636664689e6a2e5da575bc0cfabd913c3ed8056e1c459b8aa0e21ecac960
MD5 48d504ae389672fa89aa2f1b177215e5
BLAKE2b-256 b73e827455d95ff65aae30988bc8601d8808343ea9742fbd17f9048912717f45

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