{"id":14065248,"url":"https://github.com/cs91chris/flask_autocrud","last_synced_at":"2025-06-19T15:41:14.989Z","repository":{"id":57430144,"uuid":"164512716","full_name":"cs91chris/flask_autocrud","owner":"cs91chris","description":"Automatically generate a RESTful API service for CRUD operation on database and advanced search","archived":false,"fork":false,"pushed_at":"2024-02-09T03:34:19.000Z","size":1646,"stargazers_count":22,"open_issues_count":7,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-01T14:33:20.441Z","etag":null,"topics":["advanced-search","automatic-api","browsable-api","cli","crud","database","flask","hateoas","rest-api","restful","sqlalchemy"],"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/cs91chris.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-07T23:17:58.000Z","updated_at":"2023-08-05T22:27:19.000Z","dependencies_parsed_at":"2024-05-28T00:29:50.076Z","dependency_job_id":"d0209642-1a07-406a-9c4d-f7cee1fffff6","html_url":"https://github.com/cs91chris/flask_autocrud","commit_stats":{"total_commits":131,"total_committers":2,"mean_commits":65.5,"dds":0.007633587786259555,"last_synced_commit":"e522b1d73b49238207b3a7d130ab43c458d39337"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/cs91chris/flask_autocrud","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs91chris%2Fflask_autocrud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs91chris%2Fflask_autocrud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs91chris%2Fflask_autocrud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs91chris%2Fflask_autocrud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cs91chris","download_url":"https://codeload.github.com/cs91chris/flask_autocrud/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cs91chris%2Fflask_autocrud/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260781140,"owners_count":23062164,"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":["advanced-search","automatic-api","browsable-api","cli","crud","database","flask","hateoas","rest-api","restful","sqlalchemy"],"created_at":"2024-08-13T07:04:23.348Z","updated_at":"2025-06-19T15:41:09.977Z","avatar_url":"https://github.com/cs91chris.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Flask-AutoCRUD\n==============\n\n|download| |version|\n\nInspired by: `sandman2 \u003chttps://github.com/jeffknupp/sandman2\u003e`__\n\nbased on: `sqlalchemy-filters \u003chttps://pypi.org/project/sqlalchemy-filters\u003e`__\n`Flask-ResponseBuilder \u003chttps://pypi.org/project/Flask-ResponseBuilder\u003e`__\n`Flask-ErrorsHandler \u003chttps://pypi.org/project/Flask-ErrorsHandler\u003e`__\n\nAutomatically generate a RESTful APIs for CRUD operation and advanced search on a database.\nIf a list of ``Model`` is not provided, all tables are affected, otherwise you can customize:\n\n- resource name\n- fields name\n- resource url\n- allowed methods\n- hidden fields\n\n\nFeatures\n~~~~~~~~\n\n- HATEOAS support\n- conditional requests via ETag header\n- full range of CRUD operations\n- filtering, sorting and pagination\n- customizable responses via query string\n- custom FETCH method for advanced search\n- content negotiation based on Accept header\n- export to csv available\n- meta resource description\n- cli tool to run autocrud on a database\n\nQuickstart\n~~~~~~~~~~\n\nInstall ``flask_autocrud`` using ``pip``:\n\n::\n\n    $ pip install Flask-AutoCRUD\n\n\n.. _section-1:\n\nExample usage\n^^^^^^^^^^^^^\n\n.. code:: python\n\n   from flask import Flask\n\n   from flask_autocrud import AutoCrud\n   from flask_sqlalchemy import SQLAlchemy\n\n\n   app = Flask(__name__)\n   app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite+pysqlite:///db.sqlite3'\n   app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False\n   app.config['AUTOCRUD_METADATA_ENABLED'] = True\n\n   db = SQLAlchemy(app)\n   AutoCrud(app, db)\n\n   app.run(debug=True)\n\nGo to http://127.0.0.1:5000/resources and see all available resources with its\nendpoint. NOTE: you must set SQLALCHEMY_DATABASE_URI with your database.\n\nIf you want to see an example use with Flask-Admin see in example folder.\n\n.. _section-2:\n\nFiltering and Sorting\n^^^^^^^^^^^^^^^^^^^^^\n\nAdd filters as query string parameters, they are applied in AND, OR operator not supported.\n\nYou can use entity fields as parameter with the following placeholders in the value:\n\n- null value: ``null``\n- in operator: list separated by ``;``\n- not operator: ``!`` means: not equal, not null, not in\n- comparators: ``__gt__`` (grater), ``__lt__`` (lesser), ``__gte__`` (grater-equal), ``__lte__`` (lesser-equal)\n- like operator: ``%`` for example: %%test%, %test% or %%test\n  NOTE first % are not used in expression, it only indicated that value must be used with like operator.\n\n\nOther parameters, note that all starts with ``_``:\n\n- Use ``_fields`` parameter to get only the fields listed as value, separated by ``;``.\n- Use ``_limit`` and ``_page`` parameters for pagination.\n- Sorting is implemented with ``_sort`` parameter. The value is a list of field separated by `;`\n  You can prepend ``-`` to reverse order.\n- Use ``_export`` parameter to export data into csv format with file name passed as value or leave empty for default.\n  You can also use ``Accept:text/csv`` header, but it has a different behavior because the transformation is applied at the\n  end of response.\n- Use ``_related`` in order to fetch data of related resources listed as value separated by ``;`` or leave empty if\n  you want all. Added in 2.2.0 in previous release use ``_extended`` with no filters.\n- Use ``_as_table`` in order to flatten nested dict useful if you want render response as table in combination with\n  response in html format or simply if you do not want nested json (no value required).\n- With ``_no_links`` links of related data and pages are filtered (no value required).\n\nExample requests:\n\n- ``/invoice?InvoiceId=(35;344)``\n\n- ``/invoice?Total=__lte__10\u0026_sort=Total``\n\n- ``/invoice?_fields=BillingCountry;Total;InvoiceId\u0026InvoiceId=!355;344\u0026_sort=-InvoiceId``\n\n- ``/invoice?_fields=Total;InvoiceId\u0026BillingPostalCode=!null\u0026BillingCountry=%%ermany``\n\n- ``/invoice?_fields=Total;InvoiceDate;InvoiceId;CustomerId\u0026_page=2\u0026_limit=10``\n\n- ``/invoice?InvoiceDate=(2009-01-01;2009-02-01 00:00:00)``\n\n- ``/track?_related=Album;Genre``\n\n\nCustom method FETCH\n^^^^^^^^^^^^^^^^^^^\n\nFETCH request is like a GET collection resources with a body that represents the filters to apply. It differs from\nfilters in query string because there are used to reduce the response (filters are in AND), here are used to\nproduce a search response, in fact you can request and filter data of combined related resources (like sql JOIN) and\nuse OR operator with a simple syntax.\n\nSee: `sqlalchemy-filters \u003chttps://github.com/juliotrigo/sqlalchemy-filters\u003e`__ documentation for filters explanation\nand more examples.\n\nIf you are unable to use FETCH, you can use POST method with header: ``X-HTTP-Method-Override: FETCH``. If you\nwant only headers and not response use header: ``X-HTTP-Method-Override: HEAD``.\n\nThe following is an example of body request on ``/customer``:\n\n.. code:: json\n\n    {\n        \"fields\": [\n            \"Address\",\n            \"City\"\n        ],\n        \"related\": {\n            \"Employee\": [\n                \"FirstName\",\n                \"LastName\"\n            ],\n            \"Invoice\": [\"*\"]\n        },\n        \"filters\": [\n            {\n                \"model\": \"Customer\",\n                \"field\": \"SupportRepId\",\n                \"op\": \"==\",\n                \"value\": 5\n            },\n            {\n                \"model\": \"Invoice\",\n                \"field\": \"Total\",\n                \"op\": \"\u003e\",\n                \"value\": 6\n            }\n        ],\n        \"sorting\": [\n            {\n                \"model\": \"Invoice\",\n                \"field\": \"Total\",\n                \"direction\": \"asc\"\n            },\n            {\n                \"model\": \"Customer\",\n                \"field\": \"Address\",\n                \"direction\": \"desc\"\n            }\n        ]\n    }\n\n.. _section-3:\n\nAutoCRUD cli\n^^^^^^^^^^^^\n\nYou can use autocrud as a standalone application configurable via yaml file.\nSome options could be given via cli see: ``autocrud --help``.\n\nFrom release 2.2.0 multiple wsgi server can be used,\ninstead in previous release only gunicorn or waitress can be used;\nin addition cli options are changed.\n\nConfiguration file contains 2 principal macro section:\n\n- app: every configuration under it will be passed to Flask config object\n- wsgi: every configuration under it will be passed to the chosen wsgi server\n\n\nFor example:\n\n.. code:: yaml\n\n    app:\n      SQLALCHEMY_DATABASE_URI: sqlite+pysqlite:///examples/db.sqlite3\n      SQLALCHEMY_TRACK_MODIFICATIONS: false\n    wsgi:\n      bind: localhost:5000\n      workers: 1\n      threads: 1\n\n\n.. _section-4:\n\nConfiguration\n^^^^^^^^^^^^^\n\n1.  ``AUTOCRUD_METADATA_ENABLED``: *(default: True)* enable metadata endpoint for a resource\n2.  ``AUTOCRUD_METADATA_URL``: *(default: '/meta)* added at the end of url resource\n3.  ``AUTOCRUD_READ_ONLY``: *(default: False)* enable only http GET method\n4.  ``AUTOCRUD_BASE_URL``: *(default: '')* prefix url for resources\n5.  ``AUTOCRUD_RESOURCES_URL``: *(default: '/resources')* url for all available resources\n6.  ``AUTOCRUD_RESOURCES_URL_ENABLED``: *(default: True)* enable route for resources list\n7.  ``AUTOCRUD_SUBDOMAIN``: *(default: None)* bind autocrud endpoints to a subdomain\n8.  ``AUTOCRUD_MAX_QUERY_LIMIT``: *(default 1000)* max query limit, 0 means no limit\n9.  ``AUTOCRUD_FETCH_ENABLED``: *(default True)* enable or disable FETCH method\n10. ``AUTOCRUD_QUERY_STRING_FILTERS_ENABLED``: *(default True)* enable or disable filters in querystring\n11. ``AUTOCRUD_EXPORT_ENABLED``: *(default True)* enable or disable export to csv\n12. ``AUTOCRUD_DATABASE_SCHEMA``: *(default None)* database schema to consider\n13. ``AUTOCRUD_CONDITIONAL_REQUEST_ENABLED``: *(default True)* allow conditional request\n\n\nTODO\n^^^^\n\n* automatic swagger ui or alternative api docs\n\n\nFeedback and contributions are welcome.\n\nLicense MIT\n\n\n.. |download| image:: https://pypip.in/download/flask_autocrud/badge.png\n.. |version| image:: https://pypip.in/version/flask_autocrud/badge.png","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcs91chris%2Fflask_autocrud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcs91chris%2Fflask_autocrud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcs91chris%2Fflask_autocrud/lists"}