Skip to main content

Django Rest Framework library to interconnect external APIs

Project description

Django Spook

Library to interconnect multiple external HTTP APIs as Http Services

Installation

pip install spook

Usage

Declare your internal model

class MyModel(models.Model):
    name = models.CharField(max_length=16)
    age = models.IntegerField(default=0)

Declare a serializer class for your external service

from rest_framework import serializers

class MyModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = MyModel
        fields = ('name', 'age', )

Declare a Http Service class and its manager.

from spook.services import HttpService
from spook.managers import DatabaseDataManager

class MyManager(DatabaseDataManager):
    model = MyModel
    serializer = MyModelSerializer

class MyService(HttpService):
    api_url = 'https://my.external/api'
    manager = MyManager

And you can instance MyService class and use the methods

service = MyService()

response = service.list()
data = response.queryset
queryset = data.get_queryset()

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

spook-0.1.0.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

spook-0.1.0-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

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