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.3.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.3-py3-none-any.whl (59.5 kB view details)

Uploaded Python 3

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

Hashes for somerandomapi_py-0.1.3.tar.gz
Algorithm Hash digest
SHA256 316a6e0cd5e6c665ef5c8e8603b782fcc27f308865fa0b8b9b7368c3dc1ce7b2
MD5 e2ed4b99795931953e2fcc0fbedab73c
BLAKE2b-256 9f8d91befa3969955384fb6c9cf10621f073a30cb79e9f2e01dc20c20b0efc67

See more details on using hashes here.

Provenance

The following attestation bundles were made for somerandomapi_py-0.1.3.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.3-py3-none-any.whl.

File metadata

File hashes

Hashes for somerandomapi_py-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1448a727c67c0c791939ec41a82d044269f63f2f838470d6274453aa550fa785
MD5 56322906c2e47a155fd1883b1e675af9
BLAKE2b-256 df273cdee86ec12e2791007e8fad883b77d7bb5e5b868b4f6a36b83595803065

See more details on using hashes here.

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

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