{"id":13501832,"url":"https://github.com/ramnes/flask-aggregator","last_synced_at":"2025-03-29T10:32:15.252Z","repository":{"id":57430084,"uuid":"78375606","full_name":"ramnes/flask-aggregator","owner":"ramnes","description":":fast_forward: Batch the GET requests to your REST API into a single POST","archived":true,"fork":false,"pushed_at":"2017-01-17T18:57:00.000Z","size":13,"stargazers_count":22,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T19:49:13.001Z","etag":null,"topics":["api","flask","flask-extensions","http","mobile-first","python","rest"],"latest_commit_sha":null,"homepage":"","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/ramnes.png","metadata":{"files":{"readme":"README.rst","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":"2017-01-08T22:48:23.000Z","updated_at":"2023-01-28T09:40:25.000Z","dependencies_parsed_at":"2022-08-26T03:25:13.436Z","dependency_job_id":null,"html_url":"https://github.com/ramnes/flask-aggregator","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramnes%2Fflask-aggregator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramnes%2Fflask-aggregator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramnes%2Fflask-aggregator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramnes%2Fflask-aggregator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ramnes","download_url":"https://codeload.github.com/ramnes/flask-aggregator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246173848,"owners_count":20735405,"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":["api","flask","flask-extensions","http","mobile-first","python","rest"],"created_at":"2024-07-31T22:01:52.389Z","updated_at":"2025-03-29T10:32:14.987Z","avatar_url":"https://github.com/ramnes.png","language":"Python","readme":"Flask-Aggregator\n================\n\n.. image:: https://img.shields.io/pypi/v/flask-aggregator.svg\n\nBatch the GET requests to your API into a single POST. Save requests latency and\nreduce REST chatiness.\n\nI was inspired by `this article\n\u003chttp://tech.3scale.net/2013/04/18/accelerate-your-mobile-api-with-nginx-and-lua/\u003e`_\nfrom 3scale, and by `their NGINX aggregator\n\u003chttps://github.com/solso/api-aggregator\u003e`_ - but I wanted something simpler.\n\n\nWhat does it do?\n----------------\n\nFlask-Aggregator adds an endpoint to your Flask application that handles\nmultiple GET requests in a single POST, and returns the response of each GET\nrequest in a JSON stream.\n\n\nWhat does that mean?\n--------------------\n\nIt means that instead of sending multiple GET requests:\n\n.. code-block:: sh\n\n   -\u003e GET /route1\n   \u003c- answer1\n   -\u003e GET /route2\n   \u003c- answer2\n   -\u003e GET /route3\n   \u003c- answer3\n\n\nYou can now just send a single POST that aggregates them all:\n\n.. code-block:: sh\n\n  -\u003e POST /aggregate [\"/route1\", \"/route2\", \"/route3\"]\n  \u003c- {\n         \"/route1\": answer1,\n  \u003c-     \"/route2\": answer2,\n  \u003c-     \"/route3\": answer3\n     }\n\n\nWhy?\n----\n\nMobile networks.\n\n\nHow to install?\n---------------\n\n.. code-block:: sh\n\n    $ pip install flask-aggregator\n\n\nHow to setup my application?\n----------------------------\n\n.. code-block:: python\n\n   from flask import Flask\n   from flask_aggregator import Aggregator\n\n   app = Flask(__name__)\n   Aggregator(app=app, endpoint=\"/batch\")\n\n\nHow to aggregate?\n-----------------\n\n.. code-block:: sh\n\n   $ python example.py\n   [go to another shell]\n   $ curl -H \"Content-type: application/json\" -X POST 127.0.0.1:5000/batch \\\n                --data-raw '[\"/hello/world\", \"/hello/ramnes?question=Sup?\"]'\n   {\n       \"/hello/world\": \"Hello, world!\",\n       \"/hello/ramnes?question=Sup?\": \"Hello, ramnes! Sup?\"\n   }\n\n\nIs it ready for production yet?\n-------------------------------\n\nNot really.\n\nAs of today, Flask-Aggregator executes the aggregated requests in a\nsynchronous manner, which makes it only useful if latency is a real issue and\nresponse time is not, and that more than N requests are sent at the same time,\nwhere N is maximum number of concurrent requests on user's client.\n\nAlso, it has limitations such has:\n\n* no automatic caching mechanism browser-side, since it uses a POST request\n* no header support at all for now, which means no cookie, etag, or whatever\n* no other HTTP verb than GET is supported for now\n\nLast but not least, chances are high that a lot of corner cases are not handled.\n\n\nLicense\n-------\n\nMIT\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framnes%2Fflask-aggregator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framnes%2Fflask-aggregator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framnes%2Fflask-aggregator/lists"}