{"id":37064303,"url":"https://github.com/labthings/python-labthings","last_synced_at":"2026-01-14T07:30:52.004Z","repository":{"id":37103667,"uuid":"234552142","full_name":"labthings/python-labthings","owner":"labthings","description":"Python implementation of LabThings, based on the Flask microframework","archived":false,"fork":false,"pushed_at":"2024-05-15T08:26:54.000Z","size":4130,"stargazers_count":18,"open_issues_count":24,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-10T07:35:30.172Z","etag":null,"topics":["flask-microframework","iot","iot-framework","laboratory","python","webthings"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/labthings.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-17T13:17:19.000Z","updated_at":"2023-05-21T15:40:48.000Z","dependencies_parsed_at":"2023-01-25T17:01:29.102Z","dependency_job_id":null,"html_url":"https://github.com/labthings/python-labthings","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"purl":"pkg:github/labthings/python-labthings","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labthings%2Fpython-labthings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labthings%2Fpython-labthings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labthings%2Fpython-labthings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labthings%2Fpython-labthings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/labthings","download_url":"https://codeload.github.com/labthings/python-labthings/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/labthings%2Fpython-labthings/sbom","scorecard":{"id":576566,"data":{"date":"2025-08-11","repo":{"name":"github.com/labthings/python-labthings","commit":"d228f34e5a3ffc601661c2683923d38564c3dca0"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":1,"reason":"Found 1/6 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/labthings/python-labthings/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/labthings/python-labthings/publish.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/labthings/python-labthings/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:51: update your workflow using https://app.stepsecurity.io/secureworkflow/labthings/python-labthings/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/labthings/python-labthings/publish.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish.yml:61: update your workflow using https://app.stepsecurity.io/secureworkflow/labthings/python-labthings/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/labthings/python-labthings/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/labthings/python-labthings/test.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/labthings/python-labthings/test.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/labthings/python-labthings/test.yml/master?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: GNU General Public License v3.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"32 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2024-48 / GHSA-fj7x-q9j7-g6q6","Warn: Project is vulnerable to: PYSEC-2024-230 / GHSA-248v-346w-9cwc","Warn: Project is vulnerable to: PYSEC-2022-42986 / GHSA-43fp-rhv2-5gv8","Warn: Project is vulnerable to: PYSEC-2023-135 / GHSA-xqr8-7jwr-rhp7","Warn: Project is vulnerable to: PYSEC-2023-62 / GHSA-m2qf-hxjv-5gpq","Warn: Project is vulnerable to: GHSA-43qf-4rqw-9q2g","Warn: Project is vulnerable to: GHSA-7rxf-gvfg-47g4","Warn: Project is vulnerable to: GHSA-84pr-m4jr-85g5","Warn: Project is vulnerable to: GHSA-8vgw-p6qm-5gr7","Warn: Project is vulnerable to: PYSEC-2024-71 / GHSA-hxwh-jpp2-84pm","Warn: Project is vulnerable to: PYSEC-2024-60 / GHSA-jjg7-2v4v-x38h","Warn: Project is vulnerable to: GHSA-cpwx-vrp4-4pq7","Warn: Project is vulnerable to: GHSA-h5c8-rqwp-cp95","Warn: Project is vulnerable to: GHSA-h75v-3vvj-5mfj","Warn: Project is vulnerable to: GHSA-q2x7-8rv6-6q7h","Warn: Project is vulnerable to: PYSEC-2022-42969","Warn: Project is vulnerable to: PYSEC-2023-117 / GHSA-mrwq-x4v8-fh7p","Warn: Project is vulnerable to: GHSA-9hjg-9r4m-mvj7","Warn: Project is vulnerable to: GHSA-9wx4-h78v-vm56","Warn: Project is vulnerable to: PYSEC-2023-74 / GHSA-j8r2-6x86-q33q","Warn: Project is vulnerable to: GHSA-34jh-p97f-mpxf","Warn: Project is vulnerable to: PYSEC-2023-212 / GHSA-g4mx-q9vg-27p4","Warn: Project is vulnerable to: GHSA-pq67-6m6q-mj2v","Warn: Project is vulnerable to: PYSEC-2023-192 / GHSA-v845-jxx5-vc9f","Warn: Project is vulnerable to: GHSA-2g68-c3qc-8985","Warn: Project is vulnerable to: GHSA-f9vj-2wh5-fj8j","Warn: Project is vulnerable to: PYSEC-2023-221 / GHSA-hrfv-mqp8-q5rw","Warn: Project is vulnerable to: PYSEC-2023-57 / GHSA-px8h-6qxv-m22q","Warn: Project is vulnerable to: GHSA-q34m-jh98-gwm2","Warn: Project is vulnerable to: PYSEC-2023-58 / GHSA-xg9f-g7g7-2323","Warn: Project is vulnerable to: PYSEC-2022-203","Warn: Project is vulnerable to: GHSA-jfmj-5v4g-7637"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T17:57:46.680Z","repository_id":37103667,"created_at":"2025-08-20T17:57:46.680Z","updated_at":"2025-08-20T17:57:46.680Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28413319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["flask-microframework","iot","iot-framework","laboratory","python","webthings"],"created_at":"2026-01-14T07:30:51.320Z","updated_at":"2026-01-14T07:30:51.980Z","avatar_url":"https://github.com/labthings.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python LabThings (for Flask)\r\n\r\n[![LabThings](https://img.shields.io/badge/-LabThings-8E00FF?style=flat\u0026logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz4NCjxzdmcgY2xpcC1ydWxlPSJldmVub2RkIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS1taXRlcmxpbWl0PSIyIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAxNjMgMTYzIiB4bWw6c3BhY2U9InByZXNlcnZlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Im0xMjIuMjQgMTYyLjk5aDQwLjc0OHYtMTYyLjk5aC0xMDEuODd2NDAuNzQ4aDYxLjEyMnYxMjIuMjR6IiBmaWxsPSIjZmZmIi8+PHBhdGggZD0ibTAgMTIuMjI0di0xMi4yMjRoNDAuNzQ4djEyMi4yNGg2MS4xMjJ2NDAuNzQ4aC0xMDEuODd2LTEyLjIyNGgyMC4zNzR2LTguMTVoLTIwLjM3NHYtOC4xNDloOC4wMTl2LTguMTVoLTguMDE5di04LjE1aDIwLjM3NHYtOC4xNDloLTIwLjM3NHYtOC4xNWg4LjAxOXYtOC4xNWgtOC4wMTl2LTguMTQ5aDIwLjM3NHYtOC4xNWgtMjAuMzc0di04LjE0OWg4LjAxOXYtOC4xNWgtOC4wMTl2LTguMTVoMjAuMzc0di04LjE0OWgtMjAuMzc0di04LjE1aDguMDE5di04LjE0OWgtOC4wMTl2LTguMTVoMjAuMzc0di04LjE1aC0yMC4zNzR6IiBmaWxsPSIjZmZmIi8+PC9zdmc+DQo=)](https://github.com/labthings/)\r\n[![ReadTheDocs](https://readthedocs.org/projects/python-labthings/badge/?version=latest\u0026style=flat)](https://python-labthings.readthedocs.io/en/latest/)\r\n[![PyPI](https://img.shields.io/pypi/v/labthings)](https://pypi.org/project/labthings/)\r\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\r\n[![codecov](https://codecov.io/gh/labthings/python-labthings/branch/master/graph/badge.svg)](https://codecov.io/gh/labthings/python-labthings)\r\n[![Riot.im](https://img.shields.io/badge/chat-on%20riot.im-368BD6)](https://riot.im/app/#/room/#labthings:matrix.org)\r\n\r\nA thread-based Python implementation of the LabThings API structure, based on the Flask microframework.\r\n\r\n## Installation\r\n\r\n`pip install labthings`\r\n\r\n## Quickstart example\r\n\r\nThis example assumes a `PretendSpectrometer` class, which already has `data` and `integration_time` attributes, as well as an `average_data(n)` method. LabThings allows you to easily convert this existing instrument control code into a fully documented, standardised web API complete with auto-discovery and automatic background task threading.\r\n\r\n```python\r\n#!/usr/bin/env python\r\nimport time\r\n\r\nfrom labthings import ActionView, PropertyView, create_app, fields, find_component, op\r\nfrom labthings.example_components import PretendSpectrometer\r\nfrom labthings.json import encode_json\r\n\r\n\"\"\"\r\nClass for our lab component functionality. This could include serial communication,\r\nequipment API calls, network requests, or a \"virtual\" device as seen here.\r\n\"\"\"\r\n\r\n\r\n\"\"\"\r\nCreate a view to view and change our integration_time value,\r\nand register is as a Thing property\r\n\"\"\"\r\n\r\n\r\n# Wrap in a semantic annotation to automatically set schema and args\r\nclass DenoiseProperty(PropertyView):\r\n    \"\"\"Value of integration_time\"\"\"\r\n\r\n    schema = fields.Int(required=True, minimum=100, maximum=500)\r\n    semtype = \"LevelProperty\"\r\n\r\n    @op.readproperty\r\n    def get(self):\r\n        # When a GET request is made, we'll find our attached component\r\n        my_component = find_component(\"org.labthings.example.mycomponent\")\r\n        return my_component.integration_time\r\n\r\n    @op.writeproperty\r\n    def put(self, new_property_value):\r\n        # Find our attached component\r\n        my_component = find_component(\"org.labthings.example.mycomponent\")\r\n\r\n        # Apply the new value\r\n        my_component.integration_time = new_property_value\r\n\r\n        return my_component.integration_time\r\n\r\n\r\n\"\"\"\r\nCreate a view to quickly get some noisy data, and register is as a Thing property\r\n\"\"\"\r\n\r\n\r\nclass QuickDataProperty(PropertyView):\r\n    \"\"\"Show the current data value\"\"\"\r\n\r\n    # Marshal the response as a list of floats\r\n    schema = fields.List(fields.Float())\r\n\r\n    @op.readproperty\r\n    def get(self):\r\n        # Find our attached component\r\n        my_component = find_component(\"org.labthings.example.mycomponent\")\r\n        return my_component.data\r\n\r\n\r\n\r\n\"\"\"\r\nCreate a view to start an averaged measurement, and register is as a Thing action\r\n\"\"\"\r\n\r\n\r\nclass MeasurementAction(ActionView):\r\n    # Expect JSON parameters in the request body.\r\n    # Pass to post function as dictionary argument.\r\n    args = {\r\n        \"averages\": fields.Integer(\r\n            missing=20, example=20, description=\"Number of data sets to average over\",\r\n        )\r\n    }\r\n    # Marshal the response as a list of numbers\r\n    schema = fields.List(fields.Number)\r\n\r\n    # Main function to handle POST requests\r\n    @op.invokeaction\r\n    def post(self, args):\r\n        \"\"\"Start an averaged measurement\"\"\"\r\n\r\n        # Find our attached component\r\n        my_component = find_component(\"org.labthings.example.mycomponent\")\r\n\r\n        # Get arguments and start a background task\r\n        n_averages = args.get(\"averages\")\r\n\r\n        # Return the task information\r\n        return my_component.average_data(n_averages)\r\n\r\n\r\n# Create LabThings Flask app\r\napp, labthing = create_app(\r\n    __name__,\r\n    title=\"My Lab Device API\",\r\n    description=\"Test LabThing-based API\",\r\n    version=\"0.1.0\",\r\n)\r\n\r\n# Attach an instance of our component\r\n# Usually a Python object controlling some piece of hardware\r\nmy_spectrometer = PretendSpectrometer()\r\nlabthing.add_component(my_spectrometer, \"org.labthings.example.mycomponent\")\r\n\r\n\r\n# Add routes for the API views we created\r\nlabthing.add_view(DenoiseProperty, \"/integration_time\")\r\nlabthing.add_view(QuickDataProperty, \"/quick-data\")\r\nlabthing.add_view(MeasurementAction, \"/actions/measure\")\r\n\r\n\r\n# Start the app\r\nif __name__ == \"__main__\":\r\n    from labthings import Server\r\n\r\n    Server(app).run()\r\n```\r\n\r\n## Acknowledgements\r\n\r\nMuch of the code surrounding default response formatting has been liberally taken from [Flask-RESTful](https://github.com/flask-restful/flask-restful). The integrated [Marshmallow](https://github.com/marshmallow-code/marshmallow) support was inspired by [Flask-Marshmallow](https://github.com/marshmallow-code/flask-marshmallow) and [Flask-ApiSpec](https://github.com/jmcarp/flask-apispec). \r\n\r\n## Developer notes\r\n\r\n### Changelog generation\r\n\r\n* `npm install -g conventional-changelog-cli`\r\n* `npx conventional-changelog -r 1 --config ./changelog.config.js -i CHANGELOG.md -s`\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabthings%2Fpython-labthings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flabthings%2Fpython-labthings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flabthings%2Fpython-labthings/lists"}