Skip to main content

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

Project description

Django Simple API

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

Quick Start

Install

Download and install from github:

pip install git+https://github.com/Django-Simple-API/django-simple-api.git@setup.py

Or from coding mirror in China:

pip install git+https://e.coding.net/aber/github/django-simple-api.git@setup.py

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-simple-api-0.1.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

django_simple_api-0.1.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file django-simple-api-0.1.0.tar.gz.

File metadata

  • Download URL: django-simple-api-0.1.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

File hashes

Hashes for django-simple-api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0b24f4b37cb5f3579062ddc23671b92942997647dc5bf4678bb41eb911e92ae0
MD5 aa2478aeb33f9f504127ca52ba897d9f
BLAKE2b-256 c16dc429cb40ee4944c9c808dbe152f4017e3989719df260734f9e3426a7f192

See more details on using hashes here.

File details

Details for the file django_simple_api-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_simple_api-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

File hashes

Hashes for django_simple_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be90cef57a23a66b92a14766a6d884845c4034a3f6c26ebe4b4ee1441c837b5d
MD5 1d0a55eed920967f7637258f7ce4ca5f
BLAKE2b-256 ae39637f67c1908efed690d6266a676ebd09e1c758219c8875ddaeb2441f2f74

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page