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) database in Uzbekistan.
Installation
pip install tsuz-search
Requirements
- Python 3.8+
- requests
- pydantic
Usage
Basic Usage
from tsuz_search 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 tsuz_search 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 tsuz_search 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: AnElasticSearchobject containing search parameters.
search_by_params
search_by_params(params: SearchParams) -> List[MxikData]
Search by specific parameters.
params: ASearchParamsobject containing search parameters.
search_dv_cert
search_dv_cert(params: SearchParams) -> List[MxikData]
Search by DV certificate number.
params: ASearchParamsobject 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/aslon1213/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
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
File details
Details for the file tsuz_search-0.1.2.tar.gz.
File metadata
- Download URL: tsuz_search-0.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bda54844f7634d84af83392e432e98b34a7f4528840d1791ecaa8f967a4f7c1
|
|
| MD5 |
145c5218cc37e9f8623898c55e3cfd21
|
|
| BLAKE2b-256 |
6d3d31d05d32dc9ee2943e7ab003f2b6fb79289fbd48352cfcabe697e8496b95
|