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.2.tar.gz (80.0 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.2-py3-none-any.whl (102.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: marqetive_lib-0.1.2.tar.gz
  • Upload date:
  • Size: 80.0 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.2.tar.gz
Algorithm Hash digest
SHA256 8461c4a7991f92879e7929b64b65534fbbd29205cbe341d1fc0bc4b1b80bd957
MD5 f516f81d0751687005fd912f6a45ef0d
BLAKE2b-256 6f7e9aa01d38b6ad5b2fa485cd6c9b3c42e1f456e3cf195d581257923df56e18

See more details on using hashes here.

File details

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

File metadata

  • Download URL: marqetive_lib-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 102.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e84eccbf49cf84203417eac0ebc7871f58d1fa84d597aa91627c7d72c15d793b
MD5 2fef5da3df157fe93a7061a450cb87cf
BLAKE2b-256 73e8876fb51b91b12e4c569d14fde3fa543a0743045b9f5848b21a0ee796ecac

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