Simple, readable, declarative APIs for Django
Project description
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
./manage startapp myapp
Add app to INSTALLED_APPS
INSTALLED_APPS = [
'django_declarative_apis',
'myapp',
]
Add required config
DECLARATIVE_ENDPOINT_RESOURCE_ADAPTER = 'django_declarative_apis.adapters.EndpointResource'
DECLARATIVE_ENDPOINT_AUTHENTICATION_HANDLERS = 'django_declarative_apis.authentication.oauthlib.oauth1.TwoLeggedOauth1'
myapp/urls.py
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
from django.conf.urls import url, include
import myapp.urls
urlpatterns = [
url(r'^', include(myapp.urls)),
]
myapp/resources.py
from django_declarative_apis import machinery
class PingDefinition(machinery.BaseEndpointDefinition):
def is_authorized(self):
return True
@property
def resource(self):
return {'ping': 'pong'}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-declarative-apis-0.31.7.tar.gz
.
File metadata
- Download URL: django-declarative-apis-0.31.7.tar.gz
- Upload date:
- Size: 52.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4d19d9e13c57e53da5747b0497f77b2885025628a30029832bbae80125e326d |
|
MD5 | ee6c531d25a925b5ee9d572d49460bb7 |
|
BLAKE2b-256 | d2e3d018350eecc1231cc8d3311d4950c3f2eb5fe178b8e6a6efb35a7795ac38 |
File details
Details for the file django_declarative_apis-0.31.7-py3-none-any.whl
.
File metadata
- Download URL: django_declarative_apis-0.31.7-py3-none-any.whl
- Upload date:
- Size: 56.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5ff2707567956a4d9e692ea034a2335af37517be03f2700cd547b17fe64f515 |
|
MD5 | afb237807aa4aa954e3d08790c646b03 |
|
BLAKE2b-256 | 72029288eaa1f42ac754c28fd01f329d2ccd216b75a38479a70ea4a0488d9342 |