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

Uploaded Python 3

File details

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

File metadata

  • Download URL: various_api_tools-0.3.0.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.0.tar.gz
Algorithm Hash digest
SHA256 aba221e0a64ff146df84173520dcf990307f1f573105dca457c931a377307501
MD5 3c5e4fada1d4fd11086c38dd2063050e
BLAKE2b-256 d27af7bed196dfc0005156a0a4355cff0887ccdf54868595dbeeb71679a2f84f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: various_api_tools-0.3.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b64a6c2d077739b57d6829a566dee3881a20f1206521a5feec48e10823260ee
MD5 93584f1375cc2119ea67bf75a55eaf13
BLAKE2b-256 b6731788adb9d5e260ed706c77fb725498c231a51d9053acee34d43d52da0428

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