[](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'}
```
Optional: Implement Custom Event Hooks for Event Emission
-----
```bash
# settings.py
DDA_EVENT_HOOK = "my_app.hooks.custom_event_handler"
```
Raw data
{
"_id": null,
"home_page": null,
"name": "django-declarative-apis",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "django, rest, declarative, api",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/3f/9c/5a6912cca94da8a898bcb72ae103f47abbcd1d5eb1ada6e85ebf99c81d1d/django_declarative_apis-0.34.1.tar.gz",
"platform": null,
"description": "[](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\nOptional: Implement Custom Event Hooks for Event Emission\n-----\n```bash\n# settings.py \nDDA_EVENT_HOOK = \"my_app.hooks.custom_event_handler\"\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Simple, readable, declarative APIs for Django",
"version": "0.34.1",
"project_urls": null,
"split_keywords": [
"django",
" rest",
" declarative",
" api"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "fd25955453df351cfc911aceed70a4004dd143b38c46190c2e49ee1ec2d5d9a6",
"md5": "9bebc9fbf6b201ba5baffed10f5b44b4",
"sha256": "3c3edc2240a6145f9a800daaa2bf2387f74bc8077ae94fb5f6e5a1b183b1a115"
},
"downloads": -1,
"filename": "django_declarative_apis-0.34.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9bebc9fbf6b201ba5baffed10f5b44b4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 58716,
"upload_time": "2025-07-22T22:37:53",
"upload_time_iso_8601": "2025-07-22T22:37:53.138285Z",
"url": "https://files.pythonhosted.org/packages/fd/25/955453df351cfc911aceed70a4004dd143b38c46190c2e49ee1ec2d5d9a6/django_declarative_apis-0.34.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "3f9c5a6912cca94da8a898bcb72ae103f47abbcd1d5eb1ada6e85ebf99c81d1d",
"md5": "fb839314f2de6b678118259bf267abe3",
"sha256": "c54c50a5e814aa51db32837265840ecab30384772d8c7c20f96bdbf3888d4627"
},
"downloads": -1,
"filename": "django_declarative_apis-0.34.1.tar.gz",
"has_sig": false,
"md5_digest": "fb839314f2de6b678118259bf267abe3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 54134,
"upload_time": "2025-07-22T22:37:54",
"upload_time_iso_8601": "2025-07-22T22:37:54.549646Z",
"url": "https://files.pythonhosted.org/packages/3f/9c/5a6912cca94da8a898bcb72ae103f47abbcd1d5eb1ada6e85ebf99c81d1d/django_declarative_apis-0.34.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-22 22:37:54",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "django-declarative-apis"
}