apiron helps you cook a tasty client for RESTful APIs. Just don't wash it with SOAP.
Project description
apiron
apiron helps you cook a tasty client for RESTful APIs. Just don't wash it with SOAP.
Gathering data from multiple services has become a ubiquitous task for web application developers. The complexity can grow quickly: calling an API endpoint with multiple parameter sets, calling multiple API endpoints, calling multiple endpoints in multiple APIs. While the business logic can get hairy, the code to interact with those APIs doesn't have to.
apiron provides declarative, structured configuration of services and endpoints
with a unified interface for interacting with them.
Defining a service
A service definition requires a domain and one or more endpoints with which to interact:
from apiron.service.base import Service
from apiron.endpoint import JsonEndpoint
class GitHub(Service):
domain = 'https://api.github.com'
user = JsonEndpoint(path='/users/{username}')
repo = JsonEndpoint(path='/repos/{org}/{repo}')
Interacting with a service
Once your service definition is in place, you can interact with its endpoints
using the ServiceCaller:
from apiron.client import ServiceCaller
github = GitHub()
response = ServiceCaller.call(
github,
github.user,
path_kwargs={'username': 'defunkt'},
) # {"name": "Chris Wanstrath", ...}
response = ServiceCaller.call(
github,
github.repo,
path_kwargs={'org': 'github', 'repo': 'hub'},
) # {"description": "hub helps you win at git.", ...}
To learn more about building clients, head over to the docs.
Contributing
We are happy to consider contributions via pull request, especially if they address an existing bug or vulnerability. Please read our contribution guidelines before getting started.
License
This package is available under the MIT license. For more information, view the full license and copyright notice.
Copyright 2018 Ithaka Harbors, Inc.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file apiron-2.0.0.tar.gz.
File metadata
- Download URL: apiron-2.0.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.4.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecc89d5faff0a675452b00dd8f53e11238703ccd9620a917de4156c30a8103b6
|
|
| MD5 |
e93e0b7f00c6b68b9e9bbbb68b81790d
|
|
| BLAKE2b-256 |
d593340d86751047a8d4a58d60c235471493cc2aef05ca0adb73c1f233f4292b
|
File details
Details for the file apiron-2.0.0-py3-none-any.whl.
File metadata
- Download URL: apiron-2.0.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.4.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9234ad31588de5e22bd4e15c45ed5a14a137c87d18e08631054592e98754ec2
|
|
| MD5 |
997c1dafec1af9e62202683b3318c15c
|
|
| BLAKE2b-256 |
438842db6b92d418f3ad52f46500c5f676a9590b5256f543471d69da983ea39a
|