{"id":29371259,"url":"https://github.com/python-odin/odinweb","last_synced_at":"2025-10-24T21:08:25.783Z","repository":{"id":52414076,"uuid":"81298142","full_name":"python-odin/odinweb","owner":"python-odin","description":"OdinWeb toolkit for building RESTful APIs using Odin and your favourite Python web framework.","archived":false,"fork":false,"pushed_at":"2021-04-29T21:20:57.000Z","size":1097,"stargazers_count":3,"open_issues_count":6,"forks_count":2,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2025-05-26T21:04:38.608Z","etag":null,"topics":["api","bottle","django","flask","odin","python","restful"],"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/python-odin.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-02-08T06:57:34.000Z","updated_at":"2022-01-16T14:19:27.000Z","dependencies_parsed_at":"2022-09-26T17:30:32.833Z","dependency_job_id":null,"html_url":"https://github.com/python-odin/odinweb","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/python-odin/odinweb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-odin%2Fodinweb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-odin%2Fodinweb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-odin%2Fodinweb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-odin%2Fodinweb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/python-odin","download_url":"https://codeload.github.com/python-odin/odinweb/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-odin%2Fodinweb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264465909,"owners_count":23612587,"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","bottle","django","flask","odin","python","restful"],"created_at":"2025-07-09T15:01:27.245Z","updated_at":"2025-10-24T21:08:25.705Z","avatar_url":"https://github.com/python-odin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=======\nOdinWeb\n=======\n\nA Restful API framework for Python that uses Odin Resources with native support for `Swagger \u003chttps://swagger.io\u003e`_\nand an integrated Swagger-UI.\n\n.. image:: https://img.shields.io/pypi/l/odinweb.svg?style=flat\n    :target: https://pypi.python.org/pypi/odinweb/\n    :alt: License\n\n.. image:: https://img.shields.io/pypi/v/odinweb.svg?style=flat\n    :target: https://pypi.python.org/pypi/odinweb/\n\n.. image:: https://img.shields.io/travis/python-odin/odinweb/master.svg?style=flat\n    :target: https://travis-ci.org/python-odin/odinweb\n    :alt: Travis CI Status\n\n.. image:: https://codecov.io/gh/python-odin/odinweb/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/python-odin/odinweb\n    :alt: Code cov\n\n.. image:: https://landscape.io/github/python-odin/odinweb/master/landscape.svg?style=flat\n   :target: https://landscape.io/github/python-odin/odinweb/master\n   :alt: Code Health\n\n.. image:: https://img.shields.io/requires/github/python-odin/odinweb.svg?style=flat\n    :target: https://requires.io/github/python-odin/odinweb/requirements/?branch=master\n    :alt: Requirements Status\n\n.. image:: https://img.shields.io/badge/gitterim-timsavage.odin-brightgreen.svg?style=flat\n    :target: https://gitter.im/timsavage/odin\n    :alt: Gitter.im\n\nThe initial development effort currently supports:\n\n- `Flask \u003chttp://flask.pocoo.org/\u003e`_\n- `Bottle \u003chttps://bottlepy.org\u003e`_\n- `Django \u003chttps://wwww.djangoproject.org/\u003e`_ - Odin/Django integration is already implemented with\n  `baldr \u003chttps://github.com/python-odin/baldr\u003e`_. Odin Web is an evolution of the design of baldr. Baldr still includes\n  other integration between django and odin, once merged Baldr will be depreciated\n\nWith the following frameworks to be included once a stable API is established:\n\n- `Retort \u003chttps://github.com/timsavage/retort\u003e`_ - A Flask/Bottle like framework for AWS Lambda/API Gateway\n\nThere are no plans at this point for other libraries although I'm open to suggestions/contributions. The effort\nrequired to integrate other libraries is minimal as Odin Web was designed to be agnostic of the framework it is\nrunning within.\n\n.. note::\n    Odin Web is being developed very much with a view to dropping support for Python 2.7 in the future, back-ported\n    versions of several Python 3.x features are utilised in the design (eg :py:mod:`enum` :py:mod:`http`).\n\n\nInstallation\n============\n\nAn early Alpha release is on PyPI, the API has however undergone significant changes since this was first put out the\nbest option is to checkout a tagged release from GitHub until a beta is ready that will solidify the API\n\nInstall the core library::\n\n    git clone git@github.com:python-odin/odinweb.git\n    cd odinweb\n    python setup.py install\n\nInstall your preferred web framework::\n\n    git clone git@github.com:python-odin/odinweb.flask.git\n    # or\n    git clone git@github.com:python-odin/odinweb.bottle.git\n    # or\n    git clone git@github.com:python-odin/odinweb.django.git\n\n    # Change into the appropriate directory then\n    python setup.py install\n\n\nQuickstart\n==========\n\nOdin Web is very much oriented around Resources so first define your resources::\n\n    import odin\n\n    class User(odin.Resource):\n        \"\"\"\n        User resource\n        \"\"\"\n        id = odin.IntegerField()\n        username = odin.StringField()\n        first_name = odin.StringField()\n        last_name = odin.StringField()\n        email = odin.EmailField()\n\n\nNext define your API::\n\n    from odinweb import api\n\n    USERS = [\n        User(1, 'pimpstar24', 'Bender', 'Rodreges', 'bender@ilovebender.com'),\n        User(2, 'zoidberg', 'Zoidberg', '', 'zoidberg@freemail.web'),\n        User(3, 'amylove79', 'Amy', 'Wong', 'awong79@marslink.web'),\n    ]\n    USER_ID = len(USERS)\n\n\n    class UserApi(api.ResourceApi):\n        resource = User\n        tags = ['user']\n\n        @api.listing\n        def get_user_list(self, request, offset, limit):\n            return USERS[offset:offset+limit], len(USERS)\n\n        @api.create\n        def create_user(self, request, user):\n            global USER_ID\n\n            # Add user to list\n            USER_ID += 1\n            user.id = USER_ID\n            USERS.append(user)\n\n            return user\n\n        @api.detail\n        def get_user(self, request, resource_id):\n            \"\"\"\n            Get a user object\n            \"\"\"\n            for user in USERS:\n                if user.id == resource_id:\n                    return user\n\n            raise api.Error.from_status(api.HTTPStatus.NOT_FOUND)\n\n        @api.delete\n        def delete_user(self, request, resource_id):\n            for idx, user in enumerate(USERS):\n                if user.id == resource_id:\n                    USERS.remove(user)\n                    return api.create_response(200)\n\n            raise api.Error.from_status(api.HTTPStatus.NOT_FOUND)\n\nThis defines an API for listing, fetching and creating a users.\n\nFinally hookup to your web framework, in this case Flask and enable swagger spec::\n\n    from flask import Flask\n    from odinweb.flask import ApiBlueprint\n    from odinweb.swagger import SwaggerSpec\n\n    app = flask.Flask(__name__)\n\n    app.register_blueprint(\n        ApiBlueprint(\n            # Use an API version\n            api.ApiVersion(\n                SwaggerSpec('Flask Example API', enable_ui=True),  # Support for Swagger!\n                UserApi(),\n            ),\n            debug_enabled=True,  # Enable debug output\n        ),\n    )\n\nStart the flask app and you can browse to the swagger UI to try out the API::\n\n    http://localhost:5000/api/v1/swagger/ui\n\n\n\nCORS\n====\n\nTo enable CORS your API Interface (for Flask this is `ApiBlueprint`) needs to\nbe wrapped with the CORS wrapper eg::\n\n    from flask import Flask\n    from odinweb.flask import ApiBlueprint\n    from odinweb.cors import CORS, AnyOrigin\n\n    app = flask.Flask(__name__)\n\n    app.register_blueprint(\n        CORS(\n            ApiBlueprint(\n                api.ApiVersion(\n                    UserApi()\n                )\n            ),\n            origins=AnyOrigin\n        )\n    )\n\nFor customisation the CORS class can easily be inherited to customise how the\norigin is determined (handy if your application is behind a reverse proxy).\nThe CORS wrapper also accepts `max_age`, `allow_credentials`, `expose_headers`\nand `allow_headers` options.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-odin%2Fodinweb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpython-odin%2Fodinweb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-odin%2Fodinweb/lists"}