socialapi 0.1.0__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 (66) hide show
  1. socialapi-0.1.0/.github/workflows/ci.yml +38 -0
  2. socialapi-0.1.0/.github/workflows/publish.yml +30 -0
  3. socialapi-0.1.0/.gitignore +48 -0
  4. socialapi-0.1.0/CHANGELOG.md +17 -0
  5. socialapi-0.1.0/CONTRIBUTING.md +91 -0
  6. socialapi-0.1.0/LICENSE +21 -0
  7. socialapi-0.1.0/PKG-INFO +269 -0
  8. socialapi-0.1.0/README.md +236 -0
  9. socialapi-0.1.0/pyproject.toml +82 -0
  10. socialapi-0.1.0/src/socialapi/__init__.py +35 -0
  11. socialapi-0.1.0/src/socialapi/_async_client.py +117 -0
  12. socialapi-0.1.0/src/socialapi/_base_client.py +688 -0
  13. socialapi-0.1.0/src/socialapi/_client.py +117 -0
  14. socialapi-0.1.0/src/socialapi/_config.py +24 -0
  15. socialapi-0.1.0/src/socialapi/_constants.py +8 -0
  16. socialapi-0.1.0/src/socialapi/_exceptions.py +155 -0
  17. socialapi-0.1.0/src/socialapi/_pagination.py +122 -0
  18. socialapi-0.1.0/src/socialapi/_retry.py +134 -0
  19. socialapi-0.1.0/src/socialapi/_types.py +14 -0
  20. socialapi-0.1.0/src/socialapi/_version.py +1 -0
  21. socialapi-0.1.0/src/socialapi/models/__init__.py +94 -0
  22. socialapi-0.1.0/src/socialapi/models/accounts.py +53 -0
  23. socialapi-0.1.0/src/socialapi/models/interactions.py +61 -0
  24. socialapi-0.1.0/src/socialapi/models/keys.py +32 -0
  25. socialapi-0.1.0/src/socialapi/models/media.py +47 -0
  26. socialapi-0.1.0/src/socialapi/models/posts.py +63 -0
  27. socialapi-0.1.0/src/socialapi/models/shared.py +35 -0
  28. socialapi-0.1.0/src/socialapi/models/usage.py +18 -0
  29. socialapi-0.1.0/src/socialapi/models/users.py +16 -0
  30. socialapi-0.1.0/src/socialapi/models/webhooks.py +32 -0
  31. socialapi-0.1.0/src/socialapi/py.typed +0 -0
  32. socialapi-0.1.0/src/socialapi/resources/__init__.py +47 -0
  33. socialapi-0.1.0/src/socialapi/resources/accounts.py +208 -0
  34. socialapi-0.1.0/src/socialapi/resources/comments.py +264 -0
  35. socialapi-0.1.0/src/socialapi/resources/dms.py +181 -0
  36. socialapi-0.1.0/src/socialapi/resources/feedback.py +67 -0
  37. socialapi-0.1.0/src/socialapi/resources/interactions.py +91 -0
  38. socialapi-0.1.0/src/socialapi/resources/keys.py +110 -0
  39. socialapi-0.1.0/src/socialapi/resources/media.py +204 -0
  40. socialapi-0.1.0/src/socialapi/resources/mentions.py +99 -0
  41. socialapi-0.1.0/src/socialapi/resources/oauth.py +73 -0
  42. socialapi-0.1.0/src/socialapi/resources/posts.py +294 -0
  43. socialapi-0.1.0/src/socialapi/resources/reviews.py +99 -0
  44. socialapi-0.1.0/src/socialapi/resources/usage.py +53 -0
  45. socialapi-0.1.0/src/socialapi/resources/users.py +104 -0
  46. socialapi-0.1.0/src/socialapi/resources/webhooks.py +184 -0
  47. socialapi-0.1.0/src/socialapi/webhooks.py +49 -0
  48. socialapi-0.1.0/tests/__init__.py +0 -0
  49. socialapi-0.1.0/tests/conftest.py +22 -0
  50. socialapi-0.1.0/tests/test_accounts.py +122 -0
  51. socialapi-0.1.0/tests/test_client.py +87 -0
  52. socialapi-0.1.0/tests/test_comments.py +86 -0
  53. socialapi-0.1.0/tests/test_dms.py +112 -0
  54. socialapi-0.1.0/tests/test_exceptions.py +123 -0
  55. socialapi-0.1.0/tests/test_interactions.py +47 -0
  56. socialapi-0.1.0/tests/test_keys.py +108 -0
  57. socialapi-0.1.0/tests/test_media.py +127 -0
  58. socialapi-0.1.0/tests/test_mentions.py +66 -0
  59. socialapi-0.1.0/tests/test_pagination.py +115 -0
  60. socialapi-0.1.0/tests/test_posts.py +91 -0
  61. socialapi-0.1.0/tests/test_retry.py +92 -0
  62. socialapi-0.1.0/tests/test_reviews.py +66 -0
  63. socialapi-0.1.0/tests/test_usage.py +58 -0
  64. socialapi-0.1.0/tests/test_users.py +99 -0
  65. socialapi-0.1.0/tests/test_webhooks.py +139 -0
  66. socialapi-0.1.0/tests/test_webhooks_verify.py +35 -0
@@ -0,0 +1,38 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ lint-type-test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Set up Python ${{ matrix.python-version }}
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - name: Install dependencies
26
+ run: pip install -e ".[dev]"
27
+
28
+ - name: Lint
29
+ run: ruff check .
30
+
31
+ - name: Format check
32
+ run: ruff format . --check
33
+
34
+ - name: Type check
35
+ run: pyright
36
+
37
+ - name: Test
38
+ run: pytest --cov=socialapi --cov-report=xml
@@ -0,0 +1,30 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ id-token: write
10
+
11
+ jobs:
12
+ publish:
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.12"
22
+
23
+ - name: Install build tools
24
+ run: pip install build
25
+
26
+ - name: Build package
27
+ run: python -m build
28
+
29
+ - name: Publish to PyPI
30
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,48 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ build/
8
+ dist/
9
+ *.egg-info/
10
+ *.egg
11
+
12
+ # Virtual environments
13
+ .venv/
14
+ venv/
15
+ env/
16
+
17
+ # IDE
18
+ .idea/
19
+ .vscode/
20
+ *.swp
21
+ *.swo
22
+
23
+ # Testing
24
+ .pytest_cache/
25
+ htmlcov/
26
+ .coverage
27
+ coverage.xml
28
+
29
+ # Type checking
30
+ .pyright/
31
+ .mypy_cache/
32
+
33
+ # OS
34
+ .DS_Store
35
+ Thumbs.db
36
+
37
+ # Ruff
38
+ .ruff_cache/
39
+
40
+ # Block all markdown files by default
41
+ *.md
42
+
43
+ # Allowlist specific markdown files
44
+ !README.md
45
+ !LICENSE.md
46
+ !CONTRIBUTING.md
47
+ !CHANGELOG.md
48
+ !CODE_OF_CONDUCT.md
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ - Initial project structure and SDK skeleton.
13
+ - Exception hierarchy mapped to SocialAPI error codes.
14
+ - Sync (`SocialAPI`) and async (`AsyncSocialAPI`) client stubs.
15
+ - Resource namespace stubs for all API endpoints.
16
+ - Pydantic model stubs for all response types.
17
+ - CI/CD workflows for linting, testing, type checking, and PyPI publishing.
@@ -0,0 +1,91 @@
1
+ # Contributing to socialapi-python
2
+
3
+ Thank you for considering contributing to the SocialAPI Python SDK.
4
+
5
+ ## Development Setup
6
+
7
+ 1. Clone the repository:
8
+
9
+ ```bash
10
+ git clone https://github.com/social-api-ai/socialapi-python.git
11
+ cd socialapi-python
12
+ ```
13
+
14
+ 2. Create a virtual environment and install dependencies:
15
+
16
+ ```bash
17
+ python -m venv .venv
18
+ source .venv/bin/activate # or .venv\Scripts\activate on Windows
19
+ pip install -e ".[dev]"
20
+ ```
21
+
22
+ ## Running Tests
23
+
24
+ ```bash
25
+ # All tests
26
+ pytest
27
+
28
+ # Single file
29
+ pytest tests/test_accounts.py
30
+
31
+ # Single test
32
+ pytest tests/test_accounts.py -k "test_list"
33
+
34
+ # With coverage
35
+ pytest --cov=socialapi
36
+ ```
37
+
38
+ ## Linting and Formatting
39
+
40
+ ```bash
41
+ # Lint
42
+ ruff check .
43
+
44
+ # Auto-fix lint issues
45
+ ruff check . --fix
46
+
47
+ # Format
48
+ ruff format .
49
+
50
+ # Format check (CI mode)
51
+ ruff format . --check
52
+ ```
53
+
54
+ ## Type Checking
55
+
56
+ ```bash
57
+ pyright
58
+ ```
59
+
60
+ ## Pre-Commit Checklist
61
+
62
+ Run all quality checks before committing:
63
+
64
+ ```bash
65
+ ruff check . && ruff format . --check && pyright && pytest
66
+ ```
67
+
68
+ All four must pass before a pull request can be merged.
69
+
70
+ ## Pull Request Guidelines
71
+
72
+ 1. **Branch from `main`** and open your PR against `main`.
73
+ 2. **Keep changes focused** -- one feature or fix per PR.
74
+ 3. **Add tests** for any new functionality.
75
+ 4. **Update docstrings** using Google-style format.
76
+ 5. **Add type annotations** to all public functions and methods.
77
+ 6. **Ensure all checks pass** (lint, format, type check, tests).
78
+ 7. **Update CHANGELOG.md** with a summary of your changes under the `[Unreleased]` section.
79
+
80
+ ## Code Style
81
+
82
+ - Follow PEP 8 naming conventions.
83
+ - Use `X | None` union syntax (PEP 604), not `Optional[X]`.
84
+ - Use built-in generics (`list[T]`, `dict[K, V]`), not `typing.List` / `typing.Dict`.
85
+ - Prefix private modules with `_`.
86
+ - Use keyword-only arguments (after `*`) for all optional parameters.
87
+ - Write Google-style docstrings with `Args`, `Returns`, and `Raises` sections.
88
+
89
+ ## Questions?
90
+
91
+ Open an issue or reach out at contact@social-api.ai.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SocialAPI.ai
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,269 @@
1
+ Metadata-Version: 2.4
2
+ Name: socialapi
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for SocialAPI -- unified social media inbox API
5
+ Project-URL: Homepage, https://social-api.ai
6
+ Project-URL: Documentation, https://docs.social-api.ai
7
+ Project-URL: Repository, https://github.com/social-api-ai/socialapi-python
8
+ Project-URL: Changelog, https://github.com/social-api-ai/socialapi-python/blob/main/CHANGELOG.md
9
+ Author-email: SocialAPI <contact@social-api.ai>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: httpx>=0.27.0
23
+ Requires-Dist: pydantic>=2.0.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: build>=1.0; extra == 'dev'
26
+ Requires-Dist: pyright>=1.1; extra == 'dev'
27
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
28
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
29
+ Requires-Dist: pytest-httpx>=0.30; extra == 'dev'
30
+ Requires-Dist: pytest>=8.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.8; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # SocialAPI Python SDK
35
+
36
+ [![PyPI version](https://img.shields.io/pypi/v/socialapi.svg)](https://pypi.org/project/socialapi/)
37
+ [![Python versions](https://img.shields.io/pypi/pyversions/socialapi.svg)](https://pypi.org/project/socialapi/)
38
+ [![CI](https://github.com/social-api-ai/socialapi-python/actions/workflows/ci.yml/badge.svg)](https://github.com/social-api-ai/socialapi-python/actions/workflows/ci.yml)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
40
+
41
+ The official Python SDK for [SocialAPI](https://social-api.ai) -- a unified social media inbox API that reads and responds to comments, DMs, reviews, and mentions across Instagram, Facebook, Google Reviews, TikTok, YouTube, X/Twitter, Trustpilot, and LinkedIn through a single REST API.
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install socialapi
47
+ ```
48
+
49
+ Requires Python 3.10 or later.
50
+
51
+ ## Quick Start
52
+
53
+ ### Synchronous
54
+
55
+ ```python
56
+ from socialapi import SocialAPI
57
+
58
+ client = SocialAPI(api_key="sapi_key_...")
59
+
60
+ # List connected accounts
61
+ accounts = client.accounts.list()
62
+ for account in accounts.data:
63
+ print(f"{account.platform}: {account.name}")
64
+
65
+ # List comments on a post
66
+ comments = client.comments.list("acc_123", "post_456")
67
+ for comment in comments.data:
68
+ print(comment.content.text)
69
+
70
+ # Reply to a comment
71
+ reply = client.interactions.reply("acc_123", "sapi_cmt_abc", text="Thanks!")
72
+ ```
73
+
74
+ ### Asynchronous
75
+
76
+ ```python
77
+ import asyncio
78
+ from socialapi import AsyncSocialAPI
79
+
80
+ async def main():
81
+ async with AsyncSocialAPI(api_key="sapi_key_...") as client:
82
+ accounts = await client.accounts.list()
83
+ for account in accounts.data:
84
+ print(f"{account.platform}: {account.name}")
85
+
86
+ asyncio.run(main())
87
+ ```
88
+
89
+ ## Authentication
90
+
91
+ Pass your API key directly or set the `SOCIALAPI_API_KEY` environment variable:
92
+
93
+ ```python
94
+ # Explicit
95
+ client = SocialAPI(api_key="sapi_key_...")
96
+
97
+ # From environment variable
98
+ import os
99
+ os.environ["SOCIALAPI_API_KEY"] = "sapi_key_..."
100
+ client = SocialAPI()
101
+ ```
102
+
103
+ API keys are created in the [SocialAPI dashboard](https://app.social-api.ai/keys) or via the API. The full key is shown once at creation -- store it securely.
104
+
105
+ ## Usage Examples
106
+
107
+ ### Managing Accounts
108
+
109
+ ```python
110
+ # Connect a new account via OAuth
111
+ result = client.accounts.connect("instagram", metadata={"redirect_uri": "https://..."})
112
+
113
+ # Disconnect an account
114
+ client.accounts.disconnect("acc_123")
115
+ ```
116
+
117
+ ### Publishing Posts
118
+
119
+ ```python
120
+ # Create a post across multiple accounts
121
+ post = client.posts.create(
122
+ account_ids=["acc_123", "acc_456"],
123
+ text="Hello from SocialAPI!",
124
+ )
125
+
126
+ # Schedule a post
127
+ post = client.posts.create(
128
+ account_ids=["acc_123"],
129
+ text="Scheduled post",
130
+ scheduled_at="2026-04-01T12:00:00Z",
131
+ )
132
+ ```
133
+
134
+ ### Direct Messages
135
+
136
+ ```python
137
+ # List DM threads
138
+ dms = client.dms.list("acc_123")
139
+
140
+ # Send a DM
141
+ client.dms.send("acc_123", thread_id="thread_789", text="Hello!")
142
+ ```
143
+
144
+ ### Media Upload
145
+
146
+ ```python
147
+ # Upload media for use in posts
148
+ upload_info = client.media.upload_url(media_type="image", filename="photo.jpg")
149
+ # Upload to the presigned URL, then verify:
150
+ client.media.verify(media_id=upload_info.id)
151
+ ```
152
+
153
+ ## Error Handling
154
+
155
+ The SDK raises typed exceptions for all API errors:
156
+
157
+ ```python
158
+ from socialapi import (
159
+ SocialAPIError,
160
+ AuthenticationError,
161
+ NotFoundError,
162
+ RateLimitError,
163
+ PlanLimitError,
164
+ PlatformRateLimitError,
165
+ ValidationError,
166
+ NotSupportedError,
167
+ )
168
+
169
+ try:
170
+ client.comments.list("acc_123", "post_456")
171
+ except NotFoundError as e:
172
+ print(f"Not found: {e.message} (code: {e.code})")
173
+ except PlanLimitError:
174
+ print("Monthly limit exceeded -- upgrade your plan")
175
+ except PlatformRateLimitError:
176
+ print("Platform rate limit hit -- will auto-retry")
177
+ except AuthenticationError:
178
+ print("Invalid API key")
179
+ except SocialAPIError as e:
180
+ print(f"API error {e.status_code}: {e.message}")
181
+ ```
182
+
183
+ ## Pagination
184
+
185
+ ### Single Page
186
+
187
+ ```python
188
+ response = client.comments.list("acc_123", "post_456", limit=10)
189
+ print(response.data) # list of comments
190
+ print(response.count) # total count
191
+ ```
192
+
193
+ ### Auto-Pagination
194
+
195
+ ```python
196
+ # Synchronous -- iterates through all pages automatically
197
+ for comment in client.comments.list_auto("acc_123", "post_456"):
198
+ print(comment.content.text)
199
+
200
+ # Asynchronous
201
+ async for comment in async_client.comments.list_auto("acc_123", "post_456"):
202
+ print(comment.content.text)
203
+ ```
204
+
205
+ ## Configuration
206
+
207
+ ```python
208
+ client = SocialAPI(
209
+ api_key="sapi_key_...",
210
+ base_url="https://api.social-api.ai", # default
211
+ timeout=30.0, # seconds, default
212
+ max_retries=3, # default
213
+ )
214
+ ```
215
+
216
+ ### Context Manager
217
+
218
+ Both clients support context managers for proper resource cleanup:
219
+
220
+ ```python
221
+ with SocialAPI(api_key="sapi_key_...") as client:
222
+ accounts = client.accounts.list()
223
+
224
+ async with AsyncSocialAPI(api_key="sapi_key_...") as client:
225
+ accounts = await client.accounts.list()
226
+ ```
227
+
228
+ ### Custom HTTP Client
229
+
230
+ For advanced use cases, inject your own httpx client:
231
+
232
+ ```python
233
+ import httpx
234
+
235
+ http_client = httpx.Client(verify=False) # custom SSL settings, proxies, etc.
236
+ client = SocialAPI(api_key="sapi_key_...", http_client=http_client)
237
+ ```
238
+
239
+ ## API Reference
240
+
241
+ For full endpoint documentation, visit [docs.social-api.ai](https://docs.social-api.ai).
242
+
243
+ ### Resources
244
+
245
+ | Resource | Description |
246
+ |---|---|
247
+ | `client.accounts` | Manage connected social accounts |
248
+ | `client.posts` | Create, update, delete, and retry posts |
249
+ | `client.comments` | List and moderate comments |
250
+ | `client.interactions` | Reply to comments, reviews, and mentions |
251
+ | `client.dms` | List and send direct messages |
252
+ | `client.reviews` | List reviews |
253
+ | `client.mentions` | List mentions |
254
+ | `client.media` | Upload and manage media files |
255
+ | `client.usage` | Check usage statistics |
256
+ | `client.keys` | Manage API keys |
257
+ | `client.users` | Manage user profile |
258
+ | `client.webhooks` | Configure webhook endpoints |
259
+ | `client.billing` | Manage billing and subscriptions |
260
+ | `client.oauth` | OAuth token exchange |
261
+ | `client.search` | Search across accounts |
262
+
263
+ ## Contributing
264
+
265
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, testing, and PR guidelines.
266
+
267
+ ## License
268
+
269
+ This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.