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

This version

0.1.3

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.3.tar.gz (80.6 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.3-py3-none-any.whl (103.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: marqetive_lib-0.1.3.tar.gz
  • Upload date:
  • Size: 80.6 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.3.tar.gz
Algorithm Hash digest
SHA256 e97026ccd19e0a7a7f70543e5a54ae12122a64e6409645044aa6dfd5395612d9
MD5 99c1395821eba2da4668fcf5868fd8a6
BLAKE2b-256 12499fd3b9587e10fbd5b986104db05f364fae64a60305409e6cbc25a02c5f29

See more details on using hashes here.

File details

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

File metadata

  • Download URL: marqetive_lib-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 103.2 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 587e812d32b884100f502e773c171a4a948e3486e1ea7adec5cdedb0174889cd
MD5 bb5529ca046cb98c33abe76ab78f165e
BLAKE2b-256 1acefba6142a2f68e83151a36f04fda9f3b7b5258fb58037ba380ed00f15a61e

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