{"id":20636735,"url":"https://github.com/libcommon/flask-reqparser-py","last_synced_at":"2025-10-08T15:42:00.127Z","repository":{"id":62575398,"uuid":"222612510","full_name":"libcommon/flask-reqparser-py","owner":"libcommon","description":"Python library for the Flask framework to parse request parameters using the argparse library.","archived":false,"fork":false,"pushed_at":"2022-12-26T21:31:51.000Z","size":54,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-23T07:02:13.844Z","etag":null,"topics":[],"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/libcommon.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-11-19T05:02:44.000Z","updated_at":"2020-05-31T07:46:06.000Z","dependencies_parsed_at":"2023-01-31T01:45:48.791Z","dependency_job_id":null,"html_url":"https://github.com/libcommon/flask-reqparser-py","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/libcommon/flask-reqparser-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libcommon%2Fflask-reqparser-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libcommon%2Fflask-reqparser-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libcommon%2Fflask-reqparser-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libcommon%2Fflask-reqparser-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libcommon","download_url":"https://codeload.github.com/libcommon/flask-reqparser-py/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libcommon%2Fflask-reqparser-py/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268644482,"owners_count":24283334,"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-08-04T02:00:09.867Z","response_time":79,"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":[],"created_at":"2024-11-16T15:12:00.805Z","updated_at":"2025-10-08T15:41:55.096Z","avatar_url":"https://github.com/libcommon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flask-reqparser-py\n\n## Overview\n\nThe Flask web framework provides access to request parameters via [flask.request.args](https://flask.palletsprojects.com/en/1.1.x/api/#flask.Request.args)\nfor `GET` requests and via [flask.request.form](https://flask.palletsprojects.com/en/1.1.x/api/#flask.Request.form) for `PUT` and `POST` requests.\nRequiring certain parameters be present for an endpoint, or parsing parameters as custom types, necessitates extra logic to process values from the aforementioned\ndictionaries and is error-prone.  However, API endpoints can act much like command line interfaces, and Python has solved that problem\nfairly will with the [argparse](https://docs.python.org/3/library/argparse.html) library.  `flask-reqparser-py` exposes a `RequestParser` class\nthat allows you to define a parser for request arguments, and access them like regular command line arguments.\n\n## Installation\n\n### Install from PyPi (preferred method)\n\n```bash\npip install lc-flask-reqparser\n```\n\n### Install from GitHub with Pip\n\n```bash\npip install git+https://github.com/libcommon/flask-reqparser-py.git@vx.x.x#egg=lc_flask_reqparser\n```\n\nwhere `x.x.x` is the version you want to download.\n\n## Install by Manual Download\n\nTo download the source distribution and/or wheel files, navigate to\n`https://github.com/libcommon/flask-reqparser-py/tree/releases/vx.x.x/dist`, where `x.x.x` is the version you want to install,\nand download either via the UI or with a tool like wget. Then to install run:\n\n```bash\npip install \u003cdownloaded file\u003e\n```\n\nDo _not_ change the name of the file after downloading, as Pip requires a specific naming convention for installation files.\n\n## Dependencies\n\n`flask-reqparser-py` depends on, and is designed to work with, the \n[Flask framework](https://flask.palletsprojects.com/en/1.1.x/).  Only Python versions \u003e= 3.6 are officially supported.\n\n## Getting Started\n\nThe syntax for defining a `RequestParser` is almost identical to an `ArgumentParser`, except that all arguments should be\ndefined as positional, and it supports the builder pattern for adding arguments.  `RequestParser` will take the positional\ndefinitions and transform them to act like optional arguments (optional arguments in `argparse` can still have `required=True`).\n\n```python\nfrom typing import List\n\nfrom flask import Flask\n\nfrom lc_flask_reqparser import RequestParser\n\n\napp = Flask(__name__)\n\n\ndef CommaSeparatedList(arg: str) -\u003e List[str]:\n    \"\"\"Convert string representation of CSV to list of str.\"\"\"\n    return arg.split(\",\")\n\n\n@app.route(\"/api/describe/person\")\ndef describe_person():\n    \"\"\"API endpoint to describe information about a person.\"\"\"\n    parser = (RequestParser()\n              .add_argument(\"name\", required=True)\n              .add_argument(\"nicknames\", type=CommaSeparatedList))\n    args, _ = parser.parse_args()\n    // use args.name or args.nicknames list to lookup user in database\n    // and return information in JSON form.\n```\n\nNote that `RequestParser.parse_args` returns a tuple containing the `Namespace` with defined arguments, as well as\na list of the remaining (undefined) arguments.  If an API endpoint only cares about defined arguments, it can safely\nignore the second element of the tuple like the example above.\n\n## Contributing/Suggestions\n\nContributions and suggestions are welcome! To make a feature request, report a bug, or otherwise comment on existing\nfunctionality, please file an issue. For contributions please submit a PR, but make sure to lint, type-check, and test\nyour code before doing so. Thanks in advance!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibcommon%2Fflask-reqparser-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibcommon%2Fflask-reqparser-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibcommon%2Fflask-reqparser-py/lists"}