Skip to main content

Thorgate API Core

https://img.shields.io/pypi/v/tg-apicore.svg https://img.shields.io/travis/thorgate/tg-apicore.svg Documentation Status

Opinionated API framework on top of Django REST framework

  • Free software: ISC license

Supports Python 3.5+, Django 1.11+, Django REST framework 3.6+

Features

  • API documentation automatically generated from your views
    • General intro can be added

    • You can add example request/response data

    • Autogenerated Python requests-based examples

    • Not interactive yet

  • Integrates JSON API
    • Cursor pagination with configurable page size

  • Viewset classes for using different serializers and querysets for list/detail/edit endpoints

  • API-specific 404 view

  • Test utilities, e.g. for response validation

  • Versioning (WIP)

Usage

  • pip install tg-apicore

  • Add tg_apicore to INSTALLED_APPS

  • Ensure your REST_FRAMEWORK setting contains ALLOWED_VERSIONS, e.g:

    # In your Django project settings:
    REST_FRAMEWORK = {
        'ALLOWED_VERSIONS': ('2018-01-01',),
    }
  • Note that the default paginator requires that your models have created field

  • Create API documentation view by subclassing APIDocumentationView and making necessary modifications. See example/example/views.py for example.

  • Add main API urls plus 404 view (as fallback).

Here’s an example urls.py:

from tg_apicore.views import PageNotFoundView

from myproject.views import MyProjectAPIDocumentationView

urlpatterns = [
    # The documentation view
    url(r'^api-docs/', MyProjectAPIDocumentationView.as_view(), name='api-docs'),

    # myproject.urls_api should contain your API urls patterns
    url(r'^api/(?P<version>(\d{4}-\d{2}-\d{2}))/', include('myproject.urls_api')),

    # API-specific 404 for everything under api/ prefix
    url(r'^api/', include(PageNotFoundView.urlpatterns())),
]

See example directory for a more in-depth demo.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.3.0 (2018-05-23)

  • Add Usage section to README (to make starting up easier)

  • Most REST_FRAMEWORK settings are now automatically configured by Thorgate API Core. Users only need to specify ALLOWED_VERSIONS, the rest is optional.

0.2.1 (2018-04-14)

  • Fix packaging (tg_apicore subdirs weren’t included)

0.2.0 (2018-04-14)

  • Added PageNotFoundView (JSON-based 404 views)

  • Added DetailSerializerViewSet (different serializers and queryset for list/detail/edit views)

  • Added CreateOnlyFieldsSerializerMixin, ModelValidationSerializerMixin and BaseModelSerializer

  • Renamed APIDocumentationView.get_patterns() to .urlpatterns()

  • Improved example app a lot. It now also includes tests that partially test tg-apicore itself

0.1.0 (2018-03-08)

  • First release on PyPI.

Metadata

Release files for tg-apicore 0.3.0

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

Source distribution (sdist)

Source distribution for tg-apicore 0.3.0
File Size Uploaded Provenance
tg-apicore-0.3.0.tar.gz 22.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for tg-apicore 0.3.0
File Interpreter ABI Platform
tg_apicore-0.3.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 46.3 kB

Release files / tg-apicore-0.3.0.tar.gz

Download URL tg-apicore-0.3.0.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
da47e7539dc080bced58f982df7aba14aa22226473bb7685085e07d063320a03
BLAKE2b-256 checksum
How to use checksums
0cf2a32347f79323716be0c168d4379aaf52e784b63aebc813c6c17cec9f6ff9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / tg_apicore-0.3.0-py2.py3-none-any.whl

Download URL tg_apicore-0.3.0-py2.py3-none-any.whl
Size 23.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ac7c9a749b950b1e7e7f5da76c63d809a41e08d772faea62c53847a93b2329b4
BLAKE2b-256 checksum
How to use checksums
0d8bc209afe8f2ef5ec4de9c27501fae51bd0d07cd1dcc593f7e443be9e423d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for tg-apicore 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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