amocrm-api-wrapper 0.0.20__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. amocrm_api_wrapper-1.0.1/LICENSE +21 -0
  2. amocrm_api_wrapper-1.0.1/PKG-INFO +146 -0
  3. amocrm_api_wrapper-1.0.1/README.md +120 -0
  4. amocrm_api_wrapper-1.0.1/amocrm_api/__init__.py +11 -0
  5. amocrm_api_wrapper-1.0.1/amocrm_api/base.py +56 -0
  6. amocrm_api_wrapper-1.0.1/amocrm_api/entities/__init__.py +53 -0
  7. amocrm_api_wrapper-1.0.1/amocrm_api/entities/base.py +584 -0
  8. amocrm_api_wrapper-1.0.1/amocrm_api/entities/calls.py +44 -0
  9. amocrm_api_wrapper-1.0.1/amocrm_api/entities/catalogs.py +580 -0
  10. amocrm_api_wrapper-1.0.1/amocrm_api/entities/chat_templates.py +239 -0
  11. amocrm_api_wrapper-1.0.1/amocrm_api/entities/chats.py +124 -0
  12. amocrm_api_wrapper-1.0.1/amocrm_api/entities/companies.py +279 -0
  13. amocrm_api_wrapper-1.0.1/amocrm_api/entities/contacts.py +396 -0
  14. amocrm_api_wrapper-1.0.1/amocrm_api/entities/custom_fields.py +807 -0
  15. amocrm_api_wrapper-1.0.1/amocrm_api/entities/customer_statuses.py +185 -0
  16. amocrm_api_wrapper-1.0.1/amocrm_api/entities/customers.py +269 -0
  17. amocrm_api_wrapper-1.0.1/amocrm_api/entities/events.py +300 -0
  18. amocrm_api_wrapper-1.0.1/amocrm_api/entities/leads.py +406 -0
  19. amocrm_api_wrapper-1.0.1/amocrm_api/entities/loss_reasons.py +99 -0
  20. amocrm_api_wrapper-1.0.1/amocrm_api/entities/notes.py +658 -0
  21. amocrm_api_wrapper-1.0.1/amocrm_api/entities/pipelines.py +681 -0
  22. amocrm_api_wrapper-1.0.1/amocrm_api/entities/short_links.py +38 -0
  23. amocrm_api_wrapper-1.0.1/amocrm_api/entities/sources.py +227 -0
  24. amocrm_api_wrapper-1.0.1/amocrm_api/entities/subscriptions.py +73 -0
  25. amocrm_api_wrapper-1.0.1/amocrm_api/entities/tags.py +127 -0
  26. amocrm_api_wrapper-1.0.1/amocrm_api/entities/talks.py +141 -0
  27. amocrm_api_wrapper-1.0.1/amocrm_api/entities/tasks.py +290 -0
  28. amocrm_api_wrapper-1.0.1/amocrm_api/entities/unsorted.py +628 -0
  29. amocrm_api_wrapper-1.0.1/amocrm_api/entities/users.py +437 -0
  30. amocrm_api_wrapper-1.0.1/amocrm_api/entities/webhooks.py +118 -0
  31. amocrm_api_wrapper-1.0.1/amocrm_api/entities/widgets.py +265 -0
  32. amocrm_api_wrapper-1.0.1/amocrm_api/errors.py +37 -0
  33. amocrm_api_wrapper-1.0.1/amocrm_api/legacy_client.py +125 -0
  34. amocrm_api_wrapper-1.0.1/amocrm_api/oauth_client.py +166 -0
  35. amocrm_api_wrapper-1.0.1/amocrm_api/py.typed +0 -0
  36. amocrm_api_wrapper-1.0.1/amocrm_api_wrapper.egg-info/PKG-INFO +146 -0
  37. amocrm_api_wrapper-1.0.1/amocrm_api_wrapper.egg-info/SOURCES.txt +42 -0
  38. amocrm_api_wrapper-1.0.1/amocrm_api_wrapper.egg-info/requires.txt +7 -0
  39. {amocrm-api-wrapper-0.0.20 → amocrm_api_wrapper-1.0.1}/amocrm_api_wrapper.egg-info/top_level.txt +2 -0
  40. amocrm_api_wrapper-1.0.1/pyproject.toml +61 -0
  41. amocrm_api_wrapper-1.0.1/tests/test_base.py +481 -0
  42. amocrm_api_wrapper-1.0.1/tests/test_contracts.py +557 -0
  43. amocrm-api-wrapper-0.0.20/PKG-INFO +0 -1231
  44. amocrm-api-wrapper-0.0.20/README.md +0 -1217
  45. amocrm-api-wrapper-0.0.20/amocrm_api/__init__.py +0 -5
  46. amocrm-api-wrapper-0.0.20/amocrm_api/base.py +0 -4191
  47. amocrm-api-wrapper-0.0.20/amocrm_api/errors.py +0 -9
  48. amocrm-api-wrapper-0.0.20/amocrm_api/legacy_client.py +0 -58
  49. amocrm-api-wrapper-0.0.20/amocrm_api/oauth_client.py +0 -92
  50. amocrm-api-wrapper-0.0.20/amocrm_api_wrapper.egg-info/PKG-INFO +0 -1231
  51. amocrm-api-wrapper-0.0.20/amocrm_api_wrapper.egg-info/SOURCES.txt +0 -12
  52. amocrm-api-wrapper-0.0.20/amocrm_api_wrapper.egg-info/requires.txt +0 -1
  53. amocrm-api-wrapper-0.0.20/setup.py +0 -25
  54. {amocrm-api-wrapper-0.0.20 → amocrm_api_wrapper-1.0.1}/amocrm_api_wrapper.egg-info/dependency_links.txt +0 -0
  55. {amocrm-api-wrapper-0.0.20 → amocrm_api_wrapper-1.0.1}/setup.cfg +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 bzdvdn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: amocrm-api-wrapper
3
+ Version: 1.0.1
4
+ Summary: AmoCRM v4 REST API wrapper with sync and async clients
5
+ Author-email: bzdvdn <bzdv.dn@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/bzdvdn/amocrm-api-wrapper
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: httpx>=0.25
20
+ Provides-Extra: dev
21
+ Requires-Dist: mypy>=1.10; extra == "dev"
22
+ Requires-Dist: ruff>=0.6; extra == "dev"
23
+ Requires-Dist: readme-renderer>=35.0; extra == "dev"
24
+ Requires-Dist: twine>=5.1; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # wrapper for amocrm rest api
28
+
29
+ ## Install
30
+
31
+ Install using `pip`...
32
+
33
+ pip install amocrm-api-wrapper
34
+
35
+ ## Async support
36
+
37
+ Every method has an async twin with the `_async` suffix (e.g. `get_leads_async`).
38
+ Async variants use `httpx.AsyncClient` natively and return awaitables:
39
+
40
+ ```python
41
+ import asyncio
42
+ from amocrm_api import AmoOAuthClient
43
+
44
+ async def main():
45
+ client = AmoOAuthClient('<access_token>', '<refresh_token>', '<crm_url>', '<client_id>', '<client_secret>', '<redirect_uri>')
46
+ leads = await client.get_leads_async()
47
+ print(leads)
48
+ await client.close_async()
49
+
50
+ asyncio.run(main())
51
+ ```
52
+
53
+ For the legacy client the async session is initialized lazily on the first
54
+ async call, no extra setup is required:
55
+
56
+ ```python
57
+ import asyncio
58
+ from amocrm_api import AmoLegacyClient
59
+
60
+ async def main():
61
+ client = AmoLegacyClient('<login>', '<token>', '<crm_url>')
62
+ users = await client.get_users_async()
63
+ print(users)
64
+
65
+ asyncio.run(main())
66
+ ```
67
+
68
+ ## Pagination
69
+
70
+ Methods that return collections across pages (`iter_*`) fetch all pages
71
+ lazily, so you don't have to manage `page`/`limit` manually. Sync variants
72
+ are generators, async variants are async generators:
73
+
74
+ ```python
75
+ # sync
76
+ for lead in client.iter_leads(filters={"name": "x"}):
77
+ print(lead["id"])
78
+
79
+ # async
80
+ async for contact in client.iter_contacts_async():
81
+ print(contact["id"])
82
+ ```
83
+
84
+ Available iterators:
85
+
86
+ | Method | Async twin | Notes |
87
+ | :--- | :--- | :--- |
88
+ | `iter_leads` | `iter_leads_async` | |
89
+ | `iter_contacts` | `iter_contacts_async` | |
90
+ | `iter_companies` | `iter_companies_async` | |
91
+ | `iter_tasks` | `iter_tasks_async` | |
92
+ | `iter_catalog_elements(catalog_id, ...)` | `iter_catalog_elements_async` | |
93
+ | `iter_tags_by_entity_type(entity_type, ...)` | `iter_tags_by_entity_type_async` | |
94
+
95
+ All accept the same filters/order/with-params as the corresponding `get_*`
96
+ methods, but the `page` argument is handled for you.
97
+
98
+ ## Usage
99
+
100
+ ```python
101
+ from amocrm_api import AmoLegacyClient # for login password auth
102
+ from amocrm_api import AmoOAuthClient # for oauth
103
+ from datetime import datetime
104
+
105
+ client = AmoLegacyClient('<login>', '<password>', '<crm_url>')
106
+ client = AmoOAuthClient('<access_token>', '<refresh_token>', '<crm_url>', '<client_id>', '<client_secret>', '<redirect_uri>')
107
+ dt = datetime.datetime.today().strftime("%a, %d %b %Y %H-%m-%d")
108
+ date_time = f"{dt} UTC"
109
+
110
+ # for Legacy client
111
+ headers = {
112
+ "IF-MODIFIED-SINCE": f"{date_time}",
113
+ "Content-Type": "application/json",
114
+ }
115
+
116
+ client.update_session_params(headers)
117
+ ```
118
+
119
+ ## Documentation
120
+
121
+ Per-entity API reference is split into `docs/`. Every method has an async
122
+ twin with the `_async` suffix; each file ends with an async usage example:
123
+
124
+ | Entity | File |
125
+ | :--- | :--- |
126
+ | Account | [docs/account.md](docs/account.md) |
127
+ | Leads | [docs/leads.md](docs/leads.md) |
128
+ | Unsorted leads | [docs/unsorted.md](docs/unsorted.md) |
129
+ | Pipelines | [docs/pipelines.md](docs/pipelines.md) |
130
+ | Contacts | [docs/contacts.md](docs/contacts.md) |
131
+ | Companies | [docs/companies.md](docs/companies.md) |
132
+ | Customers | [docs/customers.md](docs/customers.md) |
133
+ | Catalogs | [docs/catalogs.md](docs/catalogs.md) |
134
+ | Tasks | [docs/tasks.md](docs/tasks.md) |
135
+ | Notes | [docs/notes.md](docs/notes.md) |
136
+ | Events | [docs/events.md](docs/events.md) |
137
+ | Tags | [docs/tags.md](docs/tags.md) |
138
+ | Loss reasons | [docs/loss_reasons.md](docs/loss_reasons.md) |
139
+ | Sources | [docs/sources.md](docs/sources.md) |
140
+ | Chats | [docs/chats.md](docs/chats.md) |
141
+ | Users | [docs/users.md](docs/users.md) |
142
+ | Webhooks | [docs/webhooks.md](docs/webhooks.md) |
143
+ | Widgets | [docs/widgets.md](docs/widgets.md) |
144
+ | Custom fields | [docs/custom_fields.md](docs/custom_fields.md) |
145
+
146
+ See [CHANGELOG.md](CHANGELOG.md) for release history.
@@ -0,0 +1,120 @@
1
+ # wrapper for amocrm rest api
2
+
3
+ ## Install
4
+
5
+ Install using `pip`...
6
+
7
+ pip install amocrm-api-wrapper
8
+
9
+ ## Async support
10
+
11
+ Every method has an async twin with the `_async` suffix (e.g. `get_leads_async`).
12
+ Async variants use `httpx.AsyncClient` natively and return awaitables:
13
+
14
+ ```python
15
+ import asyncio
16
+ from amocrm_api import AmoOAuthClient
17
+
18
+ async def main():
19
+ client = AmoOAuthClient('<access_token>', '<refresh_token>', '<crm_url>', '<client_id>', '<client_secret>', '<redirect_uri>')
20
+ leads = await client.get_leads_async()
21
+ print(leads)
22
+ await client.close_async()
23
+
24
+ asyncio.run(main())
25
+ ```
26
+
27
+ For the legacy client the async session is initialized lazily on the first
28
+ async call, no extra setup is required:
29
+
30
+ ```python
31
+ import asyncio
32
+ from amocrm_api import AmoLegacyClient
33
+
34
+ async def main():
35
+ client = AmoLegacyClient('<login>', '<token>', '<crm_url>')
36
+ users = await client.get_users_async()
37
+ print(users)
38
+
39
+ asyncio.run(main())
40
+ ```
41
+
42
+ ## Pagination
43
+
44
+ Methods that return collections across pages (`iter_*`) fetch all pages
45
+ lazily, so you don't have to manage `page`/`limit` manually. Sync variants
46
+ are generators, async variants are async generators:
47
+
48
+ ```python
49
+ # sync
50
+ for lead in client.iter_leads(filters={"name": "x"}):
51
+ print(lead["id"])
52
+
53
+ # async
54
+ async for contact in client.iter_contacts_async():
55
+ print(contact["id"])
56
+ ```
57
+
58
+ Available iterators:
59
+
60
+ | Method | Async twin | Notes |
61
+ | :--- | :--- | :--- |
62
+ | `iter_leads` | `iter_leads_async` | |
63
+ | `iter_contacts` | `iter_contacts_async` | |
64
+ | `iter_companies` | `iter_companies_async` | |
65
+ | `iter_tasks` | `iter_tasks_async` | |
66
+ | `iter_catalog_elements(catalog_id, ...)` | `iter_catalog_elements_async` | |
67
+ | `iter_tags_by_entity_type(entity_type, ...)` | `iter_tags_by_entity_type_async` | |
68
+
69
+ All accept the same filters/order/with-params as the corresponding `get_*`
70
+ methods, but the `page` argument is handled for you.
71
+
72
+ ## Usage
73
+
74
+ ```python
75
+ from amocrm_api import AmoLegacyClient # for login password auth
76
+ from amocrm_api import AmoOAuthClient # for oauth
77
+ from datetime import datetime
78
+
79
+ client = AmoLegacyClient('<login>', '<password>', '<crm_url>')
80
+ client = AmoOAuthClient('<access_token>', '<refresh_token>', '<crm_url>', '<client_id>', '<client_secret>', '<redirect_uri>')
81
+ dt = datetime.datetime.today().strftime("%a, %d %b %Y %H-%m-%d")
82
+ date_time = f"{dt} UTC"
83
+
84
+ # for Legacy client
85
+ headers = {
86
+ "IF-MODIFIED-SINCE": f"{date_time}",
87
+ "Content-Type": "application/json",
88
+ }
89
+
90
+ client.update_session_params(headers)
91
+ ```
92
+
93
+ ## Documentation
94
+
95
+ Per-entity API reference is split into `docs/`. Every method has an async
96
+ twin with the `_async` suffix; each file ends with an async usage example:
97
+
98
+ | Entity | File |
99
+ | :--- | :--- |
100
+ | Account | [docs/account.md](docs/account.md) |
101
+ | Leads | [docs/leads.md](docs/leads.md) |
102
+ | Unsorted leads | [docs/unsorted.md](docs/unsorted.md) |
103
+ | Pipelines | [docs/pipelines.md](docs/pipelines.md) |
104
+ | Contacts | [docs/contacts.md](docs/contacts.md) |
105
+ | Companies | [docs/companies.md](docs/companies.md) |
106
+ | Customers | [docs/customers.md](docs/customers.md) |
107
+ | Catalogs | [docs/catalogs.md](docs/catalogs.md) |
108
+ | Tasks | [docs/tasks.md](docs/tasks.md) |
109
+ | Notes | [docs/notes.md](docs/notes.md) |
110
+ | Events | [docs/events.md](docs/events.md) |
111
+ | Tags | [docs/tags.md](docs/tags.md) |
112
+ | Loss reasons | [docs/loss_reasons.md](docs/loss_reasons.md) |
113
+ | Sources | [docs/sources.md](docs/sources.md) |
114
+ | Chats | [docs/chats.md](docs/chats.md) |
115
+ | Users | [docs/users.md](docs/users.md) |
116
+ | Webhooks | [docs/webhooks.md](docs/webhooks.md) |
117
+ | Widgets | [docs/widgets.md](docs/widgets.md) |
118
+ | Custom fields | [docs/custom_fields.md](docs/custom_fields.md) |
119
+
120
+ See [CHANGELOG.md](CHANGELOG.md) for release history.
@@ -0,0 +1,11 @@
1
+ from .legacy_client import AmoLegacyClient as AmoLegacyClient
2
+ from .oauth_client import AmoOAuthClient as AmoOAuthClient
3
+
4
+ __all__ = [
5
+ "AmoLegacyClient",
6
+ "AmoOAuthClient",
7
+ "__version__",
8
+ ]
9
+
10
+ __version__ = "1.0.1"
11
+ __author__ = "bzdvdn"
@@ -0,0 +1,56 @@
1
+ from .entities import (
2
+ Calls,
3
+ Catalogs,
4
+ Chats,
5
+ ChatTemplates,
6
+ Companies,
7
+ Contacts,
8
+ Customers,
9
+ CustomerStatuses,
10
+ CustomFields,
11
+ Events,
12
+ Leads,
13
+ LossReasons,
14
+ Notes,
15
+ Pipelines,
16
+ ShortLinks,
17
+ Sources,
18
+ Subscriptions,
19
+ Tags,
20
+ Talks,
21
+ Tasks,
22
+ Unsorted,
23
+ Users,
24
+ Webhooks,
25
+ Widgets,
26
+ )
27
+ from .entities.base import mask_token as mask_token # noqa: PLC0414 (re-export)
28
+
29
+
30
+ class BaseClient(
31
+ Leads,
32
+ Unsorted,
33
+ Pipelines,
34
+ Contacts,
35
+ Companies,
36
+ Customers,
37
+ Catalogs,
38
+ CustomFields,
39
+ CustomerStatuses,
40
+ Users,
41
+ Webhooks,
42
+ Widgets,
43
+ Tasks,
44
+ Tags,
45
+ Events,
46
+ Notes,
47
+ LossReasons,
48
+ Sources,
49
+ Talks,
50
+ Subscriptions,
51
+ Calls,
52
+ ChatTemplates,
53
+ ShortLinks,
54
+ Chats,
55
+ ):
56
+ """Aggregates all amocrm entities into a single client interface."""
@@ -0,0 +1,53 @@
1
+ from .base import Entity
2
+ from .calls import Calls
3
+ from .catalogs import Catalogs
4
+ from .chat_templates import ChatTemplates
5
+ from .chats import Chats
6
+ from .companies import Companies
7
+ from .contacts import Contacts
8
+ from .custom_fields import CustomFields
9
+ from .customer_statuses import CustomerStatuses
10
+ from .customers import Customers
11
+ from .events import Events
12
+ from .leads import Leads
13
+ from .loss_reasons import LossReasons
14
+ from .notes import Notes
15
+ from .pipelines import Pipelines
16
+ from .short_links import ShortLinks
17
+ from .sources import Sources
18
+ from .subscriptions import Subscriptions
19
+ from .tags import Tags
20
+ from .talks import Talks
21
+ from .tasks import Tasks
22
+ from .unsorted import Unsorted
23
+ from .users import Users
24
+ from .webhooks import Webhooks
25
+ from .widgets import Widgets
26
+
27
+ __all__ = [
28
+ "Calls",
29
+ "Catalogs",
30
+ "ChatTemplates",
31
+ "Chats",
32
+ "Companies",
33
+ "Contacts",
34
+ "CustomFields",
35
+ "CustomerStatuses",
36
+ "Customers",
37
+ "Entity",
38
+ "Events",
39
+ "Leads",
40
+ "LossReasons",
41
+ "Notes",
42
+ "Pipelines",
43
+ "ShortLinks",
44
+ "Sources",
45
+ "Subscriptions",
46
+ "Tags",
47
+ "Talks",
48
+ "Tasks",
49
+ "Unsorted",
50
+ "Users",
51
+ "Webhooks",
52
+ "Widgets"
53
+ ]