{"id":37083408,"url":"https://github.com/meeshkan/py-http-types","last_synced_at":"2026-01-14T10:10:26.878Z","repository":{"id":62569694,"uuid":"226833149","full_name":"meeshkan/py-http-types","owner":"meeshkan","description":"Python library for JSON serialisation of HTTP exchanges.","archived":true,"fork":false,"pushed_at":"2020-08-25T10:55:57.000Z","size":254,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-28T05:27:07.206Z","etag":null,"topics":["http","http-types","json","python"],"latest_commit_sha":null,"homepage":"https://meeshkan.github.io/http-types/","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/meeshkan.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}},"created_at":"2019-12-09T09:25:34.000Z","updated_at":"2025-06-24T18:26:36.000Z","dependencies_parsed_at":"2022-11-03T17:01:09.798Z","dependency_job_id":null,"html_url":"https://github.com/meeshkan/py-http-types","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/meeshkan/py-http-types","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeshkan%2Fpy-http-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeshkan%2Fpy-http-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeshkan%2Fpy-http-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeshkan%2Fpy-http-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meeshkan","download_url":"https://codeload.github.com/meeshkan/py-http-types/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeshkan%2Fpy-http-types/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28416634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["http","http-types","json","python"],"created_at":"2026-01-14T10:10:26.017Z","updated_at":"2026-01-14T10:10:26.871Z","avatar_url":"https://github.com/meeshkan.png","language":"Python","readme":"# HTTP Types in Python\n\n[![CircleCI](https://circleci.com/gh/meeshkan/py-http-types.svg?style=shield)](https://circleci.com/gh/meeshkan/py-http-types)\n[![PyPi](https://img.shields.io/pypi/pyversions/http-types)](https://pypi.org/project/http-types/)\n[![License](https://img.shields.io/pypi/l/http-types)](LICENSE)\n\nPython (3.6 or later) library to read and write records of HTTP exchanges in the [HTTP types](https://meeshkan.github.io/http-types/) format.\n\n## Installation\n\n```bash\npip install http-types\n```\n\n## Writing HTTP exchanges\n\nUsing `HttpExchangeWriter`a recording of HTTP traffic can be serialised for use with any program that can handle the HTTP Types format:\n\n```python\nrequest = RequestBuilder.from_dict({\n        \"host\": \"api.github.com\",\n        \"protocol\": \"https\",\n        \"method\": \"get\",\n        \"pathname\": \"/v1/users\",\n        \"query\": {\"a\": \"b\", \"q\": [\"1\", \"2\"]},\n    }\n)\n\nresponse = ResponseBuilder.from_dict({\n        \"statusCode\": 200,\n        \"headers\": {\"content-type\": \"text/plain\"},\n        \"body\": \"(response body string)\",\n    }\n)\n\nexchange = HttpExchange(request=request, response=response)\n\nwith tempfile.TemporaryFile(mode=\"w\") as output:\n    writer = HttpExchangeWriter(output)\n    writer.write(exchange)\n\n# Serialize to dictionary\nas_dict = HttpExchangeWriter.to_dict(exchange)\n# Serialize to JSON string\nas_str = HttpExchangeWriter.to_json(exchange)\n```\n\n## Reading HTTP exchanges\n\nWith `HttpExchangeReader` recordings in the HTTP Types format can be read for processing:\n\n```python\nfor exchange in HttpExchangeReader.from_jsonl(input_file):\n    assert exchange.request.method == HttpMethod.GET\n    assert exchange.request.protocol == Protocol.HTTPS\n    assert exchange.response.statusCode == 200\n```\n\n## Development\n\nInitial setup:\n\n1. Create a new virtual environment.\n1. Install dependencies: `pip install --upgrade -e '.[dev]'`\n\nTo test, run `python setup.py test`, which will:\n\n- Enforce code formatting using [black](https://black.readthedocs.io/en/stable/).\n- Test with `pytest`, configured in [pytest.ini](./pytest.ini).\n- Type check with `mypy`.\n- Enforce style guide with [flake8](https://flake8.pycqa.org/en/latest/), configured in [.flake8](./.flake8).\n\n## Publishing\n\n1. Bump the version in [setup.py](./setup.py) if the version is the same as in the published [package](https://pypi.org/project/http-types/). Commit and push.\n1. Run `python setup.py test` and `python setup.py dist` to check that everything works.\n1. To build and upload the package, run `python setup.py upload`. Insert PyPI credentials to upload the package to `PyPI`. The command will also run `git tag` to tag the commit as a release and push the tags to remote.\n\nTo see what the different commands do, see `Command` classes in [setup.py](./setup.py).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeeshkan%2Fpy-http-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeeshkan%2Fpy-http-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeeshkan%2Fpy-http-types/lists"}