{"id":22340059,"url":"https://github.com/lvieirajr/mongorest","last_synced_at":"2025-06-24T20:09:25.697Z","repository":{"id":30594586,"uuid":"34149734","full_name":"lvieirajr/mongorest","owner":"lvieirajr","description":"Easy REST APIs using MongoDB","archived":false,"fork":false,"pushed_at":"2019-10-23T00:38:01.000Z","size":382,"stargazers_count":12,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T22:02:21.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lvieirajr.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":"2015-04-18T02:43:38.000Z","updated_at":"2024-02-09T23:01:14.000Z","dependencies_parsed_at":"2022-09-26T17:21:30.043Z","dependency_job_id":null,"html_url":"https://github.com/lvieirajr/mongorest","commit_stats":null,"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"purl":"pkg:github/lvieirajr/mongorest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lvieirajr%2Fmongorest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lvieirajr%2Fmongorest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lvieirajr%2Fmongorest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lvieirajr%2Fmongorest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lvieirajr","download_url":"https://codeload.github.com/lvieirajr/mongorest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lvieirajr%2Fmongorest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261749216,"owners_count":23203990,"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":[],"created_at":"2024-12-04T07:10:17.143Z","updated_at":"2025-06-24T20:09:25.645Z","avatar_url":"https://github.com/lvieirajr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MongoRest\n\n[![pypi-version]][pypi] [![pypi-downloads]][pypi] [![read-the-docs]][mongorest-read-the-docs] [![build-status]][travis] [![coveralls-status]][coveralls] [![landscape-health]][landscape] [![codacy-grade]][codacy] \n\n**Easy [REST][rest] [APIs][api] using [MongoDB][mongodb].**\n\n\n# Overview\n\n[MongoRest][mongorest] is a [Framework][framework] written in [Python][python] built on top of [PyMongo][pymongo] and [Werkzeug][werkzeug] to ease the creation of [REST][rest] [APIs][api] using [MongoDB][mongodb].\n\n\n# Python Compatibility\n\n* Python \u003e= 2.7\n* Python3 \u003e= 3.3\n* Pypy \u003e= 2.6\n* Pypy3 \u003e= 2.4\n\n\n# Mongo Compatibility\n\n* MongoDB \u003e= 2.4\n\n\n# Requirements\n\n* Cerberus \u003e= 0.9.0\n* PyMongo \u003e= 3.0.0\n* Six \u003e= 1.10.0\n* Werkzeug \u003e= 0.10.0\n\n\n# Installation\n\n    pip install mongorest\n    \n    \n# Usage\n\nTo define the settings for your project you should set the environment variable `MONGOREST_SETTINGS_MODULE` to the module where the settings are stored:\n\n```python\nfrom os import environ\nenviron['MONGOREST_SETTINGS_MODULE'] = 'project.settings'\n```\n\nTo connect to your database you should specify the `MONGODB` setting on your mongorest settings module.\nYou can set the connection `URI`, or use other options like setting the `HOSTS` and `PORTS` of your replica-set.\nIf you are not using a replica-set you can just set the one `HOST` and `PORT`.\n\n```python\nMONGODB = {\n    'URI': '',\n    'USERNAME': '',\n    'PASSWORD': '',\n    'HOST': 'localhost'\n    'HOSTS': [],\n    'PORT': 27017\n    'PORTS': [],\n    'DATABASE': 'mongorest',\n    'OPTIONS': [],\n}\n```\n\nHere is a basic example of how easy it is to create an example library API with **MongoRest**:\n\n```python\nfrom mongorest.collection import Collection\n\nclass Book(Collection):\n    schema = {\n        'name': {'type': 'string', 'required': True},\n        'genre': {'type': 'string', 'required': True},\n        'author': {'type': 'string', 'required': True},\n        'number_of_pages': {'type': 'integer'},\n        'release_date': {'type': 'datetime'},\n    }\n```\n\nFirst we created our Book collection that inherited from the `mongorest.Collection` class, \nthen we added a `schema` to specify the fields, and their types.\nFor more details on schema creation visit the documentation for **Cerberus** in this [LINK][cerberus].\n\n```python\nfrom mongorest.resource import ListResourceMixin, CreateResourceMixin\n\nclass BookResource(ListResourceMixin, CreateResourceMixin):\n    collection = Book\n    endpoint = 'books'\n```\n\nHere, by inheriting from these mongorest-builtin Mixins, our resource already has the list and create actions.\nWe also defined what will be the collection and endpoint this Resource refers to.\n\n```python        \nfrom mongorest.wsgi import WSGIDispatcher\nfrom werkzeug.serving import run_simple\n\nif __name__ == '__main__':\n    wsgi_app = WSGIDispatcher([BookResource])\n    run_simple('localhost', 8000, wsgi_app)\n```\n\nNow we just had to instantiate the application as a `WSGIDispatcher` passing it our list of resources.\nAfter that, we started our server and the API is ready to be consumed.\n\n    \n# License\n\nCopyright (c) 2015, Luis Antônio Vieira Junior.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n\\*  Redistributions of source code must retain the above copyright notice, this\n    list of conditions and the following disclaimer.\n\n\\*  Redistributions in binary form must reproduce the above copyright notice,\n    this list of conditions and the following disclaimer in the documentation\n    and/or other materials provided with the distribution.\n\n\\*  Neither the name of MongoRest nor the names of its\n    contributors may be used to endorse or promote products derived from\n    this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n[pypi-version]: https://img.shields.io/pypi/v/MongoRest.svg\n[pypi-downloads]: https://img.shields.io/pypi/dm/MongoRest.svg\n[pypi]: https://pypi.python.org/pypi/mongorest\n\n[read-the-docs]: https://readthedocs.org/projects/docs/badge/?version=latest\n[mongorest-read-the-docs]: https://mongorest.readthedocs.io/\n\n[build-status]: https://travis-ci.org/lvieirajr/mongorest.svg?branch=master\n[travis]: https://travis-ci.org/lvieirajr/mongorest\n\n[coveralls-status]: https://coveralls.io/repos/lvieirajr/mongorest/badge.svg?branch=master\n[coveralls]: https://coveralls.io/r/lvieirajr/mongorest?branch=master\n\n[landscape-health]: https://landscape.io/github/lvieirajr/mongorest/master/landscape.svg?style=flat\n[landscape]: https://landscape.io/github/lvieirajr/mongorest/master\n\n[codacy-grade]: https://www.codacy.com/project/badge/de84ced5bfa241b3a1a64f73146a03e3\n[codacy]: https://www.codacy.com/app/lvieira/mongorest\n\n[rest]: https://en.wikipedia.org/wiki/Rest\n[api]: https://en.wikipedia.org/wiki/Application_programming_interface\n[mongodb]: https://www.mongodb.org/\n\n[mongorest]: https://github.com/lvieirajr/mongorest/\n[framework]: https://en.wikipedia.org/wiki/Software_framework\n[python]: https://www.python.org/\n[pymongo]: https://github.com/mongodb/mongo-python-driver/ \n[werkzeug]: http://werkzeug.pocoo.org/\n[cerberus]: http://cerberus.readthedocs.io/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flvieirajr%2Fmongorest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flvieirajr%2Fmongorest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flvieirajr%2Fmongorest/lists"}