Skip to main content

Language: English | Chinese

Django Simple API

A non-intrusive component that can help you quickly create APIs.

Quick Start

Install

Download and install from github:

pip install django-simple-api

Configure

Add django-simple-api to your INSTALLED_APPS in settings:

INSTALLED_APPS = [
    ...,
    "django_simple_api",
]

Register the middleware to your MIDDLEWARE in settings:

MIDDLEWARE = [
    ...,
    "django_simple_api.middleware.SimpleApiMiddleware",
]

Add the url of django-simple-api to your urls.py:

# urls.py

from django.urls import include, path
from django.conf import settings

# Your urls
urlpatterns = [
    ...
]

# Simple API urls, should only run in a test environment.
if settings.DEBUG:
    urlpatterns += [
        # generate documentation
        path("docs/", include("django_simple_api.urls"))
    ]

Complete the first example

Define your url:

# your urls.py

from django.urls import path
from yourviews import JustTest

urlpatterns = [
    ...,
    path("/path/<int:id>/", JustTest.as_view()),
]

Define your view:

# your views.py

from django.views import View
from django.http.response import HttpResponse

from django_simple_api import Query


class JustTest(View):
    def get(self, request, id: int = Query()):
        return HttpResponse(id)

⚠️ To generate the document, you must declare the parameters according to the rules of Simple API (like the example above).

Click Declare parameters to see how to declare parameters.

Access interface document

After the above configuration, you can start your server and access the interface documentation now.

If your service is running locally, you can visit http://127.0.0.1:8000/docs/ to view your documentation.

More

For more tutorials, see Django Simple API.

Metadata

Release files for django-simple-api 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-simple-api 0.2.2
File Size Uploaded
django-simple-api-0.2.2.tar.gz 676.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-simple-api 0.2.2
File Interpreter ABI Platform
django_simple_api-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 1.4 MB

Release files / django-simple-api-0.2.2.tar.gz

Download URL django-simple-api-0.2.2.tar.gz
Size 676.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bb8fac7019bd80ea4af6f5fcb99e07cb233bd9678ae0ad92e422f7b465dc3b6c
BLAKE2b-256 checksum
How to use checksums
4e51e1d9667b1c76f5f1108d6e087278e293762ccd04c6ac9f26d17b751bc8a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.3

Release files / django_simple_api-0.2.2-py3-none-any.whl

Download URL django_simple_api-0.2.2-py3-none-any.whl
Size 684.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1d93f0e8f69dcfbaf72902569da3fd1db63f2080bc843e8fcca3a3551cdaf34
BLAKE2b-256 checksum
How to use checksums
be885a0cb4be7c2c603715ad7a280d32138a4833a1b068748f95ea9740c29582
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page