Client

Prevision.io’s SDK client uses a specific master token to authenticate with the instance’s server and allow you to perform various requests. To get your master token, log in the online interface, navigate to the admin page and copy the token.

You can either set the token and the instance name as environment variables, by specifying PREVISION_URL and PREVISION_MASTER_TOKEN, or at the beginning of your script:

import previsionio as pio

# We initialize the client with our master token and the url of the prevision.io server
# (or local installation, if applicable)
url = """https://<your instance>.prevision.io"""
token = """<your token>"""
pio.client.init_client(url, token)
class previsionio.prevision_client.Client

Client class to interact with the Prevision.io platform and manage authentication.

init_client(prevision_url: str, token: str)

Init the client (and check that the connection is valid).

Parameters:
  • prevision_url (str) – URL of the Prevision.io platform. Should be of the form https://<instance_name>.prevision.io, or a custom IP address if working on-premise.
  • token (str) –

    Your Prevision.io master token. Can be retrieved on /dashboard/infos on the web interface or obtained programmatically through:

    client.init_client(prevision_url, token)
    
request(endpoint: str, method, files: Dict = None, data: Dict = None, format: Dict = None, allow_redirects: bool = True, stream: bool = False, is_json: bool = True, content_type: str = None, check_response: bool = True, message_prefix: str = None, **requests_kwargs) → requests.models.Response

Make a request on the desired endpoint with the specified method & data.

Requires initialization.

Parameters:
  • endpoint (str) – api endpoint (e.g. /experiments, /prediction/file)
  • method (requests.{get,post,delete}) – requests method
  • files (dict) – files dict
  • data (dict) – for single predict
  • content_type (str) – force request content-type
  • allow_redirects (bool) – passed to requests method
  • check_response (bool) – wether to handle error or not
  • message_prefix (str) – prefix message in error logs
Returns:

request response

Raises:

Exception – Error if url/token not configured