Client’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 server
# (or local installation, if applicable)
url = """https://<your instance>"""
token = """<your token>"""
pio.client.init_client(url, token)
class previsionio.prevision_client.Client

Client class to interact with the platform and manage authentication.

init_client(prevision_url: str, token: str)

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

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

    Your 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, 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.

  • 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

request response


Exception – Error if url/token not configured