Skip to main content

ArcStack Django API Framework

Tests

This is a simple yet extensible API framework for Django that you can create API endpoints Django way.

Check out Documentation for more info.

Sponsoring

Maintaining an open-source project requires attention and time. If you like this project and want it to be developed further, you might want to consider giving me a support.

If you are using ArcStack API in your project, please give me your feedback at me@gokhan.tr.

Installation

pip install arcstack-django-api

Usage

ArcStack Django API comes with CommonMiddleware enabled. This middleware can convert your endpoint results to HttpResponse, handle exceptions and check for logged in users.

Usage with class-based views:

from arcstack_api import Endpoint, APIError

class StatusOk(Endpoint):
    # By default all defined enpoints do not require logged in user
    # You can change this behavior with this class constant.
    LOGIN_REQUIRED = True

    def get(self, request, a: str | None = None):
        if a == "something_invalid":
            # This `dict` will be converted to `JSON` and `HttpResponse`
            # will be generated
            raise APIError(
                {"error": "you have passed invalid argument"}
                # The default status_code is `400` but it can be changed to
                # anything you want.
                status_code=480
            )

        # ArcStack API will serialize this to JSON and generate
        # a `HttpResponse` for you.
        return {"status": "OK"}

Usage with function views:

from arcstack_api import api_endpoint, Endpoint, APIError

@api_endpoint(login_required=True)
def statusOk(request, a: str | None = None):
    if a == "something_invalid":
        raise APIError(
            {"error": "you have passed invalid argument"}
            status_code=480
        )

    return {"status": "OK"}

In urls.py

from django.urls import path

from . import endpoints

urlpatterns = [
    # For class-based views:
    path("api", endpoints.StatusOk.as_endpoint()),
    # For function views:
    path("api", endpoints.statusOk),
]

Release files for arcstack-django-api 0.2.1

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

Source distribution (sdist)

Source distribution for arcstack-django-api 0.2.1
File Size Uploaded
arcstack_django_api-0.2.1.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arcstack-django-api 0.2.1
File Interpreter ABI Platform
arcstack_django_api-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.1 kB

Release files / arcstack_django_api-0.2.1.tar.gz

Download URL arcstack_django_api-0.2.1.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e53786d5ff02ba033f2b075696a360a7309e0d21e60d611bfb5985d43598a6d0
BLAKE2b-256 checksum
How to use checksums
3366d9609efbfdbb173abeea7f841634cdab75555af758f83609c1788a7532fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure

Release files / arcstack_django_api-0.2.1-py3-none-any.whl

Download URL arcstack_django_api-0.2.1-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
baad75d410bb95bcc1b923aa7e7f28232fb470066583357651d9a9303bea7807
BLAKE2b-256 checksum
How to use checksums
031afd35e071a49a4c15269a13ab1060856bf70504b0cfdffda815747925d24b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.1

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