Skip to main content

A JSON-RPC client library, backed by requests

Project description

https://travis-ci.org/gciotta/jsonrpc-requests.svg https://coveralls.io/repos/gciotta/jsonrpc-requests/badge.svg

This is a compact (~100 SLOC) and simple JSON-RPC client implementation written while debugging a picky server.

Main Features

  • Python 2.7 & 3.4 compatible

  • Exposes requests options

  • Supports nested namespaces (eg. app.users.getUsers())

  • 100% test coverage

TODO

Usage

from jsonrpc_requests import Server
server = Server('http://localhost:8080')
server.foo(1, 2)
server.foo(bar=1, baz=2)
server.foo.bar(baz=1, qux=2)

A notification:

from jsonrpc_requests import Server
server.foo(bar=1, _notification=True)

Pass through arguments to requests (see also requests documentation)

from jsonrpc_requests import Server
server = Server('http://localhost:8080', auth=('user', 'pass'), headers={'x-test2': 'true'})

Pass through requests exceptions

from jsonrpc_requests import Server, TransportError
server = Server('http://unknown-host')
try:
    server.foo()
except TransportError as transport_error:
    print(transport_error.args[1]) # this will hold a `requests.exceptions.RequestException` instance

Tests

Install the Python tox package and run tox, it’ll test this package with Python 2.7 and 3.4.

Credits

@mbroadst for providing full support for nested method calls, JSON-RPC RFC compliance and other improvements.

@vaab for providing api and tests improvements, better RFC compliance.

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

jsonrpc-requests-0.2.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file jsonrpc-requests-0.2.tar.gz.

File metadata

File hashes

Hashes for jsonrpc-requests-0.2.tar.gz
Algorithm Hash digest
SHA256 fff5ee473e26fdb00cc7ec9188b7db69052feb014721da133e7321a7d5bee2b2
MD5 fa6b4c166a79179951b1914332b02f69
BLAKE2b-256 a7a0084a4afb1e87dd07d54fa09045c0b0637f74dd2e3b883c7447733d428771

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page