lightstreamer-client-lib


Namelightstreamer-client-lib JSON
Version 2.1.0 PyPI version JSON
download
home_page
SummaryLightstreamer Client SDK
upload_time2023-12-19 08:39:34
maintainer
docs_urlNone
author
requires_python>=3.7
licenseApache-2.0
keywords lightstreamer push realtime real-time
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Lightstreamer Python Client SDK

Lightstreamer Python Client SDK enables any Python application to communicate bidirectionally with a **Lightstreamer Server**. The API allows to subscribe to real-time data pushed by the server and to send any message to the server.

The library offers automatic recovery from connection failures, automatic selection of the best available transport, and full decoupling of subscription and connection operations. It is responsible of forwarding the subscriptions to the Server and re-forwarding all the subscriptions whenever the connection is broken and then reopened.

## Installation

You can install the Lightstreamer Client SDK from [PyPI](https://pypi.org/project/lightstreamer-client-lib/):

```
python -m pip install lightstreamer-client-lib
```

The sdk is supported on Python 3.7 and above.

## Quickstart

To connect to a Lightstreamer Server, a [LightstreamerClient](https://lightstreamer.com/api/ls-python-client/2.1.0/lightstreamer.html#lightstreamer.client.ls_python_client_wrapper.LightstreamerClient) object has to be created, configured, and instructed to connect to the Lightstreamer Server. 
A minimal version of the code that creates a LightstreamerClient and connects to the Lightstreamer Server on *https://push.lightstreamer.com* will look like this:

```python
from lightstreamer.client import *

client = LightstreamerClient("http://push.lightstreamer.com/","DEMO")
client.connect()
```

For each subscription to be subscribed to a Lightstreamer Server a [Subscription](https://lightstreamer.com/api/ls-python-client/2.1.0/lightstreamer.html#lightstreamer.client.ls_python_client_wrapper.Subscription) instance is needed.
A simple Subscription containing three items and two fields to be subscribed in *MERGE* mode is easily created (see [Lightstreamer General Concepts](https://lightstreamer.com/docs/ls-server/latest/General%20Concepts.pdf)):

```python
sub = Subscription("MERGE",["item1","item2","item3"],["stock_name","last_price"])
sub.setDataAdapter("QUOTE_ADAPTER")
sub.setRequestedSnapshot("yes")
client.subscribe(sub)
```

Before sending the subscription to the server, usually at least one [SubscriptionListener](https://lightstreamer.com/api/ls-python-client/2.1.0/lightstreamer.html#lightstreamer.client.ls_python_client_api.SubscriptionListener) is attached to the Subscription instance in order to consume the real-time updates. The following code shows the values of the fields *stock_name* and *last_price* each time a new update is received for the subscription:

```python
class SubListener(SubscriptionListener):
  def onItemUpdate(self, update):
    print("UPDATE " + update.getValue("stock_name") + " " + update.getValue("last_price"))

  # other methods...

sub.addListener(SubListener())
```

Below is the complete Python code:

```python
from lightstreamer.client import *

sub = Subscription("MERGE",["item1","item2","item3"],["stock_name","last_price"])
sub.setDataAdapter("QUOTE_ADAPTER")
sub.setRequestedSnapshot("yes")

class SubListener(SubscriptionListener):
  def onItemUpdate(self, update):
    print("UPDATE " + update.getValue("stock_name") + " " + update.getValue("last_price"))

sub.addListener(SubListener())

client = LightstreamerClient("http://push.lightstreamer.com","DEMO")
client.subscribe(sub)
client.connect()
```

## Logging

To enable the internal client logger, create a [LoggerProvider](https://lightstreamer.com/api/ls-python-client/2.1.0/lightstreamer.html#lightstreamer.client.ls_python_client_api.LoggerProvider) and set it as the default provider of [LightstreamerClient](https://lightstreamer.com/api/ls-python-client/2.1.0/lightstreamer.html#lightstreamer.client.ls_python_client_wrapper.LightstreamerClient.setLoggerProvider).

```python
import sys, logging

logging.basicConfig(level=logging.DEBUG, format="%(message)s", stream=sys.stdout)

loggerProvider = ConsoleLoggerProvider(ConsoleLogLevel.DEBUG)
LightstreamerClient.setLoggerProvider(loggerProvider)
```

## Compatibility ##

Compatible with Lightstreamer Server since version 7.4.0.

## Documentation

- [Live demos](https://demos.lightstreamer.com/?p=lightstreamer&t=client&lclient=python)

- [API Reference](https://lightstreamer.com/api/ls-python-client/2.1.0/index.html)

## Support

For questions and support please use the [Official Forum](https://forums.lightstreamer.com/). The issue list of this page is **exclusively** for bug reports and feature requests.

## License

[Apache 2.0](https://opensource.org/licenses/Apache-2.0)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "lightstreamer-client-lib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "lightstreamer,push,realtime,real-time",
    "author": "",
    "author_email": "Lightstreamer Srl <support@lightstreamer.com>",
    "download_url": "https://files.pythonhosted.org/packages/1e/13/e5943b85a1fdb90d1722ead3eaeef9fe1cc8c8578872e969173f3a95cd5c/lightstreamer-client-lib-2.1.0.tar.gz",
    "platform": null,
    "description": "# Lightstreamer Python Client SDK\n\nLightstreamer Python Client SDK enables any Python application to communicate bidirectionally with a **Lightstreamer Server**. The API allows to subscribe to real-time data pushed by the server and to send any message to the server.\n\nThe library offers automatic recovery from connection failures, automatic selection of the best available transport, and full decoupling of subscription and connection operations. It is responsible of forwarding the subscriptions to the Server and re-forwarding all the subscriptions whenever the connection is broken and then reopened.\n\n## Installation\n\nYou can install the Lightstreamer Client SDK from [PyPI](https://pypi.org/project/lightstreamer-client-lib/):\n\n```\npython -m pip install lightstreamer-client-lib\n```\n\nThe sdk is supported on Python 3.7 and above.\n\n## Quickstart\n\nTo connect to a Lightstreamer Server, a [LightstreamerClient](https://lightstreamer.com/api/ls-python-client/2.1.0/lightstreamer.html#lightstreamer.client.ls_python_client_wrapper.LightstreamerClient) object has to be created, configured, and instructed to connect to the Lightstreamer Server. \nA minimal version of the code that creates a LightstreamerClient and connects to the Lightstreamer Server on *https://push.lightstreamer.com* will look like this:\n\n```python\nfrom lightstreamer.client import *\n\nclient = LightstreamerClient(\"http://push.lightstreamer.com/\",\"DEMO\")\nclient.connect()\n```\n\nFor each subscription to be subscribed to a Lightstreamer Server a [Subscription](https://lightstreamer.com/api/ls-python-client/2.1.0/lightstreamer.html#lightstreamer.client.ls_python_client_wrapper.Subscription) instance is needed.\nA simple Subscription containing three items and two fields to be subscribed in *MERGE* mode is easily created (see [Lightstreamer General Concepts](https://lightstreamer.com/docs/ls-server/latest/General%20Concepts.pdf)):\n\n```python\nsub = Subscription(\"MERGE\",[\"item1\",\"item2\",\"item3\"],[\"stock_name\",\"last_price\"])\nsub.setDataAdapter(\"QUOTE_ADAPTER\")\nsub.setRequestedSnapshot(\"yes\")\nclient.subscribe(sub)\n```\n\nBefore sending the subscription to the server, usually at least one [SubscriptionListener](https://lightstreamer.com/api/ls-python-client/2.1.0/lightstreamer.html#lightstreamer.client.ls_python_client_api.SubscriptionListener) is attached to the Subscription instance in order to consume the real-time updates. The following code shows the values of the fields *stock_name* and *last_price* each time a new update is received for the subscription:\n\n```python\nclass SubListener(SubscriptionListener):\n  def onItemUpdate(self, update):\n    print(\"UPDATE \" + update.getValue(\"stock_name\") + \" \" + update.getValue(\"last_price\"))\n\n  # other methods...\n\nsub.addListener(SubListener())\n```\n\nBelow is the complete Python code:\n\n```python\nfrom lightstreamer.client import *\n\nsub = Subscription(\"MERGE\",[\"item1\",\"item2\",\"item3\"],[\"stock_name\",\"last_price\"])\nsub.setDataAdapter(\"QUOTE_ADAPTER\")\nsub.setRequestedSnapshot(\"yes\")\n\nclass SubListener(SubscriptionListener):\n  def onItemUpdate(self, update):\n    print(\"UPDATE \" + update.getValue(\"stock_name\") + \" \" + update.getValue(\"last_price\"))\n\nsub.addListener(SubListener())\n\nclient = LightstreamerClient(\"http://push.lightstreamer.com\",\"DEMO\")\nclient.subscribe(sub)\nclient.connect()\n```\n\n## Logging\n\nTo enable the internal client logger, create a [LoggerProvider](https://lightstreamer.com/api/ls-python-client/2.1.0/lightstreamer.html#lightstreamer.client.ls_python_client_api.LoggerProvider) and set it as the default provider of [LightstreamerClient](https://lightstreamer.com/api/ls-python-client/2.1.0/lightstreamer.html#lightstreamer.client.ls_python_client_wrapper.LightstreamerClient.setLoggerProvider).\n\n```python\nimport sys, logging\n\nlogging.basicConfig(level=logging.DEBUG, format=\"%(message)s\", stream=sys.stdout)\n\nloggerProvider = ConsoleLoggerProvider(ConsoleLogLevel.DEBUG)\nLightstreamerClient.setLoggerProvider(loggerProvider)\n```\n\n## Compatibility ##\n\nCompatible with Lightstreamer Server since version 7.4.0.\n\n## Documentation\n\n- [Live demos](https://demos.lightstreamer.com/?p=lightstreamer&t=client&lclient=python)\n\n- [API Reference](https://lightstreamer.com/api/ls-python-client/2.1.0/index.html)\n\n## Support\n\nFor questions and support please use the [Official Forum](https://forums.lightstreamer.com/). The issue list of this page is **exclusively** for bug reports and feature requests.\n\n## License\n\n[Apache 2.0](https://opensource.org/licenses/Apache-2.0)\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Lightstreamer Client SDK",
    "version": "2.1.0",
    "project_urls": {
        "Homepage": "https://github.com/Lightstreamer/Lightstreamer-lib-client-haxe"
    },
    "split_keywords": [
        "lightstreamer",
        "push",
        "realtime",
        "real-time"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "10001abb36dfb2a15479153bea1d7df68f3595374c570c3519968d9bce3879a7",
                "md5": "0679d2ec6b6471514992544fbac24a90",
                "sha256": "a7a7ba8f3d5b7e9b9e7f440db5e1e6f7d6be84ddc43cd052f3369c5138ba95f7"
            },
            "downloads": -1,
            "filename": "lightstreamer_client_lib-2.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0679d2ec6b6471514992544fbac24a90",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 116998,
            "upload_time": "2023-12-19T08:39:32",
            "upload_time_iso_8601": "2023-12-19T08:39:32.074593Z",
            "url": "https://files.pythonhosted.org/packages/10/00/1abb36dfb2a15479153bea1d7df68f3595374c570c3519968d9bce3879a7/lightstreamer_client_lib-2.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1e13e5943b85a1fdb90d1722ead3eaeef9fe1cc8c8578872e969173f3a95cd5c",
                "md5": "386fe1eaf7dad72686242ad5ec5b18ff",
                "sha256": "9b06a64074dae744d81ed7c955562b267967980fb5285e125dead6ee92652040"
            },
            "downloads": -1,
            "filename": "lightstreamer-client-lib-2.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "386fe1eaf7dad72686242ad5ec5b18ff",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 115473,
            "upload_time": "2023-12-19T08:39:34",
            "upload_time_iso_8601": "2023-12-19T08:39:34.047483Z",
            "url": "https://files.pythonhosted.org/packages/1e/13/e5943b85a1fdb90d1722ead3eaeef9fe1cc8c8578872e969173f3a95cd5c/lightstreamer-client-lib-2.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-19 08:39:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Lightstreamer",
    "github_project": "Lightstreamer-lib-client-haxe",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "lightstreamer-client-lib"
}
        
Elapsed time: 0.34745s