{"id":18311622,"url":"https://github.com/dlove24/urest","last_synced_at":"2025-09-13T15:05:46.880Z","repository":{"id":65207580,"uuid":"584753772","full_name":"dlove24/urest","owner":"dlove24","description":"Micro REST HTTP Server","archived":false,"fork":false,"pushed_at":"2024-09-05T13:26:41.000Z","size":455,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"trunk","last_synced_at":"2025-06-30T14:52:54.217Z","etag":null,"topics":["http","micropython","rest"],"latest_commit_sha":null,"homepage":"https://urest.readthedocs.io","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/dlove24.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":null,"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":"2023-01-03T12:35:55.000Z","updated_at":"2024-09-05T13:25:26.000Z","dependencies_parsed_at":"2024-04-11T08:46:35.271Z","dependency_job_id":"95892b72-1ad7-4f5e-abf9-88c8aaa99c4d","html_url":"https://github.com/dlove24/urest","commit_stats":{"total_commits":35,"total_committers":2,"mean_commits":17.5,"dds":0.02857142857142858,"last_synced_commit":"e80f414c6a8b25ba7e7e2c678c8e754c58676391"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dlove24/urest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlove24%2Furest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlove24%2Furest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlove24%2Furest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlove24%2Furest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dlove24","download_url":"https://codeload.github.com/dlove24/urest/tar.gz/refs/heads/trunk","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlove24%2Furest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274045977,"owners_count":25212978,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"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":["http","micropython","rest"],"created_at":"2024-11-05T16:18:49.337Z","updated_at":"2025-09-13T15:05:46.842Z","avatar_url":"https://github.com/dlove24.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"uREST\n=====\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![PyPI version](https://badge.fury.io/py/urest-mp.svg)](https://badge.fury.io/py/urest-mp)\n[![Documentation Status](https://readthedocs.org/projects/urest/badge/?version=latest)](https://urest.readthedocs.io/en/latest/?badge=latest)\n\nBackground\n----------\n\nThis library is designed to enable simple API's to be built on\nmicro-controllers, based on a sub-set of the REST API design principles, and\ninspired by the design of the [Apollo\nDSKY](https://history-computer.com/apollo-guidance-computer/) guidance computer.\nRather than build a full HTTP server stack, including JSON parser, and\nsupporting the full complexity of modern REST API's, this library aims to\nsupport simple operations in a resource constrained environment.\n\nLike the DSKY unit, it is assumed that all the 'objects' representing the states\nwe are interested in are held in\n'[nouns](https://dlove24.github.io/urest/urest/api/base.html)'. The HTTP actions\nthen represent 'verbs' which dictate the actions on the noun. So each API call\nis then in the form of 'verb-noun'; e.g. 'GET /led', or 'PUT /led'. Valid verb\nactions are\n\n| Verb   | HTTP Method | Action                                                                                                                                                            |\n|--------|-------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Get    | `GET`       | Return the current state of the requested noun.                                                                                                                   |\n| Set    | `PUT`       | Set the requested noun to *exactly* the specified state. This is assumed to be idempotent, with the resultant state matching exactly the request from the client. |\n| Update | `POST`      | Update the state requested noun. This is *not* assumed to be idempotent: for instance asking a noun to move between two states on each update.                    |\n| Delete | `DELETE`    | Remove the current state of the noun, and return to a the default state. This does *not* remove the noun from the API: only the state currently held by the API.  |\n\nIn all cases the body of the HTTP request is a simple collection of 'key: value'\npairs, formatted as a [JSON](https://www.json.org/json-en.html) object. Only a\nsub-set of the JSON specification is used: in particular multiple objects are\nnot allowed, and nor are arrays (i.e. '`[]`') of any sort. This both simplifies\nthe parsing, and especially the memory required for the parser, and reinforces\nthe intent to support only minimal API's.\n\nInstallation\n------------\n\nA package of this library is provided on PyPi as\n[`urest-mp`](https://pypi.org/project/urest-mp/). This can be installed with the\nnormal Python tools, and should also install to boards runnning MicroPython\nunder [Thonny](https://thonny.org/).\n\nFor manual installation, everything under the `urest` directory should be copied\nto the appropriate directory on the MicroPython board, usually `/lib`. The\nlibrary can then be imported as normal, e.g.\n\n```python from urest.http import RESTServer from urest.api import APIBase ```\n\nSee the documentation for the\n[examples](https://dlove24.github.io/urest/urest/examples/index.html) for more\ndetailed guidance on the use of the library. This code is also available in the\n`urest/examples` folder, or as the library `urest.examples` when the package is\ninstalled.\n\nDebugging\n---------\n\nConsole output from the `urest.http.server.RESTServer` is controlled by the\nstandard `__debug__` flag. By default no output will be sent to the 'console'\n_unless_ the `__debug__` flag is `True`.\n\n**Note:** that in the standard Python environments the status of the `__debug__`\nflag is often controlled by the optimisation level of the interpreter: see the\nstandard [Python documentation](https://docs.python.org/3/using/cmdline.html#cmdoption-O)\nfor more details. For MicroPython the status of the `__debug__` flag is set by\n[internal constants](https://docs.micropython.org/en/latest/library/micropython.html#micropython.opt_level).\nHowever if the `__debug__` constant is set whilst a programming is running the\n[results may be unexpected](https://forum.micropython.org/viewtopic.php?t=6839),\ndue to optimisations undertaken by the MicroPython lexer. Instead for MicroPython set\nthe status of the `__debug__` flag in the platform standard `boot.py` or\nsimilar: see the documentation for the specific port for more details.\n\nDesign\n------\n\nThe core of the library is a simple HTTP server, specialised to the delivery of\na REST-like API instead of a general HTTP server. The design, and the use of the\n`asyncio` library, is inspired by the [MicroPython HTTP\nServer](https://github.com/erikdelange/MicroPython-HTTP-Server) by Erik de\nLange. This library uses a roughly similar structure for the core of the\n`asyncio` event loop, and especially in the design of the\n[`RESTServer`](https://dlove24.github.io/urest/urest/http/server.html) class.\n\nKey differences include\n\n*   Support for `PUT`, `POST` and `DELETE` operations, in addition to `GET`.\nThese are required for an API server, and also form the 'verbs' of the actions\nallowed on the 'nouns' by the API built on-top of this library.\n\n*   A more object-oriented design of the call/response handler, made easier this\nlibrary is *not* a general HTTP server. For instance Python `getters` and\n`setters` are used where possible for input validation, and the central API\nresponse is based on the\n[`APIBase`](https://dlove24.github.io/urest/urest/api/base.html) abstract base\nclass\n\n*   A more explicit validation of input from the network layer, especially in\nthe assumption that all input is by default hostile. This library should serve\nas an example of best-practice in protocol handling; at least in the slightly\nresource constrained environment of MicroPython\n\n*   This implementation is principally a teaching library, so the\n[Documentation](https://dlove24.github.io/urest/urest) should be at least as\nimportant as the 'code'. Where possible all algorithms and implementation\ntechniques should also be explained as fully as possible, or at least linked to\nreference standards/implementations\n\n*   For consistency, all code should also be in the format standardised by the\n[Black](https://github.com/psf/black) library. This makes it easier to\nco-ordinate external code and documentation with the implementation documented\nhere.\n\nKnown Implementations\n---------------------\n\n*   Raspberry Pi Pico W (MicroPython 3.4)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlove24%2Furest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdlove24%2Furest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlove24%2Furest/lists"}