{"id":25731177,"url":"https://github.com/zetapush/zetapush-python","last_synced_at":"2026-06-15T11:31:32.876Z","repository":{"id":84808096,"uuid":"110113307","full_name":"zetapush/zetapush-python","owner":"zetapush","description":"Python SDK for ZetaPush","archived":false,"fork":false,"pushed_at":"2017-12-11T17:42:47.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-02-26T02:37:39.716Z","etag":null,"topics":["python","zetapush"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zetapush.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-09T12:35:31.000Z","updated_at":"2018-06-25T09:03:35.000Z","dependencies_parsed_at":"2023-03-05T02:30:32.927Z","dependency_job_id":null,"html_url":"https://github.com/zetapush/zetapush-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zetapush/zetapush-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetapush%2Fzetapush-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetapush%2Fzetapush-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetapush%2Fzetapush-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetapush%2Fzetapush-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zetapush","download_url":"https://codeload.github.com/zetapush/zetapush-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zetapush%2Fzetapush-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34358702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","zetapush"],"created_at":"2025-02-26T02:37:06.448Z","updated_at":"2026-06-15T11:31:32.871Z","avatar_url":"https://github.com/zetapush.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# ZetaPush SDK #\n\nThis module is a SDK to connect to the ZetaPush platform with Python. (Only with Python3)\n\n## Installation\n\npip3 install zetapush_python\n\n## Usage\n\n### Imports\n\nFirst, we need to import 2 objets to use the ZetaPush SDK :\n\n - Client\n - Service\n\nThe `Client` is used to handle the connection with the ZetaPush backend and the `Service` is used to call services from the client. In particular, the service to call macroscripts.\n\nTo import them we write :\n\n\tfrom zetapush_python import Client\n\tfrom zetapush_python import Service\n\t\n\n### Connection to ZetaPush backend\n\nFirst, we need the create the `Client` to handle the connection :\n\n\tzpClient = Client(businessId=\"Rj7PY_1I\", apiUrl=\"http://demo-1.zpush.io/zbo/pub/business/\")\n\n\t\nThe *businessId* is the identifier of the sandbox in the ZetaPush back-end. For ZetaPush, a sandbox includes the whole application back-end. Then, we have the *apiUrl*. It is optional in production. During the development we send you the apiUrl if necessary.\n\nNow, we need to launch the connection with our credentials. For this example we use this credentials :\n\n - login : \"user\"\n - password: \"password\"\n\n\t\tzpClient.connect(login=\"user\", password=\"password\")\n\nIf we want to connect to the ZetaPush platform as Weak connection, we need to **don't** send the *login* and *password* parameters. By default, the SDK use the authentication service named *weak_0*.\n\n#### Set the authentication service\n\nIf we need to set the authentication service name, we can write the parameter *authenticationService*. In this case we need also to write the parameter *authenticationType* to define the type of authentication we use. ('simple' or 'weak').\n\nFor example we can write :\n\n\tzpClient.connect(authenticationService=\"simple_1\", authenticationType=\"simple\")\n\n#### Callback connection\n\nIt is useful to launch a function when the connection is established.\nFor this we implement the *onConnectionSuccess()* method :\n\n\t\n\tdef onConnectionSuccess():\n\t\tprint(\"OnConnectionSuccess\")\n\t\n\tzpClient.onConnectionSuccess = onConnectionSuccess\n\n\n\n### Call a macroscript\n\nIn this step, we call a macroscript. For this, we need to configure a service that manage the macroscript calls.\n\n\tserviceMacro = Service(\"macro_0\", zpClient)\n\nHere *macro_0* is the *deployment ID* of our macroscript service. By default we use *macro_0*.\n*zpClient* is our Client that we previously create.\n\nIn our example, we want to call a macroscript named **test** that takes 2 parameters *num1* and *num2*. The macroscript return the sum of *num1* and *num2* in a object named *result*.\n\nTo call the macroscript we use :\n\t\n\tserviceMacro.send('test', { 'num1': 3, 'num2': 5})\n\nTo listen the result we need to define a function and affect it to the result :\n\n\t\n\tdef handleTest(params):\n\t\tprint(\"result =\u003e \", params['result']\n\n\t\n\tserviceMacro.on('test', handleTest)\n\n\n\n### Stop the communication with ZetaPush\n\nTo disconnect an user to the ZetaPush platform we can use :\n\n\tzpClient.disconnect()\n\nThen, it is necessary to properly close the communication with the ZetaPush backend at the end of the program. For this we use :\n\n\tzpClient.stopZPConnection()\n\n### Send JSON in macro\n\nWe can also send JSON in a macroscript.\n\nIn our example we have a macroscript named *testJson(name, data)* that have 2 parameters :\n\n - name : String\n - data : Map (or JSON)\n\nWe can call this macroscript with this syntax :\n\n\t\n\tserviceMacro.send('testJson', { 'name': 'sensor1', 'data': { 'value': 15, 'unit': 'ppm' }} )\n\t\n\n## Complete example\n\n\nHere we have a complete example that launch a connection to the ZetaPush platform, call a macroscript named *test*, print his result and close the communication after few seconds :\n\n\n\tfrom zetapush_python import Client\n\tfrom zetapush_python import Service\n\timport time\n\t\n\t# Create the Client to handle the connection with ZetaPush \n\tzpClient = Client(businessId=\"Rj7PY_1I\", apiUrl=\"http://demo-1.zpush.io/zbo/pub/business/\")\n\t\n\t# We create the macro service\n\tserviceMacro = Service(\"macro_0\", zpClient)\n\t\n\t# Define a function that will be called when the connection is established\n\tdef onConnectionSuccessful():\n\t    print(\"ZetaPush::ConnectionSuccess\")\n\t\n\t    # We call the macroscript 'send'\n\t    serviceMacro.send('test', { 'num1': 3, 'num2': 5})\n\t\n\t# We define a function called when the macroscript \"test\" return us a result\n\tdef handleTest(params):\n\t    print(\"result =\u003e \", params['result'])\n\t\n\t\n\t# Affect a function that will be called when the connection is established\n\tzpClient.onConnectionSuccess = onConnectionSuccessful\n\t\n\t# We affect a function to handle the result of the 'test' macroscript\n\tserviceMacro.on('test', handleTest)\n\t\n\t# Launch the connection with our credentials\n\tzpClient.connect(login= \"user\", password= \"password\")\n\t\n\t# Pause the program during 2 secondes\n\ttime.sleep(2)\n\t\n\t# Properly close the communication with ZetaPush\n\tzpClient.stopZPConnection()\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzetapush%2Fzetapush-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzetapush%2Fzetapush-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzetapush%2Fzetapush-python/lists"}