apiverve-complimentgenerator 1.2.2__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.
- apiverve_complimentgenerator-1.2.2/LICENSE +21 -0
- apiverve_complimentgenerator-1.2.2/PKG-INFO +280 -0
- apiverve_complimentgenerator-1.2.2/README.md +256 -0
- apiverve_complimentgenerator-1.2.2/pyproject.toml +29 -0
- apiverve_complimentgenerator-1.2.2/setup.cfg +4 -0
- apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator/__init__.py +3 -0
- apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator/apiClient.py +250 -0
- apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator/exceptions.py +3 -0
- apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator/setup.py +26 -0
- apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator/setup_dep.py +21 -0
- apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator/tests/__init__.py +1 -0
- apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator/tests/test_api.py +19 -0
- apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator.egg-info/PKG-INFO +280 -0
- apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator.egg-info/SOURCES.txt +16 -0
- apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator.egg-info/dependency_links.txt +1 -0
- apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator.egg-info/requires.txt +1 -0
- apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator.egg-info/top_level.txt +1 -0
- apiverve_complimentgenerator-1.2.2/tests/test_api.py +27 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 APIVerve and EvlarSoft LLC
|
|
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,280 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apiverve-complimentgenerator
|
|
3
|
+
Version: 1.2.2
|
|
4
|
+
Summary: Compliment Generator creates unique, heartfelt compliments using template-based generation with extensive word banks. Perfect for apps, chatbots, or spreading positivity.
|
|
5
|
+
Author-email: APIVerve <hello@apiverve.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://apiverve.com/marketplace/compliments?utm_source=pypi&utm_medium=referral&utm_content=homepage
|
|
8
|
+
Project-URL: Documentation, https://docs.apiverve.com/ref/compliments?utm_source=pypi&utm_medium=referral&utm_content=docs
|
|
9
|
+
Project-URL: Repository, https://github.com/apiverve/compliments-api
|
|
10
|
+
Project-URL: Twitter, https://twitter.com/apivervehq
|
|
11
|
+
Keywords: compliment,compliments,generator,positive,encouragement
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Classifier: Natural Language :: English
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: requests>=2.25.0
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
Compliment Generator API
|
|
26
|
+
============
|
|
27
|
+
|
|
28
|
+
Compliment Generator creates unique, heartfelt compliments using template-based generation with extensive word banks. Perfect for apps, chatbots, or spreading positivity.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/apiverve-complimentgenerator/)
|
|
32
|
+
|
|
33
|
+
This is a Python wrapper for the [Compliment Generator API](https://apiverve.com/marketplace/compliments?utm_source=pypi&utm_medium=referral&utm_content=readme)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
Using `pip`:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install apiverve-complimentgenerator
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Using `pip3`:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip3 install apiverve-complimentgenerator
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
Before using the Compliment Generator API client, you have to setup your account and obtain your API Key.
|
|
56
|
+
You can get it by signing up at [https://apiverve.com](https://apiverve.com?utm_source=pypi&utm_medium=referral&utm_content=readme)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
Here's a simple example to get you started quickly:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
66
|
+
|
|
67
|
+
# Initialize the client with your APIVerve API key
|
|
68
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
69
|
+
|
|
70
|
+
query = { "adult": }
|
|
71
|
+
|
|
72
|
+
try:
|
|
73
|
+
# Make the API call
|
|
74
|
+
result = api.execute(query)
|
|
75
|
+
|
|
76
|
+
# Print the result
|
|
77
|
+
print(result)
|
|
78
|
+
except Exception as e:
|
|
79
|
+
print(f"Error: {e}")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
The Compliment Generator API documentation is found here: [https://docs.apiverve.com/ref/compliments](https://docs.apiverve.com/ref/compliments?utm_source=pypi&utm_medium=referral&utm_content=readme).
|
|
87
|
+
You can find parameters, example responses, and status codes documented here.
|
|
88
|
+
|
|
89
|
+
### Setup
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
# Import the client module
|
|
93
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
94
|
+
|
|
95
|
+
# Initialize the client with your APIVerve API key
|
|
96
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Perform Request
|
|
102
|
+
|
|
103
|
+
Using the API client, you can perform requests to the API.
|
|
104
|
+
|
|
105
|
+
###### Define Query
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
query = { "adult": }
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
###### Simple Request
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
# Make a request to the API
|
|
115
|
+
result = api.execute(query)
|
|
116
|
+
|
|
117
|
+
# Print the result
|
|
118
|
+
print(result)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
###### Example Response
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"status": "ok",
|
|
126
|
+
"error": null,
|
|
127
|
+
"data": {
|
|
128
|
+
"compliment": "Your graceful professionalism is an asset to everyone."
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Error Handling
|
|
136
|
+
|
|
137
|
+
The API client provides comprehensive error handling through the `ComplimentsAPIClientError` exception. Here are some examples:
|
|
138
|
+
|
|
139
|
+
### Basic Error Handling
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient, ComplimentsAPIClientError
|
|
143
|
+
|
|
144
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
145
|
+
|
|
146
|
+
query = { "adult": }
|
|
147
|
+
|
|
148
|
+
try:
|
|
149
|
+
result = api.execute(query)
|
|
150
|
+
print("Success!")
|
|
151
|
+
print(result)
|
|
152
|
+
except ComplimentsAPIClientError as e:
|
|
153
|
+
print(f"API Error: {e.message}")
|
|
154
|
+
if e.status_code:
|
|
155
|
+
print(f"Status Code: {e.status_code}")
|
|
156
|
+
if e.response:
|
|
157
|
+
print(f"Response: {e.response}")
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Handling Specific Error Types
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient, ComplimentsAPIClientError
|
|
164
|
+
|
|
165
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
166
|
+
|
|
167
|
+
query = { "adult": }
|
|
168
|
+
|
|
169
|
+
try:
|
|
170
|
+
result = api.execute(query)
|
|
171
|
+
|
|
172
|
+
# Check for successful response
|
|
173
|
+
if result.get('status') == 'success':
|
|
174
|
+
print("Request successful!")
|
|
175
|
+
print(result.get('data'))
|
|
176
|
+
else:
|
|
177
|
+
print(f"API returned an error: {result.get('error')}")
|
|
178
|
+
|
|
179
|
+
except ComplimentsAPIClientError as e:
|
|
180
|
+
# Handle API client errors
|
|
181
|
+
if e.status_code == 401:
|
|
182
|
+
print("Unauthorized: Invalid API key")
|
|
183
|
+
elif e.status_code == 429:
|
|
184
|
+
print("Rate limit exceeded")
|
|
185
|
+
elif e.status_code >= 500:
|
|
186
|
+
print("Server error - please try again later")
|
|
187
|
+
else:
|
|
188
|
+
print(f"API error: {e.message}")
|
|
189
|
+
except Exception as e:
|
|
190
|
+
# Handle unexpected errors
|
|
191
|
+
print(f"Unexpected error: {str(e)}")
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Using Context Manager (Recommended)
|
|
195
|
+
|
|
196
|
+
The client supports the context manager protocol for automatic resource cleanup:
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient, ComplimentsAPIClientError
|
|
200
|
+
|
|
201
|
+
query = { "adult": }
|
|
202
|
+
|
|
203
|
+
# Using context manager ensures proper cleanup
|
|
204
|
+
with ComplimentsAPIClient("[YOUR_API_KEY]") as api:
|
|
205
|
+
try:
|
|
206
|
+
result = api.execute(query)
|
|
207
|
+
print(result)
|
|
208
|
+
except ComplimentsAPIClientError as e:
|
|
209
|
+
print(f"Error: {e.message}")
|
|
210
|
+
# Session is automatically closed here
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Advanced Features
|
|
216
|
+
|
|
217
|
+
### Debug Mode
|
|
218
|
+
|
|
219
|
+
Enable debug logging to see detailed request and response information:
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
223
|
+
|
|
224
|
+
# Enable debug mode
|
|
225
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]", debug=True)
|
|
226
|
+
|
|
227
|
+
query = { "adult": }
|
|
228
|
+
|
|
229
|
+
# Debug information will be printed to console
|
|
230
|
+
result = api.execute(query)
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Manual Session Management
|
|
234
|
+
|
|
235
|
+
If you need to manually manage the session lifecycle:
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
239
|
+
|
|
240
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
241
|
+
|
|
242
|
+
query = { "adult": }
|
|
243
|
+
|
|
244
|
+
try:
|
|
245
|
+
result = api.execute(query)
|
|
246
|
+
print(result)
|
|
247
|
+
finally:
|
|
248
|
+
# Manually close the session when done
|
|
249
|
+
api.close()
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Customer Support
|
|
255
|
+
|
|
256
|
+
Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact?utm_source=pypi&utm_medium=referral&utm_content=readme).
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Updates
|
|
261
|
+
Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Legal
|
|
266
|
+
|
|
267
|
+
All usage of the APIVerve website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms?utm_source=pypi&utm_medium=referral&utm_content=readme) and all legal documents and agreements.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
Licensed under the MIT License (MIT)
|
|
273
|
+
|
|
274
|
+
Copyright (©) 2026 APIVerve, and EvlarSoft LLC
|
|
275
|
+
|
|
276
|
+
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:
|
|
277
|
+
|
|
278
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
279
|
+
|
|
280
|
+
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.
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
Compliment Generator API
|
|
2
|
+
============
|
|
3
|
+
|
|
4
|
+
Compliment Generator creates unique, heartfelt compliments using template-based generation with extensive word banks. Perfect for apps, chatbots, or spreading positivity.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
[](https://pypi.org/project/apiverve-complimentgenerator/)
|
|
8
|
+
|
|
9
|
+
This is a Python wrapper for the [Compliment Generator API](https://apiverve.com/marketplace/compliments?utm_source=pypi&utm_medium=referral&utm_content=readme)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Using `pip`:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install apiverve-complimentgenerator
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Using `pip3`:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip3 install apiverve-complimentgenerator
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Configuration
|
|
30
|
+
|
|
31
|
+
Before using the Compliment Generator API client, you have to setup your account and obtain your API Key.
|
|
32
|
+
You can get it by signing up at [https://apiverve.com](https://apiverve.com?utm_source=pypi&utm_medium=referral&utm_content=readme)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
Here's a simple example to get you started quickly:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
42
|
+
|
|
43
|
+
# Initialize the client with your APIVerve API key
|
|
44
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
45
|
+
|
|
46
|
+
query = { "adult": }
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
# Make the API call
|
|
50
|
+
result = api.execute(query)
|
|
51
|
+
|
|
52
|
+
# Print the result
|
|
53
|
+
print(result)
|
|
54
|
+
except Exception as e:
|
|
55
|
+
print(f"Error: {e}")
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
The Compliment Generator API documentation is found here: [https://docs.apiverve.com/ref/compliments](https://docs.apiverve.com/ref/compliments?utm_source=pypi&utm_medium=referral&utm_content=readme).
|
|
63
|
+
You can find parameters, example responses, and status codes documented here.
|
|
64
|
+
|
|
65
|
+
### Setup
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
# Import the client module
|
|
69
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
70
|
+
|
|
71
|
+
# Initialize the client with your APIVerve API key
|
|
72
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Perform Request
|
|
78
|
+
|
|
79
|
+
Using the API client, you can perform requests to the API.
|
|
80
|
+
|
|
81
|
+
###### Define Query
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
query = { "adult": }
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
###### Simple Request
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
# Make a request to the API
|
|
91
|
+
result = api.execute(query)
|
|
92
|
+
|
|
93
|
+
# Print the result
|
|
94
|
+
print(result)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
###### Example Response
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"status": "ok",
|
|
102
|
+
"error": null,
|
|
103
|
+
"data": {
|
|
104
|
+
"compliment": "Your graceful professionalism is an asset to everyone."
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Error Handling
|
|
112
|
+
|
|
113
|
+
The API client provides comprehensive error handling through the `ComplimentsAPIClientError` exception. Here are some examples:
|
|
114
|
+
|
|
115
|
+
### Basic Error Handling
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient, ComplimentsAPIClientError
|
|
119
|
+
|
|
120
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
121
|
+
|
|
122
|
+
query = { "adult": }
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
result = api.execute(query)
|
|
126
|
+
print("Success!")
|
|
127
|
+
print(result)
|
|
128
|
+
except ComplimentsAPIClientError as e:
|
|
129
|
+
print(f"API Error: {e.message}")
|
|
130
|
+
if e.status_code:
|
|
131
|
+
print(f"Status Code: {e.status_code}")
|
|
132
|
+
if e.response:
|
|
133
|
+
print(f"Response: {e.response}")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Handling Specific Error Types
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient, ComplimentsAPIClientError
|
|
140
|
+
|
|
141
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
142
|
+
|
|
143
|
+
query = { "adult": }
|
|
144
|
+
|
|
145
|
+
try:
|
|
146
|
+
result = api.execute(query)
|
|
147
|
+
|
|
148
|
+
# Check for successful response
|
|
149
|
+
if result.get('status') == 'success':
|
|
150
|
+
print("Request successful!")
|
|
151
|
+
print(result.get('data'))
|
|
152
|
+
else:
|
|
153
|
+
print(f"API returned an error: {result.get('error')}")
|
|
154
|
+
|
|
155
|
+
except ComplimentsAPIClientError as e:
|
|
156
|
+
# Handle API client errors
|
|
157
|
+
if e.status_code == 401:
|
|
158
|
+
print("Unauthorized: Invalid API key")
|
|
159
|
+
elif e.status_code == 429:
|
|
160
|
+
print("Rate limit exceeded")
|
|
161
|
+
elif e.status_code >= 500:
|
|
162
|
+
print("Server error - please try again later")
|
|
163
|
+
else:
|
|
164
|
+
print(f"API error: {e.message}")
|
|
165
|
+
except Exception as e:
|
|
166
|
+
# Handle unexpected errors
|
|
167
|
+
print(f"Unexpected error: {str(e)}")
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Using Context Manager (Recommended)
|
|
171
|
+
|
|
172
|
+
The client supports the context manager protocol for automatic resource cleanup:
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient, ComplimentsAPIClientError
|
|
176
|
+
|
|
177
|
+
query = { "adult": }
|
|
178
|
+
|
|
179
|
+
# Using context manager ensures proper cleanup
|
|
180
|
+
with ComplimentsAPIClient("[YOUR_API_KEY]") as api:
|
|
181
|
+
try:
|
|
182
|
+
result = api.execute(query)
|
|
183
|
+
print(result)
|
|
184
|
+
except ComplimentsAPIClientError as e:
|
|
185
|
+
print(f"Error: {e.message}")
|
|
186
|
+
# Session is automatically closed here
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Advanced Features
|
|
192
|
+
|
|
193
|
+
### Debug Mode
|
|
194
|
+
|
|
195
|
+
Enable debug logging to see detailed request and response information:
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
199
|
+
|
|
200
|
+
# Enable debug mode
|
|
201
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]", debug=True)
|
|
202
|
+
|
|
203
|
+
query = { "adult": }
|
|
204
|
+
|
|
205
|
+
# Debug information will be printed to console
|
|
206
|
+
result = api.execute(query)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Manual Session Management
|
|
210
|
+
|
|
211
|
+
If you need to manually manage the session lifecycle:
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
215
|
+
|
|
216
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
217
|
+
|
|
218
|
+
query = { "adult": }
|
|
219
|
+
|
|
220
|
+
try:
|
|
221
|
+
result = api.execute(query)
|
|
222
|
+
print(result)
|
|
223
|
+
finally:
|
|
224
|
+
# Manually close the session when done
|
|
225
|
+
api.close()
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Customer Support
|
|
231
|
+
|
|
232
|
+
Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact?utm_source=pypi&utm_medium=referral&utm_content=readme).
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Updates
|
|
237
|
+
Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Legal
|
|
242
|
+
|
|
243
|
+
All usage of the APIVerve website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms?utm_source=pypi&utm_medium=referral&utm_content=readme) and all legal documents and agreements.
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## License
|
|
248
|
+
Licensed under the MIT License (MIT)
|
|
249
|
+
|
|
250
|
+
Copyright (©) 2026 APIVerve, and EvlarSoft LLC
|
|
251
|
+
|
|
252
|
+
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:
|
|
253
|
+
|
|
254
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
255
|
+
|
|
256
|
+
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.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "apiverve-complimentgenerator"
|
|
3
|
+
version = "1.2.2"
|
|
4
|
+
authors = [
|
|
5
|
+
{ name="APIVerve", email="hello@apiverve.com" },
|
|
6
|
+
]
|
|
7
|
+
description = "Compliment Generator creates unique, heartfelt compliments using template-based generation with extensive word banks. Perfect for apps, chatbots, or spreading positivity."
|
|
8
|
+
keywords = ["compliment", "compliments", "generator", "positive", "encouragement"]
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
dependencies = [
|
|
13
|
+
"requests>=2.25.0"
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 5 - Production/Stable",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
21
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
22
|
+
"Natural Language :: English",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://apiverve.com/marketplace/compliments?utm_source=pypi&utm_medium=referral&utm_content=homepage"
|
|
27
|
+
Documentation = "https://docs.apiverve.com/ref/compliments?utm_source=pypi&utm_medium=referral&utm_content=docs"
|
|
28
|
+
Repository = "https://github.com/apiverve/compliments-api"
|
|
29
|
+
Twitter = "https://twitter.com/apivervehq"
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from typing import Dict, Optional, Any, List
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
import requests
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ComplimentsAPIClientError(Exception):
|
|
8
|
+
"""Custom exception for API client errors"""
|
|
9
|
+
def __init__(self, message: str, status_code: Optional[int] = None, response: Optional[Dict] = None):
|
|
10
|
+
self.message = message
|
|
11
|
+
self.status_code = status_code
|
|
12
|
+
self.response = response
|
|
13
|
+
super().__init__(self.message)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ValidationError(ComplimentsAPIClientError):
|
|
17
|
+
"""Custom exception for parameter validation errors"""
|
|
18
|
+
def __init__(self, errors: List[str]):
|
|
19
|
+
self.errors = errors
|
|
20
|
+
message = f"Validation failed: {' '.join(errors)}"
|
|
21
|
+
super().__init__(message)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ComplimentsAPIClient:
|
|
25
|
+
# Validation rules for parameters (generated from schema)
|
|
26
|
+
VALIDATION_RULES = {
|
|
27
|
+
"adult": {"type": "boolean", "required": False, "default": False}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# Format validation patterns
|
|
31
|
+
FORMAT_PATTERNS = {
|
|
32
|
+
'email': r'^[^\s@]+@[^\s@]+\.[^\s@]+$',
|
|
33
|
+
'url': r'^https?://.+',
|
|
34
|
+
'ip': r'^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$',
|
|
35
|
+
'date': r'^\d{4}-\d{2}-\d{2}$',
|
|
36
|
+
'hexColor': r'^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def __init__(self, api_key: str, secure: bool = True, debug: bool = False):
|
|
40
|
+
"""
|
|
41
|
+
Initialize the ComplimentsAPIClient with the API key and optional settings
|
|
42
|
+
|
|
43
|
+
:param api_key: Your APIVerve API key
|
|
44
|
+
:param secure: Deprecated. Always set to True
|
|
45
|
+
:param debug: Enable debug logging (default: False)
|
|
46
|
+
:raises ComplimentsAPIClientError: If API key is invalid
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
self._validate_api_key(api_key)
|
|
50
|
+
|
|
51
|
+
self.api_key = api_key
|
|
52
|
+
self.secure = secure
|
|
53
|
+
self.debug = debug
|
|
54
|
+
self.base_url = 'https://api.apiverve.com/v1/compliments'
|
|
55
|
+
self.headers = {
|
|
56
|
+
'x-api-key': self.api_key,
|
|
57
|
+
'auth-mode': 'pypi-package'
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# Create a session for connection pooling
|
|
61
|
+
self.session = requests.Session()
|
|
62
|
+
self.session.headers.update(self.headers)
|
|
63
|
+
|
|
64
|
+
def _validate_api_key(self, api_key: str) -> None:
|
|
65
|
+
"""
|
|
66
|
+
Validate the API key format
|
|
67
|
+
|
|
68
|
+
:param api_key: API key to validate
|
|
69
|
+
:raises ComplimentsAPIClientError: If API key is invalid
|
|
70
|
+
"""
|
|
71
|
+
if not api_key or not api_key.strip():
|
|
72
|
+
raise ComplimentsAPIClientError(
|
|
73
|
+
"API key is required. Get your API key at: https://apiverve.com"
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
# Check format (GUID, prefixed keys like apv_xxx, or alphanumeric)
|
|
77
|
+
if not re.match(r'^[a-zA-Z0-9_-]+$', api_key):
|
|
78
|
+
raise ComplimentsAPIClientError(
|
|
79
|
+
"Invalid API key format. API key should only contain letters, numbers, hyphens, and underscores. "
|
|
80
|
+
"Get your API key at: https://apiverve.com"
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
def _log(self, message: str) -> None:
|
|
84
|
+
"""
|
|
85
|
+
Log a debug message if debug mode is enabled
|
|
86
|
+
|
|
87
|
+
:param message: Message to log
|
|
88
|
+
"""
|
|
89
|
+
if self.debug:
|
|
90
|
+
print(f"[ComplimentsAPIClient DEBUG] {message}")
|
|
91
|
+
|
|
92
|
+
def _validate_params(self, params: Optional[Dict[str, Any]]) -> None:
|
|
93
|
+
"""
|
|
94
|
+
Validate parameters against schema rules
|
|
95
|
+
|
|
96
|
+
:param params: Parameters to validate
|
|
97
|
+
:raises ValidationError: If validation fails
|
|
98
|
+
"""
|
|
99
|
+
if not self.VALIDATION_RULES:
|
|
100
|
+
return
|
|
101
|
+
|
|
102
|
+
errors = []
|
|
103
|
+
params = params or {}
|
|
104
|
+
|
|
105
|
+
for param_name, rules in self.VALIDATION_RULES.items():
|
|
106
|
+
value = params.get(param_name)
|
|
107
|
+
|
|
108
|
+
# Check required
|
|
109
|
+
if rules.get('required') and (value is None or value == ''):
|
|
110
|
+
errors.append(f"Required parameter [{param_name}] is missing.")
|
|
111
|
+
continue
|
|
112
|
+
|
|
113
|
+
# Skip validation if value is not provided and not required
|
|
114
|
+
if value is None:
|
|
115
|
+
continue
|
|
116
|
+
|
|
117
|
+
param_type = rules.get('type', 'string')
|
|
118
|
+
|
|
119
|
+
# Type validation
|
|
120
|
+
if param_type in ('integer', 'number'):
|
|
121
|
+
try:
|
|
122
|
+
num_value = float(value) if param_type == 'number' else int(value)
|
|
123
|
+
|
|
124
|
+
# Min/max validation
|
|
125
|
+
if 'min' in rules and num_value < rules['min']:
|
|
126
|
+
errors.append(f"Parameter [{param_name}] must be at least {rules['min']}.")
|
|
127
|
+
if 'max' in rules and num_value > rules['max']:
|
|
128
|
+
errors.append(f"Parameter [{param_name}] must be at most {rules['max']}.")
|
|
129
|
+
except (ValueError, TypeError):
|
|
130
|
+
errors.append(f"Parameter [{param_name}] must be a valid {param_type}.")
|
|
131
|
+
continue
|
|
132
|
+
|
|
133
|
+
elif param_type == 'string':
|
|
134
|
+
if not isinstance(value, str):
|
|
135
|
+
errors.append(f"Parameter [{param_name}] must be a string.")
|
|
136
|
+
continue
|
|
137
|
+
|
|
138
|
+
# Length validation
|
|
139
|
+
if 'minLength' in rules and len(value) < rules['minLength']:
|
|
140
|
+
errors.append(f"Parameter [{param_name}] must be at least {rules['minLength']} characters.")
|
|
141
|
+
if 'maxLength' in rules and len(value) > rules['maxLength']:
|
|
142
|
+
errors.append(f"Parameter [{param_name}] must be at most {rules['maxLength']} characters.")
|
|
143
|
+
|
|
144
|
+
# Format validation
|
|
145
|
+
if 'format' in rules and rules['format'] in self.FORMAT_PATTERNS:
|
|
146
|
+
pattern = self.FORMAT_PATTERNS[rules['format']]
|
|
147
|
+
if not re.match(pattern, value, re.IGNORECASE):
|
|
148
|
+
errors.append(f"Parameter [{param_name}] must be a valid {rules['format']}.")
|
|
149
|
+
|
|
150
|
+
elif param_type == 'boolean':
|
|
151
|
+
if not isinstance(value, bool) and value not in ('true', 'false', True, False):
|
|
152
|
+
errors.append(f"Parameter [{param_name}] must be a boolean.")
|
|
153
|
+
|
|
154
|
+
elif param_type == 'array':
|
|
155
|
+
if not isinstance(value, list):
|
|
156
|
+
errors.append(f"Parameter [{param_name}] must be an array.")
|
|
157
|
+
|
|
158
|
+
# Enum validation
|
|
159
|
+
if 'enum' in rules and value not in rules['enum']:
|
|
160
|
+
errors.append(f"Parameter [{param_name}] must be one of: {', '.join(map(str, rules['enum']))}.")
|
|
161
|
+
|
|
162
|
+
if errors:
|
|
163
|
+
raise ValidationError(errors)
|
|
164
|
+
|
|
165
|
+
def execute(self, params: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: # Returns ComplimentGeneratorData in 'data' field
|
|
166
|
+
"""
|
|
167
|
+
Execute the API request
|
|
168
|
+
|
|
169
|
+
:param params: API parameters (optional)
|
|
170
|
+
:return: API response as a dictionary
|
|
171
|
+
:raises ComplimentsAPIClientError: If the request fails or returns an error
|
|
172
|
+
:raises ValidationError: If parameter validation fails
|
|
173
|
+
"""
|
|
174
|
+
|
|
175
|
+
# Validate parameters against schema rules
|
|
176
|
+
self._validate_params(params)
|
|
177
|
+
|
|
178
|
+
method = "GET"
|
|
179
|
+
|
|
180
|
+
self._log(f"Making {method} request to {self.base_url}")
|
|
181
|
+
if params:
|
|
182
|
+
self._log(f"Parameters: {params}")
|
|
183
|
+
|
|
184
|
+
try:
|
|
185
|
+
if method.upper() == 'POST':
|
|
186
|
+
self._log("Sending POST request with JSON body")
|
|
187
|
+
response = self.session.post(self.base_url, json=params, timeout=30)
|
|
188
|
+
else:
|
|
189
|
+
self._log("Sending GET request with query parameters")
|
|
190
|
+
response = self.session.get(self.base_url, params=params, timeout=30)
|
|
191
|
+
|
|
192
|
+
self._log(f"Response status code: {response.status_code}")
|
|
193
|
+
|
|
194
|
+
# Try to parse JSON response
|
|
195
|
+
try:
|
|
196
|
+
response_data = response.json()
|
|
197
|
+
except ValueError as e:
|
|
198
|
+
raise ComplimentsAPIClientError(
|
|
199
|
+
f"Invalid JSON response from API: {str(e)}",
|
|
200
|
+
status_code=response.status_code
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
# Check for API-level errors in the response
|
|
204
|
+
if response_data.get('status') == 'error':
|
|
205
|
+
error_message = response_data.get('error', 'Unknown API error')
|
|
206
|
+
self._log(f"API returned error: {error_message}")
|
|
207
|
+
raise ComplimentsAPIClientError(
|
|
208
|
+
error_message,
|
|
209
|
+
status_code=response.status_code,
|
|
210
|
+
response=response_data
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
# Check HTTP status code
|
|
214
|
+
if not response.ok:
|
|
215
|
+
error_message = response_data.get('error', f"HTTP {response.status_code} error")
|
|
216
|
+
self._log(f"HTTP error: {error_message}")
|
|
217
|
+
raise ComplimentsAPIClientError(
|
|
218
|
+
error_message,
|
|
219
|
+
status_code=response.status_code,
|
|
220
|
+
response=response_data
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
self._log("Request successful")
|
|
224
|
+
return response_data
|
|
225
|
+
|
|
226
|
+
except requests.exceptions.Timeout as e:
|
|
227
|
+
self._log(f"Request timeout: {str(e)}")
|
|
228
|
+
raise ComplimentsAPIClientError(f"Request timeout: {str(e)}")
|
|
229
|
+
except requests.exceptions.ConnectionError as e:
|
|
230
|
+
self._log(f"Connection error: {str(e)}")
|
|
231
|
+
raise ComplimentsAPIClientError(f"Connection error: {str(e)}")
|
|
232
|
+
except requests.exceptions.RequestException as e:
|
|
233
|
+
self._log(f"Request exception: {str(e)}")
|
|
234
|
+
raise ComplimentsAPIClientError(f"Request failed: {str(e)}")
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def close(self) -> None:
|
|
238
|
+
"""
|
|
239
|
+
Close the session and release resources
|
|
240
|
+
"""
|
|
241
|
+
self._log("Closing session")
|
|
242
|
+
self.session.close()
|
|
243
|
+
|
|
244
|
+
def __enter__(self):
|
|
245
|
+
"""Context manager entry"""
|
|
246
|
+
return self
|
|
247
|
+
|
|
248
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
249
|
+
"""Context manager exit"""
|
|
250
|
+
self.close()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
lib_folder = os.path.dirname(os.path.realpath(__file__))
|
|
5
|
+
requirements_file = os.path.join(lib_folder, 'requirements.txt')
|
|
6
|
+
install_requires = ["requests >= 2.25.1", "setuptools >= 56.0.0"]
|
|
7
|
+
if os.path.exists(requirements_file):
|
|
8
|
+
with open(requirements_file, 'r') as f:
|
|
9
|
+
install_requires = f.read().splitlines()
|
|
10
|
+
|
|
11
|
+
setup(
|
|
12
|
+
name='apiverve_complimentgenerator',
|
|
13
|
+
version='1.2.2',
|
|
14
|
+
packages=find_packages(),
|
|
15
|
+
include_package_data=True,
|
|
16
|
+
install_requires=install_requires,
|
|
17
|
+
description='Compliment Generator creates unique, heartfelt compliments using template-based generation with extensive word banks. Perfect for apps, chatbots, or spreading positivity.',
|
|
18
|
+
author='APIVerve',
|
|
19
|
+
author_email='hello@apiverve.com',
|
|
20
|
+
url='https://apiverve.com/marketplace/compliments?utm_source=pypi&utm_medium=referral&utm_content=homepage',
|
|
21
|
+
classifiers=[
|
|
22
|
+
'Programming Language :: Python :: 3',
|
|
23
|
+
'Operating System :: OS Independent',
|
|
24
|
+
],
|
|
25
|
+
python_requires='>=3.6',
|
|
26
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='apiverve_complimentgenerator',
|
|
5
|
+
version='1.2.2',
|
|
6
|
+
packages=find_packages(),
|
|
7
|
+
include_package_data=True,
|
|
8
|
+
install_requires=[
|
|
9
|
+
'requests',
|
|
10
|
+
'setuptools'
|
|
11
|
+
],
|
|
12
|
+
description='Compliment Generator creates unique, heartfelt compliments using template-based generation with extensive word banks. Perfect for apps, chatbots, or spreading positivity.',
|
|
13
|
+
author='APIVerve',
|
|
14
|
+
author_email='hello@apiverve.com',
|
|
15
|
+
url='https://apiverve.com/marketplace/compliments?utm_source=pypi&utm_medium=referral&utm_content=homepage',
|
|
16
|
+
classifiers=[
|
|
17
|
+
'Programming Language :: Python :: 3',
|
|
18
|
+
'Operating System :: OS Independent',
|
|
19
|
+
],
|
|
20
|
+
python_requires='>=3.6',
|
|
21
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Initialize test module
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
3
|
+
|
|
4
|
+
class TestClient(unittest.TestCase):
|
|
5
|
+
|
|
6
|
+
def setUp(self):
|
|
7
|
+
self.api_key = 'test_api_key'
|
|
8
|
+
self.client = ComplimentsAPIClient(self.api_key)
|
|
9
|
+
|
|
10
|
+
def test_get(self):
|
|
11
|
+
# Assuming there's an endpoint 'test_endpoint' for testing purposes
|
|
12
|
+
try:
|
|
13
|
+
response = self.client.get('test_endpoint')
|
|
14
|
+
self.assertIsInstance(response, dict)
|
|
15
|
+
except Exception as e:
|
|
16
|
+
self.fail(f"GET request failed with exception {e}")
|
|
17
|
+
|
|
18
|
+
if __name__ == '__main__':
|
|
19
|
+
unittest.main()
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apiverve-complimentgenerator
|
|
3
|
+
Version: 1.2.2
|
|
4
|
+
Summary: Compliment Generator creates unique, heartfelt compliments using template-based generation with extensive word banks. Perfect for apps, chatbots, or spreading positivity.
|
|
5
|
+
Author-email: APIVerve <hello@apiverve.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://apiverve.com/marketplace/compliments?utm_source=pypi&utm_medium=referral&utm_content=homepage
|
|
8
|
+
Project-URL: Documentation, https://docs.apiverve.com/ref/compliments?utm_source=pypi&utm_medium=referral&utm_content=docs
|
|
9
|
+
Project-URL: Repository, https://github.com/apiverve/compliments-api
|
|
10
|
+
Project-URL: Twitter, https://twitter.com/apivervehq
|
|
11
|
+
Keywords: compliment,compliments,generator,positive,encouragement
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Classifier: Natural Language :: English
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: requests>=2.25.0
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
Compliment Generator API
|
|
26
|
+
============
|
|
27
|
+
|
|
28
|
+
Compliment Generator creates unique, heartfelt compliments using template-based generation with extensive word banks. Perfect for apps, chatbots, or spreading positivity.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/apiverve-complimentgenerator/)
|
|
32
|
+
|
|
33
|
+
This is a Python wrapper for the [Compliment Generator API](https://apiverve.com/marketplace/compliments?utm_source=pypi&utm_medium=referral&utm_content=readme)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
Using `pip`:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install apiverve-complimentgenerator
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Using `pip3`:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip3 install apiverve-complimentgenerator
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
Before using the Compliment Generator API client, you have to setup your account and obtain your API Key.
|
|
56
|
+
You can get it by signing up at [https://apiverve.com](https://apiverve.com?utm_source=pypi&utm_medium=referral&utm_content=readme)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
Here's a simple example to get you started quickly:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
66
|
+
|
|
67
|
+
# Initialize the client with your APIVerve API key
|
|
68
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
69
|
+
|
|
70
|
+
query = { "adult": }
|
|
71
|
+
|
|
72
|
+
try:
|
|
73
|
+
# Make the API call
|
|
74
|
+
result = api.execute(query)
|
|
75
|
+
|
|
76
|
+
# Print the result
|
|
77
|
+
print(result)
|
|
78
|
+
except Exception as e:
|
|
79
|
+
print(f"Error: {e}")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
The Compliment Generator API documentation is found here: [https://docs.apiverve.com/ref/compliments](https://docs.apiverve.com/ref/compliments?utm_source=pypi&utm_medium=referral&utm_content=readme).
|
|
87
|
+
You can find parameters, example responses, and status codes documented here.
|
|
88
|
+
|
|
89
|
+
### Setup
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
# Import the client module
|
|
93
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
94
|
+
|
|
95
|
+
# Initialize the client with your APIVerve API key
|
|
96
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Perform Request
|
|
102
|
+
|
|
103
|
+
Using the API client, you can perform requests to the API.
|
|
104
|
+
|
|
105
|
+
###### Define Query
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
query = { "adult": }
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
###### Simple Request
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
# Make a request to the API
|
|
115
|
+
result = api.execute(query)
|
|
116
|
+
|
|
117
|
+
# Print the result
|
|
118
|
+
print(result)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
###### Example Response
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"status": "ok",
|
|
126
|
+
"error": null,
|
|
127
|
+
"data": {
|
|
128
|
+
"compliment": "Your graceful professionalism is an asset to everyone."
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Error Handling
|
|
136
|
+
|
|
137
|
+
The API client provides comprehensive error handling through the `ComplimentsAPIClientError` exception. Here are some examples:
|
|
138
|
+
|
|
139
|
+
### Basic Error Handling
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient, ComplimentsAPIClientError
|
|
143
|
+
|
|
144
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
145
|
+
|
|
146
|
+
query = { "adult": }
|
|
147
|
+
|
|
148
|
+
try:
|
|
149
|
+
result = api.execute(query)
|
|
150
|
+
print("Success!")
|
|
151
|
+
print(result)
|
|
152
|
+
except ComplimentsAPIClientError as e:
|
|
153
|
+
print(f"API Error: {e.message}")
|
|
154
|
+
if e.status_code:
|
|
155
|
+
print(f"Status Code: {e.status_code}")
|
|
156
|
+
if e.response:
|
|
157
|
+
print(f"Response: {e.response}")
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Handling Specific Error Types
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient, ComplimentsAPIClientError
|
|
164
|
+
|
|
165
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
166
|
+
|
|
167
|
+
query = { "adult": }
|
|
168
|
+
|
|
169
|
+
try:
|
|
170
|
+
result = api.execute(query)
|
|
171
|
+
|
|
172
|
+
# Check for successful response
|
|
173
|
+
if result.get('status') == 'success':
|
|
174
|
+
print("Request successful!")
|
|
175
|
+
print(result.get('data'))
|
|
176
|
+
else:
|
|
177
|
+
print(f"API returned an error: {result.get('error')}")
|
|
178
|
+
|
|
179
|
+
except ComplimentsAPIClientError as e:
|
|
180
|
+
# Handle API client errors
|
|
181
|
+
if e.status_code == 401:
|
|
182
|
+
print("Unauthorized: Invalid API key")
|
|
183
|
+
elif e.status_code == 429:
|
|
184
|
+
print("Rate limit exceeded")
|
|
185
|
+
elif e.status_code >= 500:
|
|
186
|
+
print("Server error - please try again later")
|
|
187
|
+
else:
|
|
188
|
+
print(f"API error: {e.message}")
|
|
189
|
+
except Exception as e:
|
|
190
|
+
# Handle unexpected errors
|
|
191
|
+
print(f"Unexpected error: {str(e)}")
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Using Context Manager (Recommended)
|
|
195
|
+
|
|
196
|
+
The client supports the context manager protocol for automatic resource cleanup:
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient, ComplimentsAPIClientError
|
|
200
|
+
|
|
201
|
+
query = { "adult": }
|
|
202
|
+
|
|
203
|
+
# Using context manager ensures proper cleanup
|
|
204
|
+
with ComplimentsAPIClient("[YOUR_API_KEY]") as api:
|
|
205
|
+
try:
|
|
206
|
+
result = api.execute(query)
|
|
207
|
+
print(result)
|
|
208
|
+
except ComplimentsAPIClientError as e:
|
|
209
|
+
print(f"Error: {e.message}")
|
|
210
|
+
# Session is automatically closed here
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Advanced Features
|
|
216
|
+
|
|
217
|
+
### Debug Mode
|
|
218
|
+
|
|
219
|
+
Enable debug logging to see detailed request and response information:
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
223
|
+
|
|
224
|
+
# Enable debug mode
|
|
225
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]", debug=True)
|
|
226
|
+
|
|
227
|
+
query = { "adult": }
|
|
228
|
+
|
|
229
|
+
# Debug information will be printed to console
|
|
230
|
+
result = api.execute(query)
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Manual Session Management
|
|
234
|
+
|
|
235
|
+
If you need to manually manage the session lifecycle:
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
239
|
+
|
|
240
|
+
api = ComplimentsAPIClient("[YOUR_API_KEY]")
|
|
241
|
+
|
|
242
|
+
query = { "adult": }
|
|
243
|
+
|
|
244
|
+
try:
|
|
245
|
+
result = api.execute(query)
|
|
246
|
+
print(result)
|
|
247
|
+
finally:
|
|
248
|
+
# Manually close the session when done
|
|
249
|
+
api.close()
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Customer Support
|
|
255
|
+
|
|
256
|
+
Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact?utm_source=pypi&utm_medium=referral&utm_content=readme).
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Updates
|
|
261
|
+
Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Legal
|
|
266
|
+
|
|
267
|
+
All usage of the APIVerve website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms?utm_source=pypi&utm_medium=referral&utm_content=readme) and all legal documents and agreements.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## License
|
|
272
|
+
Licensed under the MIT License (MIT)
|
|
273
|
+
|
|
274
|
+
Copyright (©) 2026 APIVerve, and EvlarSoft LLC
|
|
275
|
+
|
|
276
|
+
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:
|
|
277
|
+
|
|
278
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
279
|
+
|
|
280
|
+
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.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/apiverve_complimentgenerator/__init__.py
|
|
5
|
+
src/apiverve_complimentgenerator/apiClient.py
|
|
6
|
+
src/apiverve_complimentgenerator/exceptions.py
|
|
7
|
+
src/apiverve_complimentgenerator/setup.py
|
|
8
|
+
src/apiverve_complimentgenerator/setup_dep.py
|
|
9
|
+
src/apiverve_complimentgenerator.egg-info/PKG-INFO
|
|
10
|
+
src/apiverve_complimentgenerator.egg-info/SOURCES.txt
|
|
11
|
+
src/apiverve_complimentgenerator.egg-info/dependency_links.txt
|
|
12
|
+
src/apiverve_complimentgenerator.egg-info/requires.txt
|
|
13
|
+
src/apiverve_complimentgenerator.egg-info/top_level.txt
|
|
14
|
+
src/apiverve_complimentgenerator/tests/__init__.py
|
|
15
|
+
src/apiverve_complimentgenerator/tests/test_api.py
|
|
16
|
+
tests/test_api.py
|
apiverve_complimentgenerator-1.2.2/src/apiverve_complimentgenerator.egg-info/dependency_links.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests>=2.25.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
apiverve_complimentgenerator
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from apiverve_complimentgenerator.apiClient import ComplimentsAPIClient
|
|
3
|
+
from unittest.mock import patch
|
|
4
|
+
|
|
5
|
+
class TestComplimentsAPIClient(unittest.TestCase):
|
|
6
|
+
|
|
7
|
+
def setUp(self):
|
|
8
|
+
self.api_key = 'test_api_key'
|
|
9
|
+
self.client = ComplimentsAPIClient(self.api_key)
|
|
10
|
+
|
|
11
|
+
@patch('apiverve_complimentgenerator.apiClient.requests.get')
|
|
12
|
+
def test_make_request_success(self, mock_get):
|
|
13
|
+
# Assuming there's an endpoint 'test_endpoint' for testing purposes
|
|
14
|
+
mock_get.return_value.status_code = 200
|
|
15
|
+
mock_get.return_value.json.return_value = {'test': 'test'}
|
|
16
|
+
response = self.client.get('test_endpoint')
|
|
17
|
+
self.assertIsInstance(response, dict)
|
|
18
|
+
|
|
19
|
+
@patch('apiverve_complimentgenerator.apiClient.requests.get')
|
|
20
|
+
def test_make_request_failure(self, mock_get):
|
|
21
|
+
# Assuming there's an endpoint 'test_endpoint' for testing purposes
|
|
22
|
+
mock_get.return_value.status_code = 404
|
|
23
|
+
with self.assertRaises(Exception):
|
|
24
|
+
self.client.get('test_endpoint')
|
|
25
|
+
|
|
26
|
+
if __name__ == '__main__':
|
|
27
|
+
unittest.main()
|