{"id":21578710,"url":"https://github.com/julian-nash/httpz","last_synced_at":"2025-03-18T07:32:17.636Z","repository":{"id":62569716,"uuid":"256033365","full_name":"Julian-Nash/httpz","owner":"Julian-Nash","description":"A small but handy HTTP status code library","archived":false,"fork":false,"pushed_at":"2020-04-15T21:09:08.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-24T14:18:07.677Z","etag":null,"topics":["code","http","python","status"],"latest_commit_sha":null,"homepage":null,"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/Julian-Nash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-15T20:49:13.000Z","updated_at":"2020-04-15T21:09:10.000Z","dependencies_parsed_at":"2022-11-03T16:47:10.146Z","dependency_job_id":null,"html_url":"https://github.com/Julian-Nash/httpz","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/Julian-Nash%2Fhttpz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Julian-Nash%2Fhttpz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Julian-Nash%2Fhttpz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Julian-Nash%2Fhttpz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Julian-Nash","download_url":"https://codeload.github.com/Julian-Nash/httpz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244177723,"owners_count":20411010,"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":["code","http","python","status"],"created_at":"2024-11-24T13:11:25.543Z","updated_at":"2025-03-18T07:32:17.616Z","avatar_url":"https://github.com/Julian-Nash.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## httpz - A handy HTTP status code library\n\n![Python package](https://github.com/Julian-Nash/httpz/workflows/Python%20package/badge.svg)\n\n#### Installation\n\n```shell script\npip install httpz\n```\n\n#### API\n\nGet an HTTP status code\n\n```pycon\n\u003e\u003e\u003e HTTPStatusCodes.get(\"200\")\nHTTPStatusCode(code=200, message=OK, description=The request has succeeded)\n```\n\n`HTTPStatusCode` objects have several useful attributes:\n\n| Attribute | Type | Example |\n| --------- | ---- | ------- |\n| `code` | `int` | 200 |\n| `message` | `str` | OK |\n| `description` | `str` | The request has succeeded |\n| `category` | `str` | successful |\n| `webdav` | `bool` | `False` |\n| `experimental` | `bool` | `False` |\n\n\nFor example:\n\n```pycon\n\u003e\u003e\u003e code = HTTPStatusCodes.get(\"100\")\n\u003e\u003e\u003e code.code\n100\n\u003e\u003e\u003e code.message\n'Continue'\n\u003e\u003e\u003e code.category\n'informational'\n\u003e\u003e\u003e code.description\n'This interim response indicates that everything so far is OK and that the client should continue the request, or ignore the response if the request is already fi\nnished'\n```\n\nCalling `to_dict()` on an `HTTPStatusCode` object will return a dict:\n\n```pycon\n\u003e\u003e\u003e code = HTTPStatusCodes.get(\"200\")\n\u003e\u003e\u003e code.to_dict()\n{'description': 'The request has succeeded', 'code': 200, 'message': 'OK', 'webdav': False, 'category': 'successful'}\n```\n\nGet a list of `HTTPStatusCode` objects by category\n\n```pycon\n\u003e\u003e\u003e HTTPStatusCodes.get_category(\"informational\")\n[HTTPStatusCode(code=100, message=Continue, description=This interim response indicates that everything so far is OK and that the client should continue the reque\nst, or ignore the response if the request is already finished), HTTPStatusCode(code=101, message=Switching Protocol, description=This code is sent in response to\nan Upgrade request header from the client, and indicates the protocol the server is switching to), HTTPStatusCode(code=102, message=Processing, description=This c\node indicates that the server has received and is processing the request, but no response is available yet), HTTPStatusCode(code=103, message=Early Hints, descrip\ntion=This status code is primarily intended to be used with the Link header, letting the user agent start preloading resources while the server prepares a respons\ne)]\n```\n\nCategories:\n\n| Category | Range |\n| -------- | ----- |\n| `informational` | `100` - `199` |\n| `successful` | `200` - `299` |\n| `redirection` | `300` - `399` |\n| `client_error` | `400` - `499` |\n| `server_error` | `500` - `599` |\n\nAn enum of categories is also available:\n\n```pycon\n\u003e\u003e\u003e from httpz import HTTPStatusCodeCategory\n\u003e\u003e\u003e HTTPStatusCodeCategory.CLIENT_ERROR\n\u003cHTTPStatusCodeCategory.CLIENT_ERROR: 'client_error'\u003e\n\u003e\u003e\u003e HTTPStatusCodeCategory.CLIENT_ERROR.value\n'client_error'\n```\n\nAn ordered list of all `HTTPStatusCode` objects (from low to high) can be obtained by calling the following method:\n\n```pycon\n\u003e\u003e\u003e from httpz import HTTPStatusCodes\n\u003e\u003e\u003e all_codes = HTTPStatusCodes.get_all()\n\u003e\u003e\u003e for status_code in all_codes:\n...     print(status_code.code, status_code.message)\n100 Continue\n101 Switching Protocol\n102 Processing\n103 Early Hints\n200 OK\n201 Created\n202 Accepted\n203 Non-Authoritative Information\n204 No Content\n205 Reset Content\n206 Partial Content\n207 Multi-Status\n208 Already Reported\n226 IM Used\n300 Multiple Choice\n301 Moved Permanently\n302 Found\n303 See Other\n304 Not Modified\n305 Use Proxy\n306 Unused\n307 Temporary Redirect\n308 Permanent Redirect\n400 Bad Request\n401 Unauthorized\n402 Payment Required\n403 Forbidden\n404 Not Found\n405 Method Not Allowed\n406 Not Acceptable\n407 Proxy Authentication Required\n408 Request Timeout\n409 Conflict\n410 Gone\n411 Length Required\n412 Precondition Failed\n413 Payload Too Large\n414 URI Too Long\n415 Unsupported Media Type\n416 Range Not Satisfiable\n417 Expectation Failed\n418 I'm a teapot\n421 Misdirected Request\n422 Unprocessable Entity\n423 Locked\n424 Failed Dependency\n425 Too Early\n426 Upgrade Required\n428 Precondition Required\n429 Too Many Requests\n431 Request Header Fields Too Large\n451 Unavailable For Legal Reasons\n500 Internal Server Error\n501 Not Implemented\n502 Bad Gateway\n503 Service Unavailable\n504 Gateway Timeout\n505 HTTP Version Not Supported\n506 Variant Also Negotiates\n507 Insufficient Storage\n508 Loop Detected\n510 Not Extended\n511 Network Authentication Required\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulian-nash%2Fhttpz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjulian-nash%2Fhttpz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulian-nash%2Fhttpz/lists"}