Skip to main content

Muffin-APIClient – Its a plugin for Muffin framework which provides support for external APIs

Tests Status PYPI Version Python Versions

Requirements

  • python >= 3.9

Installation

Muffin-APIClient should be installed using pip:

pip install muffin-apiclient

Usage

Initialize and setup the plugin:

import muffin
import muffin_apiclient

# Create Muffin Application
app = muffin.Application('example')

# Initialize the plugin
# As alternative: apiclient = muffin_apiclient.Plugin(app, **options)
apiclient = muffin_apiclient.Plugin()
apiclient.setup(app, root_url='https://api.github.com')

Github API (https://developer.github.com/v4/):

github = muffin_apiclient.Plugin(app, name='github', root_url='https://api.github.com', defaults={
    'headers': {
        'Authorization': 'token OAUTH-TOKEN'
    }
})

# Read information about the current repository
repo = await github.api.repos.klen['muffin-apiclient'].get()
print(repo)  # dict parsed from Github Response JSON

Slack API (https://api.slack.com/web):

slack = muffin_apiclient.Plugin(app, name='slack', root_url='https://slack.com/api', defaults={
    'headers': {
        'Authorization': 'token OAUTH-TOKEN'
    }
})

# Update current user status (we don't care about this response)
await client.api['users.profile.set'].post(json={
    'profile': {
        'status_text': 'working',
        'status_emoji': ':computer:'
        'status_expiration': 30,
    }
}, read_response_body=False)

And etc

Options

Name

Default value

Desctiption

root_url

None

Define general root URL for the client

timeout

None

Define client timeout

backend_type

httpx

APIClient backend (httpx|aiohttp)

backend_options

{}

Backend options

raise_for_status

True

Raise errors for HTTP statuses (300+)

read_response_body

True

Read responses

parse_response_body

True

Parse responses (load json, etc)

client_defaults

{}

Default client values (headers, auth, etc)

You are able to provide the options when you are initiliazing the plugin:

apiclient.setup(app, root_url='https://api.github.com')

Or setup it inside Muffin.Application config using the APICLIENT_ prefix:

APICLIENT_ROOT_URL = 'https://api.github.com'

Muffin.Application configuration options are case insensitive

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/muffin-apiclient/issues

Contributing

Development of Muffin-APIClient happens at: https://github.com/klen/muffin-apiclient

Contributors

  • klen (Kirill Klenov)

License

Licensed under a MIT license.

Metadata

Release files for muffin-apiclient 3.9.0

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

Source distribution (sdist)

Source distribution for muffin-apiclient 3.9.0
File Size Uploaded
muffin_apiclient-3.9.0.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for muffin-apiclient 3.9.0
File Interpreter ABI Platform
muffin_apiclient-3.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.0 kB

Release files / muffin_apiclient-3.9.0.tar.gz

Download URL muffin_apiclient-3.9.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
aa2918bb37455895a69e7a3d39b880996bf436d3368ec8e16ef702f264364c30
BLAKE2b-256 checksum
How to use checksums
25d9479d0c57805c0791c35a9006e7f81ee88dc57bfbfe7dc9d99015da02f850
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1012-azure

Release files / muffin_apiclient-3.9.0-py3-none-any.whl

Download URL muffin_apiclient-3.9.0-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5448f0da9283880b0ad227868c6a0fdc3c6e122e146d853f262685b2d28f63f
BLAKE2b-256 checksum
How to use checksums
4d736c39471bc9f4d661ca027c530fb20a6d6d95b27bd8296b84ff2742233c20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-1012-azure

Release history Release notifications | RSS feed

This release

3.9.0 This release

2 release files

3.8.1

2 release files

3.8.0

2 release files

3.7.1

2 release files

3.7.0

2 release files

3.6.0

2 release files

3.5.1

2 release files

3.5.0

2 release files

3.4.1

2 release files

3.4.0

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

0.1.2

2 release files

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