Skip to main content

A wrapper for REST APIs

Maturity License Change Log Build Status Version

About

Syndicate is a library for using HTTP based REST APIs. This provides a means to generically handle serialization (JSON, XML) and URI mapping as seen in many of the REST APIs published these days. Currently Tastypie APIs are the primary target but the system should be compossible enough to work with other APIs if they work roughly the same way.

Requirements

  • Requests (sync mode)

  • aiohttp (async mode)

Installation

python ./setup.py build
python ./setup.py install

Compatibility

  • Python 3.4+

TODO

  • Unified authentication between HTTP adapters.

  • Documentation

Getting Started

Syndicate has two basic modes for communicating with an API, sync and async. The sync mode uses the ‘requests’ library as the HTTP adapter and the async mode uses aiohttp. An adapter can be provided by the user if they have their own backend.

In either mode, your interface is a ‘Service’ instance, which facilitates authentication, session management (via an adapter) and serialization.

Synchronous Examples

Creating a connnection

Instantiate a service class with some basic descriptions of the remote API to get a persistent connection.

import syndicate

bakery = syndicate.Service(uri='https://a.bakery.fake', urn='/api/v1/',
                           auth=('mrpresident', '1000xlight_points'))

Simple GET

Fetch all the resources at https://a.bakery.fake/api/v1/cake/

for x in bakery.get('cake'):
    print("Cake is food:", x)

Adding a new resource

new_owl = bakery.post('cake', {
    "type": "chuck_norris",
    "name": "Round House",
    "scovilles": 16000000001  # sorry resiniferatoxin
})

Non CRUD methods

If your service has non CRUD methods, you can ask a service to “do” things directly. Let’s “BAKE /api/v1/cake/100” with some instructions in the content body.

bakery.do('bake', 'cake', 100, temp=420, time=3600)

Release files for syndicate 2.1.2

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

Source distribution (sdist)

Source distribution for syndicate 2.1.2
File Size Uploaded
syndicate-2.1.2.tar.gz 10.8 kB Details

Release files / syndicate-2.1.2.tar.gz

Download URL syndicate-2.1.2.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
74ab58a7e91ab601aa7d656dbd32b374679ca1f24ce8f6929d91c7255e2162e4
BLAKE2b-256 checksum
How to use checksums
18298f86546a02f0372fcae4aad4aefaf0ebff22548d6dc7d7d9a8ee04b0c47b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.0.0

1 release file

2.3.0

1 release file

2.2.1

1 release file

2.2.0

1 release file

2.1.3

1 release file

This release

2.1.2 This release

1 release file

2.1.1

1 release file

2.1

1 release file

2

1 release file

1.4.0

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.99.9

1 release file

0.99.8

1 release file

0.99.7

1 release file

0.99.6

1 release file

0.99.5

1 release file

0.99.4

1 release file

0.99.3

1 release file

0.99.2

1 release file

0.99.1

1 release file

0.99.0

1 release file

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