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.2.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.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aparser_async-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 13f382637832a493a126a4f5d74f5210972f00b5aa74a8933d61a81e2ebde3d1
MD5 55e4769c3758152e100673c058c6f0c6
BLAKE2b-256 c3075064ba34d241dbfe4aa9b4334829ac12d9701b9ed034141c4031be9c71f8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aparser_async-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 971b6b4f2053a4dd871230bad372a7b664218f8302c8318dad37edb35e06a0b3
MD5 01d06e6fc77839a3be2c5973c77b6538
BLAKE2b-256 09a26d1cf21dc239f38f38bea4f9e1131d5e8795612ed645448f95894b5f535b

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