Skip to main content

apiron helps you cook a tasty client for RESTful APIs. Just don't wash it with SOAP.

Project description

apiron

Documentation Status PyPI version Build Status

apiron helps you cook a tasty client for RESTful APIs. Just don't wash it with SOAP.

Pie in a cast iron skillet

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apiron-2.2.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

apiron-2.2.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file apiron-2.2.0.tar.gz.

File metadata

  • Download URL: apiron-2.2.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for apiron-2.2.0.tar.gz
Algorithm Hash digest
SHA256 e58d450721e8cec8147d5a9cd65c20af411a4e4aef8ff5de09519646a6f5de8e
MD5 f61f31884246f2ea4ffe08aaffd5d387
BLAKE2b-256 1c3baec94ae124d2d9e4513643d4ba6dcfea1dae4eafd7f611217b9dda1984ad

See more details on using hashes here.

File details

Details for the file apiron-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: apiron-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for apiron-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b112bc9c678566fd480087b8b47d6357f26b34d9d0a9121a01d1ec708fdd7df3
MD5 287edf6b94bcd8acee9c36b3bbc66779
BLAKE2b-256 7356996eb564986b572f390d51e1fd06745ca9ef757ce0ee4608ad15c596f741

See more details on using hashes here.

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