Metadata-Version: 2.4
Name: ya-market-api
Version: 1.0.2
Summary: Yandex.Market seller API client
Author-email: Kirill_Lekhov <kirill.lekhov@mail.ru>
License: MIT License
        
        Copyright (c) 2025 Kirill_Lekhov
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.8.1
Requires-Dist: arrow>=1.3.0
Requires-Dist: pydantic>=2.10.6
Provides-Extra: all
Requires-Dist: aiohttp>=3.10.11; extra == 'all'
Requires-Dist: requests>=2.32.4; extra == 'all'
Provides-Extra: async
Requires-Dist: aiohttp>=3.10.11; extra == 'async'
Provides-Extra: sync
Requires-Dist: requests>=2.32.4; extra == 'sync'
Description-Content-Type: text/markdown

# ya-market-api [![codecov](https://codecov.io/gh/Kirill-Lekhov/ya-market-api/graph/badge.svg?token=2S6OTYCJF8)](https://codecov.io/gh/Kirill-Lekhov/ya-market-api)
Python3 client for public API of yandex market

## Installation
```shell
# Sync only mode
pip install ya-market-api[sync]
# Async only mode
pip install ya-market-api[async]
# All modes
pip install ya-market-api[all]
```

## Instantiating
There are several ways to work with the API (synchronous and asynchronous). Both interfaces have the same signatures, the only difference is the need to use async/await keywords.

```python
from ya_market_api.sync_api import SyncAPI		# Sync mode
from ya_market_api.async_api import AsyncAPI		# Async mode


def main() -> None:
	api = SyncAPI.build(
		api_key="...",
		business_id=...,		# (optional) required for the Feedback API
		base_url=...,		# (optional) may be used for test circuits
	)

	# Do things here...


async def main() -> None:
	api = await AsyncAPI.build(
		api_key="...",
		business_id=...,		# (optional) required for the Feedback API
		base_url=...,		# (optional) may be used for test circuits
	)

	# Do things here...

	await api.close()
```

## Where can I get api key?
See [official docs](https://yandex.ru/dev/market/partner-api/doc/ru/concepts/api-key).

## Guide API
### Get token info
```python
# Sync mode
from ya_market_api.sync_api import SyncAPI


api = SyncAPI.build(...)
response = api.guide.get_token_info()
```

Docs: https://yandex.ru/dev/market/partner-api/doc/ru/reference/auth/getAuthTokenInfo

### Get delivery services
```python
# Sync mode
from ya_market_api.sync_api import SyncAPI


api = SyncAPI.build(...)
response = api.guide.get_delivery_services()
```

Docs: https://yandex.ru/dev/market/partner-api/doc/ru/reference/orders/getDeliveryServices

## Guide Region API
### Get region countries
```python
# Sync mode
from ya_market_api.sync_api import SyncAPI


api = SyncAPI.build(...)
response = api.guide.region.get_region_countries()
```

Docs: https://yandex.ru/dev/market/partner-api/doc/ru/reference/regions/getRegionsCodes

### Search region
```python
# Sync mode
from ya_market_api.sync_api import SyncAPI
from ya_market_api.guide.region.dataclass import RegionSearchRequest


api = SyncAPI.build(...)
request = RegionSearchRequest(name="Москва", limit=100, page_token=None)
response = api.guide.region.search_region(request)
```

Docs: https://yandex.ru/dev/market/partner-api/doc/ru/reference/regions/searchRegionsByName

### Get region info
```python
# Sync mode
from ya_market_api.sync_api import SyncAPI
from ya_market_api.guide.region.dataclass import RegionInfoRequest


api = SyncAPI.build(...)
request = RegionInfoRequest(region_id=1)
response = api.guide.region.get_region_info(request)
```

Docs: https://yandex.ru/dev/market/partner-api/doc/ru/reference/regions/searchRegionsById

### Get region children
```python
# Sync mode
from ya_market_api.sync_api import SyncAPI
from ya_market_api.guide.region.dataclass import RegionChildrenRequest


api = SyncAPI.build(...)
request = RegionChildrenRequest(region_id=1, page=1, page_size=10)
response = api.guide.region.get_region_children(request)
```

Docs: https://yandex.ru/dev/market/partner-api/doc/ru/reference/regions/searchRegionChildren

## Feedback API
### Get feedback list
```python
# Sync mode
from ya_market_api.sync_api import SyncAPI
from ya_market_api.feedback.dataclass import FeedbackListRequest

from arrow import get


api = SyncAPI.build(...)
response = api.feedback.get_feedback_list()
# or
request = FeedbackListRequest(datetime_from=get(2025, 1, 1), date_to=get(2025, 1, 31))
response = api.feedback.get_feedback_list(request)
```

See signature of the FeedbackListRequest class and the docs to get info about all available params.

Docs: https://yandex.ru/dev/market/partner-api/doc/ru/reference/goods-feedback/getGoodsFeedbacks

### Get feedback comment list
```python
# Sync mode
from ya_market_api.sync_api import SyncAPI
from ya_market_api.feedback.dataclass import FeedbackCommentListRequest


api = SyncAPI.build(...)
request = FeedbackCommentListRequest(feedback_id=512)
response = api.feedback.get_feedback_comment_list(request)
```

See signature of the FeedbackCommentListRequest class and the docs to get info about all available params.

Docs: https://yandex.ru/dev/market/partner-api/doc/ru/reference/goods-feedback/getGoodsFeedbackComments

### Add feedback comment
```python
# Sync mode
from ya_market_api.sync_api import SyncAPI
from ya_market_api.feedback.dataclass import FeedbackCommentAddRequest


api = SyncAPI.build(...)
request = FeedbackCommentAddRequest.create(feedback_id=512, text="COMMENT_TEXT", parent_id=1024)
response = api.feedback.add_feedback_comment(request)
```

Docs: https://yandex.ru/dev/market/partner-api/doc/ru/reference/goods-feedback/updateGoodsFeedbackComment

### Update feedback comment
```python
# Sync mode
from ya_market_api.sync_api import SyncAPI
from ya_market_api.feedback.dataclass import FeedbackCommentUpdateRequest


api = SyncAPI.build(...)
request = FeedbackCommentUpdateRequest.create(feedback_id=512, comment_id=2048, text="COMMENT_TEXT")
response = api.feedback.update_feedback_comment(request)
```

Docs: https://yandex.ru/dev/market/partner-api/doc/ru/reference/goods-feedback/updateGoodsFeedbackComment

### Delete feedback comment
```python
# Sync mode
from ya_market_api.sync_api import SyncAPI
from ya_market_api.feedback.dataclass import FeedbackCommentDeleteRequest


api = SyncAPI.build(...)
request = FeedbackCommentDeleteRequest(id=512)
response = api.feedback.delete_comment_feedback(request)
```

Docs: https://yandex.ru/dev/market/partner-api/doc/ru/reference/goods-feedback/deleteGoodsFeedbackComment

### Skip feedback reaction
```python
# Sync mode
from ya_market_api.sync_api import SyncAPI
from ya_market_api.feedback.dataclass import FeedbackReactionSkipRequest


api = SyncAPI.build(...)
request = FeedbackReactionSkipRequest(feedback_ids=(64, 128, 256))
response = api.feedback.skip_feedback_reaction(request)
```

Docs: https://yandex.ru/dev/market/partner-api/doc/ru/reference/goods-feedback/skipGoodsFeedbacksReaction
