From fb3de7029eec4ba82dba263334410fc19cffbf5c Mon Sep 17 00:00:00 2001 From: femalves Date: Thu, 16 Apr 2026 12:55:22 -0400 Subject: [PATCH] raise per-user rate limits from 300/day to 5000/day on metadata and manifest endpoints --- scan_explorer_service/views/manifest.py | 6 +++--- scan_explorer_service/views/metadata.py | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scan_explorer_service/views/manifest.py b/scan_explorer_service/views/manifest.py index a88894f..d0923d0 100644 --- a/scan_explorer_service/views/manifest.py +++ b/scan_explorer_service/views/manifest.py @@ -32,7 +32,7 @@ def before_request(): manifest_factory.set_base_image_uri(image_proxy) -@advertise(scopes=['api'], rate_limit=[300, 3600*24]) +@advertise(scopes=['api'], rate_limit=[5000, 3600*24]) @bp_manifest.route('//manifest.json', methods=['GET']) def get_manifest(id: str): """ Creates an IIIF manifest from an article or Collection""" @@ -77,7 +77,7 @@ def get_manifest(id: str): return jsonify(exception='Article not found'), 404 -@advertise(scopes=['api'], rate_limit=[300, 3600*24]) +@advertise(scopes=['api'], rate_limit=[5000, 3600*24]) @bp_manifest.route('/canvas/.json', methods=['GET']) def get_canvas(page_id: str): """ Creates an IIIF canvas from a page""" @@ -90,7 +90,7 @@ def get_canvas(page_id: str): return jsonify(exception='Page not found'), 404 -@advertise(scopes=['api'], rate_limit=[300, 3600*24]) +@advertise(scopes=['api'], rate_limit=[5000, 3600*24]) @bp_manifest.route('//search', methods=['GET']) def search(id: str): """Search OCR text within an article or collection, returning IIIF annotations.""" diff --git a/scan_explorer_service/views/metadata.py b/scan_explorer_service/views/metadata.py index 974c840..c8f2b49 100644 --- a/scan_explorer_service/views/metadata.py +++ b/scan_explorer_service/views/metadata.py @@ -17,7 +17,7 @@ bp_metadata = Blueprint('metadata', __name__, url_prefix='/metadata') -@advertise(scopes=['api'], rate_limit=[300, 3600*24]) +@advertise(scopes=['api'], rate_limit=[5000, 3600*24]) @bp_metadata.route('/article/extra/', methods=['GET']) def article_extra(bibcode: str): """Route that fetches additional metadata about an article from the ADS search service """ @@ -40,7 +40,7 @@ def article_extra(bibcode: str): return jsonify(message='Failed to retrieve external ADS article metadata'), 500 return {} -@advertise(scopes=['api'], rate_limit=[300, 3600*24]) +@advertise(scopes=['api'], rate_limit=[5000, 3600*24]) @bp_metadata.route('/article//collection', methods=['GET']) def article_collection(bibcode: str): """Route that fetches collection from an article """ @@ -54,7 +54,7 @@ def article_collection(bibcode: str): page_in_collection = first_page.volume_running_page_num return jsonify({'id': article.collection_id, 'selected_page': page_in_collection}), 200 -@advertise(scopes=['ads:scan-explorer'], rate_limit=[300, 3600*24]) +@advertise(scopes=['ads:scan-explorer'], rate_limit=[5000, 3600*24]) @bp_metadata.route('/article', methods=['PUT']) def put_article(): """Create a new or overwrite an existing article""" @@ -72,7 +72,7 @@ def put_article(): return jsonify(message='Invalid article json'), 400 -@advertise(scopes=['ads:scan-explorer'], rate_limit=[300, 3600*24]) +@advertise(scopes=['ads:scan-explorer'], rate_limit=[5000, 3600*24]) @bp_metadata.route('/collection', methods=['PUT']) def put_collection(): """ Create a new or overwrite an existing collection """ @@ -142,7 +142,7 @@ def put_collection(): return jsonify(message='Invalid collection json'), 400 -@advertise(scopes=['ads:scan-explorer'], rate_limit=[300, 3600*24]) +@advertise(scopes=['ads:scan-explorer'], rate_limit=[5000, 3600*24]) @bp_metadata.route('/page', methods=['PUT']) def put_page(): """Create a new or overwrite an existing page """ @@ -174,7 +174,7 @@ def _make_search_cache_key(prefix, args): return hashlib.md5(raw.encode()).hexdigest() -@advertise(scopes=['api'], rate_limit=[300, 3600*24]) +@advertise(scopes=['api'], rate_limit=[5000, 3600*24]) @bp_metadata.route('/article/search', methods=['GET']) def article_search(): """Search for an article using one or some of the available keywords""" @@ -207,7 +207,7 @@ def article_search(): return jsonify(message=str(e), type=ApiErrors.SearchError.value), 400 -@advertise(scopes=['api'], rate_limit=[300, 3600*24]) +@advertise(scopes=['api'], rate_limit=[5000, 3600*24]) @bp_metadata.route('/collection/search', methods=['GET']) def collection_search(): """Search for a collection using one or some of the available keywords""" @@ -232,7 +232,7 @@ def collection_search(): except Exception as e: return jsonify(message=str(e), type=ApiErrors.SearchError.value), 400 -@advertise(scopes=['api'], rate_limit=[300, 3600*24]) +@advertise(scopes=['api'], rate_limit=[5000, 3600*24]) @bp_metadata.route('/page/search', methods=['GET']) def page_search(): """Search for a page using one or some of the available keywords""" @@ -256,7 +256,7 @@ def page_search(): except Exception as e: return jsonify(message=str(e), type=ApiErrors.SearchError.value), 400 -@advertise(scopes=['api'], rate_limit=[300, 3600*24]) +@advertise(scopes=['api'], rate_limit=[5000, 3600*24]) @bp_metadata.route('/page/ocr', methods=['GET']) def get_page_ocr(): """Get the OCR for a page using it's parents id and page number"""