Skip to main content

A Python client for the tasnif.soliq.uz search API

Project description

Tasnif Soliq UZ Client

A Python client for the tasnif.soliq.uz API, which provides access to the MXIK (National Classifier of Products by Activity) database in Uzbekistan.

Installation

pip install tsuz-search

Requirements

  • Python 3.8+
  • requests
  • pydantic

Usage

Basic Usage

from tasnif_solig_uz import Client

# Initialize the client
client = Client()

# Search for MXIK codes
results = client.search_mxik("Kompyuter")

# Print the results
for item in results.data:
    print(f"MXIK Code: {item.mxikCode}")
    print(f"Name (UZ): {item.groupNameUz}")
    print(f"Name (RU): {item.groupNameRu}")
    print("---")

Advanced Search

from tasnif_solig_uz import Client, ElasticSearch, SearchParams

# Initialize the client
client = Client()

# Search using ElasticSearch
search_params = ElasticSearch(
    search="телефон",
    size=50,
    page=0,
    lang="ru"
)
results = client.search(search_params)

# Search using parameters
params = SearchParams(
    params={"mxikCode": "12345"},
    size=20,
    page=0,
    lang="uz"
)
results_by_params = client.search_by_params(params)

Custom Base URL

from tasnif_solig_uz import Client

# Initialize the client with a custom base URL
client = Client(base_url="https://custom-tasnif-api.example.com/api")

API Reference

Client

The main client class for interacting with the tasnif.soliq.uz API.

Constructor

Client(base_url: str = "https://tasnif.soliq.uz/api/cls-api")
  • base_url: The base URL for the API. Defaults to the official API endpoint.

Methods

search_mxik
search_mxik(query: str, limit: int = 10) -> MXIKSearchResponse

Search for MXIK codes by a simple text query.

  • query: The search query text.
  • limit: Maximum number of results to return. Defaults to 10.
search
search(params: ElasticSearch) -> List[MxikData]

Search using ElasticSearch parameters.

  • params: An ElasticSearch object containing search parameters.
search_by_params
search_by_params(params: SearchParams) -> List[MxikData]

Search by specific parameters.

  • params: A SearchParams object containing search parameters.
search_dv_cert
search_dv_cert(params: SearchParams) -> List[MxikData]

Search by DV certificate number.

  • params: A SearchParams object containing search parameters.

Models

ElasticSearch

ElasticSearch(
    search: str,
    size: int = 20,
    page: int = 0,
    lang: str = "uz"
)
  • search: The search query text.
  • size: Number of results per page. Defaults to 20.
  • page: Page number (0-based). Defaults to 0.
  • lang: Language code ("uz", "ru", or "en"). Defaults to "uz".

SearchParams

SearchParams(
    params: Dict[str, Any],
    size: int = 20,
    page: int = 0,
    lang: str = "uz"
)
  • params: Dictionary of search parameters.
  • size: Number of results per page. Defaults to 20.
  • page: Page number (0-based). Defaults to 0.
  • lang: Language code ("uz", "ru", or "en"). Defaults to "uz".

MxikData

Represents MXIK data returned by the API.

MxikResponse

Represents a response from the API containing a single MXIK item.

MXIKSearchResponse

Represents a response from the API containing a list of MXIK items.

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/yourusername/tsuz-search.git
cd tsuz-search

# Install development dependencies
pip install -e ".[dev]"

Running Tests

# Run all tests
python -m test.run_tests

# Run with pytest
pytest

License

MIT License

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

tsuz_search-0.1.1.tar.gz (3.7 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: tsuz_search-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for tsuz_search-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cebf393054bd61262a07e277001e51024dafc42aece9b44b71e194bfd87788f2
MD5 cc956e2fdccb1019daf090e3af60d756
BLAKE2b-256 58e178d9a1a97fbec7afe2ccf9b75f903d6935f6168674a46c38205bd8b62188

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