rdoclient


Namerdoclient JSON
Version 1.5.0 PyPI version JSON
download
home_pagehttps://www.random.org/
SummaryThe official RANDOM.ORG JSON-RPC API (Release 4) implementation for Python 2 and 3.
upload_time2023-04-11 16:15:46
maintainer
docs_urlNone
authorRANDOM.ORG
requires_python>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
licenseMIT
keywords random.org random client implementation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            JSON-RPC-Python
===============

The official RANDOM.ORG JSON-RPC API (Release 4) implementation for Python 2 and 3.

This is a Python implementation of the RANDOM.ORG JSON-RPC API (R4). It provides either serialized or unserialized access to both the signed and unsigned methods of the API through the RandomOrgClient class. It also provides a convenience class through the RandomOrgClient class, the RandomOrgCache, for precaching requests. In the context of this module, a serialized client is one for which the sequence of requests matches the sequence of responses.

Installation
------------

To install, simply:

.. code-block:: bash

    $ pip install rdoclient

Requires the `requests <http://docs.python-requests.org/en/latest/>`_ lib:

.. code-block:: bash

    $ pip install requests

Requires the `six <https://six.readthedocs.io/>`_ lib:

.. code-block:: bash

    $ pip install six


Note that the required dependencies 'requests' and 'six' are installed automatically, when using pip install for 'rdoclient' version >= 1.2.  

Usage
-----

The default setup is best for non-time-critical serialized requests, e.g., batch clients:

.. code-block:: pycon

    >>> from rdoclient import RandomOrgClient
    >>> r = RandomOrgClient(YOUR_API_KEY_HERE)
    >>> r.generate_integers(5, 0, 10)
    [6, 2, 8, 9, 2]

...or for more time sensitive serialized applications, e.g., real-time draws, use:

.. code-block:: pycon

    >>> r = RandomOrgClient(YOUR_API_KEY_HERE, blocking_timeout=2.0, http_timeout=10.0)
    >>> r.generate_signed_integers(5, 0, 10)
    {'random': {u'min': 0, u'max': 10, u'completionTime': u'2014-05-19 14:26:14Z', u'serialNumber': 1482, u'n': 5, u'base': 10, u'hashedApiKey': u'HASHED_KEY_HERE', u'data': [10, 9, 0, 1, 5], u'method': u'generateSignedIntegers', u'replacement': True}, 'data': [10, 9, 0, 1, 5], 'signature': u'SIGNATURE_HERE'}

If obtaining some kind of response instantly is important, a cache should be used. A cache will populate itself as quickly and efficiently as possible allowing pre-obtained randomness to be supplied instantly. If randomness is not available - e.g., the cache is empty - the cache will return an Empty exception allowing the lack of randomness to be handled without delay:

.. code-block:: pycon

    >>> r = RandomOrgClient(YOUR_API_KEY_HERE, blocking_timeout=60.0*60.0, http_timeout=30.0)
    >>> c = r.create_integer_cache(5, 0, 10)
    >>> try:
    ...     c.get()
    ... except Queue.Empty:
    ...     # handle lack of true random number here
    ...     # possibly use a pseudo random number generator
    ...
    [1, 4, 6, 9, 10]

Note that caches don't support signed responses as it is assumed that clients using the signing features want full control over the serial numbering of responses.
	
Finally, it is possible to request live results as-soon-as-possible and without serialization, however this may be more prone to timeout failures as the client must obey the server's advisory delay times if the server is overloaded:

.. code-block:: pycon

    >>> r = RandomOrgClient(YOUR_API_KEY_HERE, blocking_timeout=0.0, http_timeout=10.0, serialized=False)
    >>> r.generate_integers(5, 0, 10)
    [3, 5, 2, 4, 8]

Signature Verification
----------------------
There are two additional methods to generate signature verification URLs and HTML forms (*create_url* and *create_html*) using the random object and signature returned from any of the signed (value generating) methods. The generated URLs and HTML forms link to the same web page that is also shown when a result is verified using the online `Signature Verification Form <https://api.random.org/signatures/form>`_.

Documentation
-------------

For a full list of available randomness generation functions and other features see rdoclient.py documentation and https://api.random.org/json-rpc/4

Tests
-----

Note that to run the accompanying tests the _API_KEY_1 field in test_rdoclient.py must be changed to contain a valid API key. The _API_KEY_2 field does not need to be changed. 

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.random.org/",
    "name": "rdoclient",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
    "maintainer_email": "",
    "keywords": "RANDOM.ORG random client implementation",
    "author": "RANDOM.ORG",
    "author_email": "contact@random.org",
    "download_url": "https://files.pythonhosted.org/packages/a1/be/b80df0a1982cc8678259bc505daedd8f3e1dc14895947c47db87c53f851d/rdoclient-1.5.0.tar.gz",
    "platform": null,
    "description": "JSON-RPC-Python\r\n===============\r\n\r\nThe official RANDOM.ORG JSON-RPC API (Release 4) implementation for Python 2 and 3.\r\n\r\nThis is a Python implementation of the RANDOM.ORG JSON-RPC API (R4). It provides either serialized or unserialized access to both the signed and unsigned methods of the API through the RandomOrgClient class. It also provides a convenience class through the RandomOrgClient class, the RandomOrgCache, for precaching requests. In the context of this module, a serialized client is one for which the sequence of requests matches the sequence of responses.\r\n\r\nInstallation\r\n------------\r\n\r\nTo install, simply:\r\n\r\n.. code-block:: bash\r\n\r\n    $ pip install rdoclient\r\n\r\nRequires the `requests <http://docs.python-requests.org/en/latest/>`_ lib:\r\n\r\n.. code-block:: bash\r\n\r\n    $ pip install requests\r\n\r\nRequires the `six <https://six.readthedocs.io/>`_ lib:\r\n\r\n.. code-block:: bash\r\n\r\n    $ pip install six\r\n\r\n\r\nNote that the required dependencies 'requests' and 'six' are installed automatically, when using pip install for 'rdoclient' version >= 1.2.  \r\n\r\nUsage\r\n-----\r\n\r\nThe default setup is best for non-time-critical serialized requests, e.g., batch clients:\r\n\r\n.. code-block:: pycon\r\n\r\n    >>> from rdoclient import RandomOrgClient\r\n    >>> r = RandomOrgClient(YOUR_API_KEY_HERE)\r\n    >>> r.generate_integers(5, 0, 10)\r\n    [6, 2, 8, 9, 2]\r\n\r\n...or for more time sensitive serialized applications, e.g., real-time draws, use:\r\n\r\n.. code-block:: pycon\r\n\r\n    >>> r = RandomOrgClient(YOUR_API_KEY_HERE, blocking_timeout=2.0, http_timeout=10.0)\r\n    >>> r.generate_signed_integers(5, 0, 10)\r\n    {'random': {u'min': 0, u'max': 10, u'completionTime': u'2014-05-19 14:26:14Z', u'serialNumber': 1482, u'n': 5, u'base': 10, u'hashedApiKey': u'HASHED_KEY_HERE', u'data': [10, 9, 0, 1, 5], u'method': u'generateSignedIntegers', u'replacement': True}, 'data': [10, 9, 0, 1, 5], 'signature': u'SIGNATURE_HERE'}\r\n\r\nIf obtaining some kind of response instantly is important, a cache should be used. A cache will populate itself as quickly and efficiently as possible allowing pre-obtained randomness to be supplied instantly. If randomness is not available - e.g., the cache is empty - the cache will return an Empty exception allowing the lack of randomness to be handled without delay:\r\n\r\n.. code-block:: pycon\r\n\r\n    >>> r = RandomOrgClient(YOUR_API_KEY_HERE, blocking_timeout=60.0*60.0, http_timeout=30.0)\r\n    >>> c = r.create_integer_cache(5, 0, 10)\r\n    >>> try:\r\n    ...     c.get()\r\n    ... except Queue.Empty:\r\n    ...     # handle lack of true random number here\r\n    ...     # possibly use a pseudo random number generator\r\n    ...\r\n    [1, 4, 6, 9, 10]\r\n\r\nNote that caches don't support signed responses as it is assumed that clients using the signing features want full control over the serial numbering of responses.\r\n\t\r\nFinally, it is possible to request live results as-soon-as-possible and without serialization, however this may be more prone to timeout failures as the client must obey the server's advisory delay times if the server is overloaded:\r\n\r\n.. code-block:: pycon\r\n\r\n    >>> r = RandomOrgClient(YOUR_API_KEY_HERE, blocking_timeout=0.0, http_timeout=10.0, serialized=False)\r\n    >>> r.generate_integers(5, 0, 10)\r\n    [3, 5, 2, 4, 8]\r\n\r\nSignature Verification\r\n----------------------\r\nThere are two additional methods to generate signature verification URLs and HTML forms (*create_url* and *create_html*) using the random object and signature returned from any of the signed (value generating) methods. The generated URLs and HTML forms link to the same web page that is also shown when a result is verified using the online `Signature Verification Form <https://api.random.org/signatures/form>`_.\r\n\r\nDocumentation\r\n-------------\r\n\r\nFor a full list of available randomness generation functions and other features see rdoclient.py documentation and https://api.random.org/json-rpc/4\r\n\r\nTests\r\n-----\r\n\r\nNote that to run the accompanying tests the _API_KEY_1 field in test_rdoclient.py must be changed to contain a valid API key. The _API_KEY_2 field does not need to be changed. \r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "The official RANDOM.ORG JSON-RPC API (Release 4) implementation for Python 2 and 3.",
    "version": "1.5.0",
    "split_keywords": [
        "random.org",
        "random",
        "client",
        "implementation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "40dfe8122999d28f34adcc1132bf928ba5a688301494ebb230a08f86c8b3a584",
                "md5": "2ab0d1c254d65db44644f2b9cfc9f28d",
                "sha256": "983d642675c2291ca1d13a25cf3812dc394a2f14605e3562b9edf36e8e998a71"
            },
            "downloads": -1,
            "filename": "rdoclient-1.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2ab0d1c254d65db44644f2b9cfc9f28d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
            "size": 23379,
            "upload_time": "2023-04-11T16:15:45",
            "upload_time_iso_8601": "2023-04-11T16:15:45.157311Z",
            "url": "https://files.pythonhosted.org/packages/40/df/e8122999d28f34adcc1132bf928ba5a688301494ebb230a08f86c8b3a584/rdoclient-1.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a1beb80df0a1982cc8678259bc505daedd8f3e1dc14895947c47db87c53f851d",
                "md5": "c8d747fa9fb9cd45cad61a5ad58b1083",
                "sha256": "d755b1276736cd496e4fc7ea3c0382af4f4e00cc135c6089d6da1de43304e61a"
            },
            "downloads": -1,
            "filename": "rdoclient-1.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c8d747fa9fb9cd45cad61a5ad58b1083",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
            "size": 23684,
            "upload_time": "2023-04-11T16:15:46",
            "upload_time_iso_8601": "2023-04-11T16:15:46.988962Z",
            "url": "https://files.pythonhosted.org/packages/a1/be/b80df0a1982cc8678259bc505daedd8f3e1dc14895947c47db87c53f851d/rdoclient-1.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-11 16:15:46",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "rdoclient"
}
        
Elapsed time: 0.06579s