Skip to main content

StackHut Client Library

https://img.shields.io/travis/stackhut/client-python.svg https://img.shields.io/pypi/v/stackhut-client.svg

StackHut client library to call dev, local, and hosted StackHut services dynamically and asynchronously from your Python code as if it were a local function.

Description

There are 3 main objects in the library,

SHService

This is the main library you create per service to communicate with it. It takes several parameters on construction, where those in square brackets are optional,

import stackhut_client as client
client.SHService(author, service_name, [service_version], [auth], [host])
  • author - The author of the service

  • service_name - The service name

  • version - The specific verion of the service (is latest if left blank)

  • auth - An SHAuth object used to authenticate requests for private services

  • host - URL for the StackHut API server, can be set to point to local servers during development, is https://api.stackhut.com if left blank

To make a remote call, just call the interface and method name on the service object, e.g.,

result = service.Interface.method(params, ...)

SHAuth

An optional object used to authenticate requests to a service,

client.SHAuth(user, [hash], [token])
  • user - Username of a registered StackHut user

  • hash - Hash of the user’s password (you can find this in ~/.stackhut.cfg). Be careful not to use in public-facing code.

  • token - A valid API token created for the user

One of hash or token must be present in the auth object to authorise a request by the given user.

SHError

Returned in the event of a remote service error in the catch block of a rejected promise.

The object has 3 parameters,

  • code - The RPC error code

  • message - A string describing the error

  • data - An optional object that may contain additional structured data for handling the error

Example

Using the existing service called demo-nodejs by user stackhut, we create the main service object,

import stackhut_client as client
service = client.SHService('stackhut', 'web-tools')

From here we can call any functions on any interfaces exposed by the hosted stackhut/demo-nodejs service, as follows,

result = service.Default.renderWebpage("http://www.stackhut.com", 1024, 768)
print("Page render at {}".format(result))

Notes

  • Python 3+ only currently (built on 3.4), looking into python-future for 2.x compatibility.

  • Calls are currently synchronous but we will switch to an async-based solution following the release of Python 3.5.

Credits

Development Leads

Release files for stackhut-client 0.1.1

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

Built distribution (wheel)

Table of built distributions (wheels) for stackhut-client 0.1.1
File Interpreter ABI Platform
stackhut_client-0.1.1-py3-none-any.whl Python 3 none any Details

Release files / stackhut_client-0.1.1-py3-none-any.whl

Download URL stackhut_client-0.1.1-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a65cd18133b0b4b4128dc53e23b9230a04a7d22094f425d19eb891b68a3d50dc
BLAKE2b-256 checksum
How to use checksums
86a017bbc4bfa004b132ac9f706ad6f0aba168ac668e15ac961f2344577b5a5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

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