The repository or configuration that created this release differ from a previous release. View details.
This release is a pre-release and may not be stable for production use.
×
Документация: gocream-labs.github.io/pycdek
gocream-pycdek — Python-библиотека для работы с CDEK API v2.0.
Installation
pip install gocream-pycdek
Для установки предварительных версий используйте флаг --pre:
pip install --pre gocream-pycdek
Импорт в Python выполняется через пакет gocream_pycdek:
from gocream_pycdek import CdekClient
client = CdekClient("client-id", "client-secret")
Quick Start
from gocream_pycdek import CdekClient
from gocream_pycdek import ContractType
client = CdekClient("client-id", "client-secret")
regions = client.get_regions()
order = client.registrate_order(
136,
{"name": "Иван Иванов", "phones": [{"number": "+79000000000"}]},
[{"number": "1", "weight": 1000}],
contract_type=ContractType.ONLINE_STORE,
to_location={"code": 270},
)
Тип заказа указывается в каждом заказе, а не в клиенте: ContractType.DELIVERY
доступен любому договору, ContractType.ONLINE_STORE — только договору
с интернет-магазином, поэтому одна учётная запись может отправлять оба типа.
Параметр base_url=TEST_API_URL переключает клиент на тестовый контур СДЭК.
Client Lifecycle
Клиент держит открытую HTTP-сессию и переиспользует соединение между запросами. Поэтому один долгоживущий клиент на приложение выгоднее, чем новый клиент на каждый запрос, — и поэтому же его нужно закрывать.
Для короткоживущего клиента достаточно блока with:
with CdekClient("client-id", "client-secret") as client:
regions = client.get_regions()
Клиент, живущий всё время работы приложения, закрывается явно при завершении:
client = CdekClient("client-id", "client-secret")
try:
regions = client.get_regions()
finally:
client.close()
Если не закрыть, сокеты остаются открытыми, пока на клиента есть хоть одна ссылка.
Сборщик мусора их в итоге освободит, но предупреждения при этом не будет, так что
накопление дескрипторов легко пропустить — особенно если клиенты создаются на каждый
запрос и оседают в кэше или контейнере зависимостей. После close() клиент остаётся
рабочим: следующий запрос откроет соединение заново.
Upgrading to 2.0
При обновлении с ранних beta и RC проверьте вызовы клиента:
- Вместо
CDEKApiClient(id, secret, is_shop, production=...)используйтеCdekClient(client_id, client_secret, base_url=...). Для тестового контура передавайтеTEST_API_URL. - В
registrate_orderиcalculator_tariffпередавайте обязательный именованный аргументcontract_type=ContractType.ONLINE_STOREилиContractType.DELIVERY. Тип больше не задаётся в конструкторе клиента. Все необязательные аргументы этих двух методов теперь также передаются по имени. - В
get_deliverypointsзамените именаpostal_code1,city_code1,tipeнаpostal_code,city_code,type. - При прямом вызове
sendявно указывайте HTTP-метод;data,paramsиraise_errorsпередавайте по имени. Вget_orderпараметрыraise_errorsиorigin_responseтакже передавайте по имени. - Закрывайте клиент через
close()или используйтеwith, как в примерах выше. Таймаут по умолчанию составляет 3 секунды на соединение и 7 секунд на чтение; переопределить его можно черезtimeout.
Актуальные методы API v2 сохраняют явно переданные пустые строки и вложенные структуры; автоматическая очистка таких значений больше не выполняется. Ограничения обработки ошибок и устаревшие параметры перечислены в известных проблемах.
Project Status
Стабильная ветка 2.x поддерживает Python 3.10 и новее. Устаревшие методы и параметры, планируемые к удалению в 3.0.0, описаны в справочнике API и разделе известных проблем.
Additional Resources
Metadata
Release files for gocream-pycdek 2.0.1rc1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Change of provenance
The repository or configuration that created these release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gocream_pycdek-2.0.1rc1.tar.gz | 99.1 kB | With provenance | Details for gocream_pycdek-2.0.1rc1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gocream_pycdek-2.0.1rc1-py3-none-any.whl | Python 3 | none | any | Details for gocream_pycdek-2.0.1rc1-py3-none-any.whl |
Total release size: 141.0 kB
Release files / gocream_pycdek-2.0.1rc1.tar.gz
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | gocream_pycdek-2.0.1rc1.tar.gz |
|---|---|
| Size | 99.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5c9d2b3651d12240b4b2ccc2bba3b67f6f96c4f11ec41f151db6ca0389ba7f4
|
|
BLAKE2b-256 checksum How to use checksums |
e7404fc453da73c9567b60f981554fc3cd4faf3cf71db48d0ed37ad6c608b93e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logRelease files / gocream_pycdek-2.0.1rc1-py3-none-any.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | gocream_pycdek-2.0.1rc1-py3-none-any.whl |
|---|---|
| Size | 41.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e2e915d76ef903a78cdf73d29485c9e609f101b151e38f28ac67a54270ff895
|
|
BLAKE2b-256 checksum How to use checksums |
ddd2a045ec50199849776e46c7618aedcb4d91e33a3ea7663477734c54b0a4b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logSecurity for gocream-pycdek 2.0.1rc1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Change of provenance
The configuration that created this release differs from a previous release.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Attestation for gocream_pycdek-2.0.1rc1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.