Skip to main content

A lightweight utility package for common API-related tasks in Python, including JSON and Pydantic error translators that provide user-friendly Russian messages.

Project description

various_api_tools

A lightweight utility package for common API-related tasks in Python, including JSON and Pydantic error translators that provide user-friendly Russian messages.


📦 Features

  • JSON Error Translator – Translates JSONDecodeError into clear Russian messages.
  • Pydantic Validation Error Translator – Converts Pydantic validation errors into human-readable Russian strings.
  • Easy to integrate – Designed for use in web APIs and data validation pipelines.

🐍 Installation

Install using pip from source or a private repository:

pip install various_api_tools

🧪 Basic Usage

Translate JSON Decode Errors

import json
from various_api_tools.translators.json import DecodeErrorTranslator

try:
    json.loads('{"name": "Alice",}')
except json.JSONDecodeError as e:
    print(DecodeErrorTranslator.translate(e))

# Output:
# Ошибка конвертации в формате JSON.
# Позиция: 16.
# Описание: не правильно используются двойные кавычки.

Translate Pydantic Validation Errors

from pydantic import BaseModel, ValidationError
from various_api_tools.translators.pydantic import ValidationErrorTranslator

class User(BaseModel):
    email: str

try:
    User(email=123)
except ValidationError as e:
    print(ValidationErrorTranslator.translate(e.errors()))

# Output:
# Поле: "email". Ошибка: "Невалидное строковое значение(str)";

📄 License

MIT License — feel free to use it in any project! 🎉


🧑‍💻 Made with ❤️ by @dkurchigin

Have questions? Open an issue or contribute to the repo!

🐙 GITVERSE

🔗 https://gitverse.ru/dkurchigin/various-api-tools

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

various_api_tools-0.3.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

various_api_tools-0.3.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file various_api_tools-0.3.1.tar.gz.

File metadata

  • Download URL: various_api_tools-0.3.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.9 CPython/3.13.7 Linux/5.15.0-144-generic

File hashes

Hashes for various_api_tools-0.3.1.tar.gz
Algorithm Hash digest
SHA256 caac43f305a979fe3c0d527f5e54da771fbb3f887ac78d4b2d02df323e4b9885
MD5 ed5db3e5277a7b4153c5b8adbdf42005
BLAKE2b-256 b134e0c0029242cb68732242b60e8c5c317b72e5c08171aa0437fa4df1999500

See more details on using hashes here.

File details

Details for the file various_api_tools-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: various_api_tools-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.9 CPython/3.13.7 Linux/5.15.0-144-generic

File hashes

Hashes for various_api_tools-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b99c26bcf16228b58df1ae18534669defe45f8c06660c91bd536f8cc4ece478
MD5 96cd1b492b3be48f4ae9b4a1c084f442
BLAKE2b-256 34156b48025893a46c031ba87a3e56e2830662444f0abcba5ffd4a058ef85391

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