Skip to main content

Modern Python utilities for web APIs

Project description

MarqetiveLib

CI codecov PyPI version Python versions License Documentation

Modern Python utilities for web APIs - Simple, type-safe, and async-ready.

Features

  • 🚀 Fast and Lightweight: Built on httpx with minimal dependencies
  • 🔒 Type-Safe: Full type hints and Pyright compliance for better IDE support
  • 📦 Zero Learning Curve: Intuitive API design that feels natural
  • 🧪 Well Tested: Comprehensive test coverage (>90%)
  • 📚 Excellent Documentation: Clear examples and detailed API reference
  • 🔄 Async/Await Support: Built for modern async Python applications
  • ✨ Developer Friendly: Great error messages and helpful utilities

Installation

pip install marqetive-lib

Or with Poetry:

poetry add marqetive-lib

Quick Start

import asyncio
from marqetive_lib import APIClient

async def main():
    async with APIClient(base_url="https://api.example.com") as client:
        # Make a GET request
        response = await client.get("/users/1")
        print(f"User: {response.data['name']}")

        # Make a POST request
        new_user = {"name": "John Doe", "email": "john@example.com"}
        response = await client.post("/users", data=new_user)
        print(f"Created user ID: {response.data['id']}")

asyncio.run(main())

Core Features

Simple HTTP Client

from marqetive_lib import APIClient

async with APIClient(base_url="https://api.example.com") as client:
    # GET request with query parameters
    response = await client.get("/search", params={"q": "python"})

    # POST request with JSON body
    response = await client.post("/users", data={"name": "Alice"})

    # Access response details
    print(response.status_code)  # 200
    print(response.data)         # Parsed JSON response
    print(response.headers)      # Response headers

Utility Functions

from marqetive_lib.utils import (
    format_response,
    parse_query_params,
    build_query_string,
    merge_headers
)

# Format JSON responses beautifully
data = {"users": [{"id": 1, "name": "Alice"}]}
print(format_response(data, pretty=True, indent=2))

# Parse URL query parameters
params = parse_query_params("https://api.com/search?q=python&page=1")
# {'q': ['python'], 'page': ['1']}

# Build query strings
query = build_query_string({"search": "api", "limit": 10})
# "search=api&limit=10"

# Merge HTTP headers
headers = merge_headers(
    {"Content-Type": "application/json"},
    {"Authorization": "Bearer token"}
)

Type-Safe Responses

from marqetive_lib import APIClient
from pydantic import BaseModel

class User(BaseModel):
    id: int
    name: str
    email: str

async with APIClient(base_url="https://api.example.com") as client:
    response = await client.get("/users/1")
    user = User(**response.data)  # Automatic validation
    print(user.name)

Documentation

Full documentation is available at marqetive-lib.readthedocs.io

Requirements

  • Python 3.9+
  • httpx >= 0.27.0
  • pydantic >= 2.0.0

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/yourusername/marqetive-lib.git
cd marqetive-lib

# Install Poetry if you haven't already
curl -sSL https://install.python-poetry.org | python3 -

# Install dependencies
poetry install --with dev,docs

# Activate virtual environment
poetry shell

Running Tests

# Run tests
poetry run pytest

# Run tests with coverage
poetry run pytest --cov=src/marqetive_lib --cov-report=term-missing

# Run tests for specific Python versions
poetry run tox

Code Quality

# Lint code with Ruff
poetry run ruff check .

# Format code with Ruff
poetry run ruff format .

# Type check with Pyright
poetry run pyright src/

Building Documentation

# Serve documentation locally with live reload
poetry run mkdocs serve

# Build static documentation
poetry run mkdocs build

Contributing

Contributions are welcome! Please read our Contributing Guide for details on:

  • Code of conduct
  • Development workflow
  • Code style guidelines
  • Testing requirements
  • Pull request process

Changelog

See CHANGELOG.md for a list of changes in each release.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support

Links

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

marqetive_lib-0.1.1.tar.gz (70.9 kB view details)

Uploaded Source

Built Distribution

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

marqetive_lib-0.1.1-py3-none-any.whl (90.4 kB view details)

Uploaded Python 3

File details

Details for the file marqetive_lib-0.1.1.tar.gz.

File metadata

  • Download URL: marqetive_lib-0.1.1.tar.gz
  • Upload date:
  • Size: 70.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.9 Darwin/24.6.0

File hashes

Hashes for marqetive_lib-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b191947b96d6e3045d3953f76f41883637ea1a7e6ec0cffa587ae831b02b045b
MD5 58dcc1f3455869b7142266f7be8a8792
BLAKE2b-256 7c15a6e978f4d7a56c3c990975f6b547ad0313673ba581b3fc715f2d9de5e0d9

See more details on using hashes here.

File details

Details for the file marqetive_lib-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: marqetive_lib-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 90.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.9 Darwin/24.6.0

File hashes

Hashes for marqetive_lib-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6213ae599c6bed216adba130bd01f5a1112733577462adc8a7dc366802c0094f
MD5 40a04c75ed8b15028c372c7ea0019451
BLAKE2b-256 c6341e69018405fa5e78f5e2ec19fbcd8b8adf56b4c63534ac2a5da87191f9c1

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