{"id":13605133,"url":"https://github.com/jczic/MicroRESTCli","last_synced_at":"2025-04-12T02:32:47.117Z","repository":{"id":55734228,"uuid":"106232042","full_name":"jczic/MicroRESTCli","owner":"jczic","description":"A micro JSON REST Web client based on MicroWebCli for MicroPython (used on Pycom modules \u0026 ESP32)","archived":false,"fork":false,"pushed_at":"2020-12-12T19:48:19.000Z","size":74,"stargazers_count":29,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-03T04:33:23.626Z","etag":null,"topics":["authentication","datetimes","download","esp32","files","hc2","http","https","json","lopy","micropython","pycom","rest","rest-client","restclient","restful-client","ssl","wipy"],"latest_commit_sha":null,"homepage":"https://microrestcli.hc2.fr","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/jczic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-09T03:21:09.000Z","updated_at":"2023-07-11T11:44:29.000Z","dependencies_parsed_at":"2022-08-15T06:40:31.040Z","dependency_job_id":null,"html_url":"https://github.com/jczic/MicroRESTCli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jczic%2FMicroRESTCli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jczic%2FMicroRESTCli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jczic%2FMicroRESTCli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jczic%2FMicroRESTCli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jczic","download_url":"https://codeload.github.com/jczic/MicroRESTCli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248506928,"owners_count":21115509,"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","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":["authentication","datetimes","download","esp32","files","hc2","http","https","json","lopy","micropython","pycom","rest","rest-client","restclient","restful-client","ssl","wipy"],"created_at":"2024-08-01T19:00:55.004Z","updated_at":"2025-04-12T02:32:46.885Z","avatar_url":"https://github.com/jczic.png","language":"Python","readme":"## MicroRESTCli is a micro HTTP JSON REST Web client based on [MicroWebCli](http://microwebcli.hc2.fr) for MicroPython (used on ESP32 and [Pycom](http://www.pycom.io) modules)\n\n![HC²](hc2.png \"HC²\")\n\nVery easy to integrate and very light with 2 files only :\n- `\"microRESTCli.py\"` - The REST client\n- `\"microWebCli.py\"` - The base Web client ([available here](http://microwebcli.hc2.fr))\n\nSimple but effective :\n- Use it to requesting fastly HTTP JSON REST endpoints (Web APIs)\n- Supports secured connections *SSL/TLS over HTTP* (https)\n- Supports authentications *HTTP Basic* and *Bearer Token*\n- Automatically bounces on HTTP(S) redirections (ressources moved)\n- Adds helpers to convert datetime formats between timestamp and json\n- Coulds save to a file the response content of any REST request\n\n### Using *microRESTCli* main class :\n\n| Name  | Function |\n| - | - |\n| Constructor | `rCli = MicroRESTCli(baseUrl, user=None, password=None, token=None)` |\n| Makes a GET request | `rCli.GET(resUrl, fileToSave=None, progressCallback=None)` |\n| Makes a POST request | `rCli.POST(resUrl, o, fileToSave=None, progressCallback=None)` |\n| Makes a PUT request | `rCli.PUT(resUrl, o, fileToSave=None, progressCallback=None)` |\n| Makes a PATCH request | `rCli.PATCH(resUrl, o, fileToSave=None, progressCallback=None)` |\n| Makes a DELETE request | `rCli.DELETE(resUrl, fileToSave=None, progressCallback=None)` |\n| Gets status code of last call | `rCli.GetLastStatusCode()` |\n| Gets status message of last call | `rCli.GetLastStatusMessage()` |\n| Gets json response object of last call | `rCli.GetLastJSONResponse()` |\n\n| Name  | Property |\n| - | - |\n| Gets or sets the connection timeout in secondes | `rCli.ConnTimeoutSec` |\n| Gets or sets the dict headers of http requests | `rCli.Headers` |\n\n### Simple example :\n```python\nfrom microRESTCli import MicroRESTCli\n\nrCli = MicroRESTCli('https://my-web-api.io/rest', user='toto', password='blah123')\n\ninvoice = rCli.GET('invoice/%d' % 42)\n\ntry :\n  u = { 'name':'geek', 'age':18 }\n  resp = rCli.POST('user', u)\n  print('User added')\nexcept :\n  err = rCli.GetLastJSONResponse()\n  if err :\n    print(\"%s API request failed (%s)\" % (err.name, err.reason))\n```\n\n### Example of saving response to a file :\n```python\nfrom microRESTCli import MicroRESTCli\n\ndef progressCallback(microWebCli, progressSize, totalSize) :\n  if totalSize :\n    print('Progress: %d bytes of %d downloaded...' % (progressSize, totalSize))\n  else :\n    print('Progress: %d bytes downloaded...' % progressSize)\n\nrCli        = MicroRESTCli('https://my-web-api.io/rest', token='jIud87jzIsUzj3=')\nfilename    = '/flash/invoice.pdf'\ncontentType = rCli.GET('invoice/%d/pdf' % 42, filename, progressCallback)\nprint('File of type \"%s\" saved to \"%s\"' % (contentType, filename))\n```\n\n### Using *microRESTCli* helpers :\n\n| Name  | Function |\n| - | - |\n| Converts timestamp to json datetime | `MicroRESTCli.Timestamp2JsonDT(timestamp=None)` |\n| Converts json datetime to timestamp | `MicroRESTCli.JsonDT2Timestamp(jsonDT)` |\n\n\n### By JC`zic for [HC²](https://www.hc2.fr) ;')\n\n*Keep it simple, stupid* :+1:\n","funding_links":[],"categories":["Libraries","Networking"],"sub_categories":["Communications"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjczic%2FMicroRESTCli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjczic%2FMicroRESTCli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjczic%2FMicroRESTCli/lists"}