{"_id":"55b2427f7f5e073900ea81f0","__v":7,"project":"55a47338e75ca60d00a3932f","category":{"_id":"55b2426a0e11590d008f7950","version":"55a47338e75ca60d00a39332","__v":4,"project":"55a47338e75ca60d00a3932f","pages":["55b2427f7f5e073900ea81f0","55b253d054aba20d001d513b","55b2543f88093a21008beeb0","55b254de54aba20d001d5143"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-07-24T13:49:30.940Z","from_sync":false,"order":4,"slug":"python-api","title":"Python API"},"user":"55a4f13d02b09d1900d00a9f","version":{"_id":"55a47338e75ca60d00a39332","project":"55a47338e75ca60d00a3932f","__v":8,"createdAt":"2015-07-14T02:26:00.724Z","releaseDate":"2015-07-14T02:26:00.724Z","categories":["55a47339e75ca60d00a39333","55a4fb7e1a5f991700a940f0","55a6702b80c8a30d00b32684","55a6703b80c8a30d00b32685","55a6ea5516d20b1900ed8f53","55b23ad2329f363900fbc92f","55b23b0a329f363900fbc932","55b2426a0e11590d008f7950"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-07-24T13:49:51.214Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"If you haven't read [Getting Started](/docs/getting-started), we'd suggest reading that first.\n\nWant to control your Lono with Python? The easiest way is probably with our Lono module!\n\nOur Module\n---\nOur module is at [https://pypi.python.org/pypi/lono](//pypi.python.org/pypi/lono). You can install it with `pip install lono`.\n\nSingle User Application Example\n---\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"from lono import LonoClient\\n\\n# lets set up the api with all the relevant info\\nlc = LonoClient(\\n    client_id=\\\"client id\\\",\\n    client_secret=\\\"client secret\\\",\\n    auth_token=\\\"auth token\\\",\\n    scope=[\\\"write\\\"]\\n)\\n\\n# turn on the first zone\\ndevice = lc.get_device(\\\"device id\\\")\\nprint \\\"Turn on zone:\\\", device.set_zone(zone_id, True)\\n\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\nMulti User Application Example\n---\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"from lono import LonoClient\\n\\n# lets set up the api with all the relevant info\\nlc = LonoClient(\\n    client_id=\\\"client id\\\",\\n    client_secret=\\\"client secret\\\",\\n    scope=[\\\"write\\\"]\\n)\\n\\n# step one: redirect users here to sign in and give your app permission\\nauth_url = lc.authorize_url(\\\"http://on_success_redirect_here.com\\\")\\n\\n# step two: once the OAuth2 callback is received, specify the token\\nlc.save_token(\\\"auth token\\\")\\n\\n# turn on the first zone\\ndevice = lc.get_device(\\\"device id\\\")\\nprint \\\"Turn on zone:\\\", device.set_zone(zone_id, True)\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"getting-started-python","type":"basic","title":"Getting Started in Python"}

Getting Started in Python


If you haven't read [Getting Started](/docs/getting-started), we'd suggest reading that first. Want to control your Lono with Python? The easiest way is probably with our Lono module! Our Module --- Our module is at [https://pypi.python.org/pypi/lono](//pypi.python.org/pypi/lono). You can install it with `pip install lono`. Single User Application Example --- [block:code] { "codes": [ { "code": "from lono import LonoClient\n\n# lets set up the api with all the relevant info\nlc = LonoClient(\n client_id=\"client id\",\n client_secret=\"client secret\",\n auth_token=\"auth token\",\n scope=[\"write\"]\n)\n\n# turn on the first zone\ndevice = lc.get_device(\"device id\")\nprint \"Turn on zone:\", device.set_zone(zone_id, True)\n", "language": "python" } ] } [/block] Multi User Application Example --- [block:code] { "codes": [ { "code": "from lono import LonoClient\n\n# lets set up the api with all the relevant info\nlc = LonoClient(\n client_id=\"client id\",\n client_secret=\"client secret\",\n scope=[\"write\"]\n)\n\n# step one: redirect users here to sign in and give your app permission\nauth_url = lc.authorize_url(\"http://on_success_redirect_here.com\")\n\n# step two: once the OAuth2 callback is received, specify the token\nlc.save_token(\"auth token\")\n\n# turn on the first zone\ndevice = lc.get_device(\"device id\")\nprint \"Turn on zone:\", device.set_zone(zone_id, True)", "language": "python" } ] } [/block]