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, token)

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

  • prevision_url (str) – URL of the platform. Should be if you’re in the cloud, or a custom IP address if installed on-premise.
  • token (str) –

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

    client.init_client_with_login(prevision_url, email, password)
request(endpoint, method, files=None, data=None, allow_redirects=True, content_type=None, no_retries=False, **requests_kwargs)

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

Requires initialization.

  • endpoint – (str): api endpoint (e.g. /usecases, /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
  • no_retries (bool) – force request to run the first time, or exit directly

request response


Exception – Error if url/token not configured