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.resources import APIResource
from spook.managers import DatabaseDataManager
class MyManager(DatabaseDataManager):
model = MyModel
serializer = MyModelSerializer
class MyResource(APIResource):
api_url = 'https://my.external/api'
manager = MyManager
And you can instance MyService class and use the methods
resource = MyResource()
response = resource.list()
data = response.queryset
queryset = data.get_queryset()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spook-2.0.0.tar.gz
(5.5 kB
view hashes)
Built Distribution
spook-2.0.0-py3-none-any.whl
(6.6 kB
view hashes)