An actively maintained wrapper for the somerandomapi API.
Project description
An actively maintained wrapper for the somerandomapi API.
Installation
Install the stable version from PyPI using pip:
python -m pip install somerandomapi
Or the latest dev version from GitHub using pip and git:
python -m pip install "somerandomapi.py @ git+https://github.com/Soheab/somerandomapi.py"
Basic Examples
Get a random joke
import asyncio
import somerandomapi
sra_api = somerandomapi.Client("<optional api token>")
async def main():
joke = await sra_api.joke()
print(joke)
await sra_api.close()
asyncio.run(main())
Use the chatbot feature:
import asyncio
import somerandomapi
async def main():
async with somerandomapi.Client("<optional api token>") as sra_api:
stopped: bool = False
while not stopped:
# can also do await sra-api.chatbot("message") to get a response immediately
# but this is more efficient for long conversations
async with sra_api.chatbot() as chatbot:
user_input = input("You: ")
if user_input.lower() == "stop":
stopped = True
print("Stopping the chatbot.")
break
# can also do await chatbot.send("message") to get a response
async with chatbot.send(user_input) as response:
if response is None:
print("No response received.")
continue
print(f"Bot: {response.response}")
asyncio.run(main())
See more examples in the examples directory on GitHub.
Documentation
Visit the full documentation at: https://somerandomapipy.readthedocs.io
Contact
For any questions, suggestions, or issues, feel free to reach out to me on Discord (@Soheab_).
License
This project is licensed under the MPL2-0 License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file somerandomapi_py-0.1.3.tar.gz.
File metadata
- Download URL: somerandomapi_py-0.1.3.tar.gz
- Upload date:
- Size: 48.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
316a6e0cd5e6c665ef5c8e8603b782fcc27f308865fa0b8b9b7368c3dc1ce7b2
|
|
| MD5 |
e2ed4b99795931953e2fcc0fbedab73c
|
|
| BLAKE2b-256 |
9f8d91befa3969955384fb6c9cf10621f073a30cb79e9f2e01dc20c20b0efc67
|
Provenance
The following attestation bundles were made for somerandomapi_py-0.1.3.tar.gz:
Publisher:
python-publish.yml on Soheab/somerandomapi.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
somerandomapi_py-0.1.3.tar.gz -
Subject digest:
316a6e0cd5e6c665ef5c8e8603b782fcc27f308865fa0b8b9b7368c3dc1ce7b2 - Sigstore transparency entry: 615392087
- Sigstore integration time:
-
Permalink:
Soheab/somerandomapi.py@31362eb3d3ec859eee3bdea0a3dedfcf9aec69b8 -
Branch / Tag:
refs/tags/0.1.3 - Owner: https://github.com/Soheab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@31362eb3d3ec859eee3bdea0a3dedfcf9aec69b8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file somerandomapi_py-0.1.3-py3-none-any.whl.
File metadata
- Download URL: somerandomapi_py-0.1.3-py3-none-any.whl
- Upload date:
- Size: 59.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1448a727c67c0c791939ec41a82d044269f63f2f838470d6274453aa550fa785
|
|
| MD5 |
56322906c2e47a155fd1883b1e675af9
|
|
| BLAKE2b-256 |
df273cdee86ec12e2791007e8fad883b77d7bb5e5b868b4f6a36b83595803065
|
Provenance
The following attestation bundles were made for somerandomapi_py-0.1.3-py3-none-any.whl:
Publisher:
python-publish.yml on Soheab/somerandomapi.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
somerandomapi_py-0.1.3-py3-none-any.whl -
Subject digest:
1448a727c67c0c791939ec41a82d044269f63f2f838470d6274453aa550fa785 - Sigstore transparency entry: 615392089
- Sigstore integration time:
-
Permalink:
Soheab/somerandomapi.py@31362eb3d3ec859eee3bdea0a3dedfcf9aec69b8 -
Branch / Tag:
refs/tags/0.1.3 - Owner: https://github.com/Soheab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@31362eb3d3ec859eee3bdea0a3dedfcf9aec69b8 -
Trigger Event:
release
-
Statement type: