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 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.

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.2.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

django_simple_api-0.2.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-simple-api-0.2.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for django-simple-api-0.2.0.tar.gz
Algorithm Hash digest
SHA256 877b6acc28f3d4c9c96a19b6f7681d57d6dead76c7015af8bd0a1600b4913925
MD5 6ca4d7835d609f6e8ecf76dddf5a5198
BLAKE2b-256 30051e616a547ad3075b8111c380600b1c28a2b4e84b474ff20fe4ab22286481

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_simple_api-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 743288efb669f15f7fb51bb712a7ab40c4957601d6799aef53397292aba6f75a
MD5 83b1097cc71806ebda5ce35c800facd5
BLAKE2b-256 299ae4c6da8c9992cadf4d2e597629ebfc7fd5f8f0fc92db251de896ce7c7a5a

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