Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

somerandomapi_py-0.1.2.tar.gz (48.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

somerandomapi_py-0.1.2-py3-none-any.whl (59.5 kB view details)

Uploaded Python 3

File details

Details for the file somerandomapi_py-0.1.2.tar.gz.

File metadata

  • Download URL: somerandomapi_py-0.1.2.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

Hashes for somerandomapi_py-0.1.2.tar.gz
Algorithm Hash digest
SHA256 028c1667e81f68145dbb3489510b37282738130b8c6a0e08d60901a0dd86ce65
MD5 a71c19b5d58bcde34f4445eea03f598f
BLAKE2b-256 fa882c975a37123d4044a578624903164729ace11623c3e618a316b6a27c73f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for somerandomapi_py-0.1.2.tar.gz:

Publisher: python-publish.yml on Soheab/somerandomapi.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file somerandomapi_py-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for somerandomapi_py-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a61913c8770137848eb4fb6bd15ec099218c0bb4c9e916de2c7249a6d1997e94
MD5 463ec0dd0ebed5a7f811088c75e407df
BLAKE2b-256 043eacbe51c21f65af9999687e8670678f57bcb9dbd969fe55ec6be6708d9d39

See more details on using hashes here.

Provenance

The following attestation bundles were made for somerandomapi_py-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on Soheab/somerandomapi.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page