django-declarative-apis


Namedjango-declarative-apis JSON
Version 0.31.7 PyPI version JSON
download
home_page
SummarySimple, readable, declarative APIs for Django
upload_time2024-02-08 10:29:07
maintainer
docs_urlNone
author
requires_python
license
keywords django rest declarative api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Documentation Status](https://readthedocs.org/projects/django-declarative-apis/badge/?version=stable)](https://django-declarative-apis.readthedocs.io/en/stable/?badge=stable)


Overview
========

django-declarative-apis is a framework built on top of Django aimed at teams implementing RESTful APis. It provides a simple interface to define endpoints declaratively. Some benefits to using django-declarative-apis:

-   Define endpoints declaratively
-   Define model-bound and unbound resource endpoints with a consistent interface
-   OAuth 1.0a authentication out of the box
-   Define resource and endpoint-bound tasks, promoting modularity
-   Define synchronous and asynchronous tasks (asynchronous tasks implemented with Celery)
-   Separation of concerns between request body processing and business logic


Quick start
===========

This guide is intended to demonstrate the bare minimum in order to get a django-declarative-apis project up and running. The example directory contains further examples using endpoint to model relationships, authentication and response attribute filtering.

Create django app
-----------------

``` sourceCode
./manage startapp myapp
```

Add app to INSTALLED\_APPS
--------------------------

``` python
INSTALLED_APPS = [
   'django_declarative_apis',
   'myapp',
]
```

Add required config
-------------------

``` python
DECLARATIVE_ENDPOINT_RESOURCE_ADAPTER = 'django_declarative_apis.adapters.EndpointResource'
DECLARATIVE_ENDPOINT_AUTHENTICATION_HANDLERS = 'django_declarative_apis.authentication.oauthlib.oauth1.TwoLeggedOauth1'
```

myapp/urls.py
-------------

``` python
from django_declarative_apis import adapters
import myapp.resources

class NoAuth:
   @staticmethod
   def is_authenticated(request):
      return True


urlpatterns = [
    url(
        r'^ping$',
        adapters.resource_adapter(
            get=myapp.resources.PingDefinition,
            authentication=NoAuth
        )
    ),
]
```

myproject/myproject/urls.py
---------------------------

``` python
from django.conf.urls import url, include
import myapp.urls

urlpatterns = [
   url(r'^', include(myapp.urls)),
]
```

myapp/resources.py
------------------

``` python
from django_declarative_apis import machinery


class PingDefinition(machinery.BaseEndpointDefinition):
    def is_authorized(self):
        return True

    @property
    def resource(self):
        return {'ping': 'pong'}
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "django-declarative-apis",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django,rest,declarative,api",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/d2/e3/d018350eecc1231cc8d3311d4950c3f2eb5fe178b8e6a6efb35a7795ac38/django-declarative-apis-0.31.7.tar.gz",
    "platform": null,
    "description": "[![Documentation Status](https://readthedocs.org/projects/django-declarative-apis/badge/?version=stable)](https://django-declarative-apis.readthedocs.io/en/stable/?badge=stable)\n\n\nOverview\n========\n\ndjango-declarative-apis is a framework built on top of Django aimed at teams implementing RESTful APis. It provides a simple interface to define endpoints declaratively. Some benefits to using django-declarative-apis:\n\n-   Define endpoints declaratively\n-   Define model-bound and unbound resource endpoints with a consistent interface\n-   OAuth 1.0a authentication out of the box\n-   Define resource and endpoint-bound tasks, promoting modularity\n-   Define synchronous and asynchronous tasks (asynchronous tasks implemented with Celery)\n-   Separation of concerns between request body processing and business logic\n\n\nQuick start\n===========\n\nThis guide is intended to demonstrate the bare minimum in order to get a django-declarative-apis project up and running. The example directory contains further examples using endpoint to model relationships, authentication and response attribute filtering.\n\nCreate django app\n-----------------\n\n``` sourceCode\n./manage startapp myapp\n```\n\nAdd app to INSTALLED\\_APPS\n--------------------------\n\n``` python\nINSTALLED_APPS = [\n   'django_declarative_apis',\n   'myapp',\n]\n```\n\nAdd required config\n-------------------\n\n``` python\nDECLARATIVE_ENDPOINT_RESOURCE_ADAPTER = 'django_declarative_apis.adapters.EndpointResource'\nDECLARATIVE_ENDPOINT_AUTHENTICATION_HANDLERS = 'django_declarative_apis.authentication.oauthlib.oauth1.TwoLeggedOauth1'\n```\n\nmyapp/urls.py\n-------------\n\n``` python\nfrom django_declarative_apis import adapters\nimport myapp.resources\n\nclass NoAuth:\n   @staticmethod\n   def is_authenticated(request):\n      return True\n\n\nurlpatterns = [\n    url(\n        r'^ping$',\n        adapters.resource_adapter(\n            get=myapp.resources.PingDefinition,\n            authentication=NoAuth\n        )\n    ),\n]\n```\n\nmyproject/myproject/urls.py\n---------------------------\n\n``` python\nfrom django.conf.urls import url, include\nimport myapp.urls\n\nurlpatterns = [\n   url(r'^', include(myapp.urls)),\n]\n```\n\nmyapp/resources.py\n------------------\n\n``` python\nfrom django_declarative_apis import machinery\n\n\nclass PingDefinition(machinery.BaseEndpointDefinition):\n    def is_authorized(self):\n        return True\n\n    @property\n    def resource(self):\n        return {'ping': 'pong'}\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Simple, readable, declarative APIs for Django",
    "version": "0.31.7",
    "project_urls": null,
    "split_keywords": [
        "django",
        "rest",
        "declarative",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "72029288eaa1f42ac754c28fd01f329d2ccd216b75a38479a70ea4a0488d9342",
                "md5": "afb237807aa4aa954e3d08790c646b03",
                "sha256": "d5ff2707567956a4d9e692ea034a2335af37517be03f2700cd547b17fe64f515"
            },
            "downloads": -1,
            "filename": "django_declarative_apis-0.31.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "afb237807aa4aa954e3d08790c646b03",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 56762,
            "upload_time": "2024-02-08T10:29:05",
            "upload_time_iso_8601": "2024-02-08T10:29:05.478040Z",
            "url": "https://files.pythonhosted.org/packages/72/02/9288eaa1f42ac754c28fd01f329d2ccd216b75a38479a70ea4a0488d9342/django_declarative_apis-0.31.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d2e3d018350eecc1231cc8d3311d4950c3f2eb5fe178b8e6a6efb35a7795ac38",
                "md5": "ee6c531d25a925b5ee9d572d49460bb7",
                "sha256": "c4d19d9e13c57e53da5747b0497f77b2885025628a30029832bbae80125e326d"
            },
            "downloads": -1,
            "filename": "django-declarative-apis-0.31.7.tar.gz",
            "has_sig": false,
            "md5_digest": "ee6c531d25a925b5ee9d572d49460bb7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 51977,
            "upload_time": "2024-02-08T10:29:07",
            "upload_time_iso_8601": "2024-02-08T10:29:07.379843Z",
            "url": "https://files.pythonhosted.org/packages/d2/e3/d018350eecc1231cc8d3311d4950c3f2eb5fe178b8e6a6efb35a7795ac38/django-declarative-apis-0.31.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-08 10:29:07",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "django-declarative-apis"
}
        
Elapsed time: 0.18026s