Using The API

You can access every object generated by Prevision Platform from the API .

To run the Code below you need your Master Token. It is available in the API Key page of your user settings :

User Settings

You can use the native urllib module to parse API. This page show how to use API with raw python but we suggest to use the SDK ( Python and R ) for an higher level of abstraction.

First, import native python 3 urllib.request and set up your Token ( warning : if you have an on promise server or custom dedicated domain, you need to replace the url « cloud.prevision.io » with your own )

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import urllib.request
import pandas as pd
import ssl
import json

MASTER_TOKEN="<YOUR_MASTER_TOKEN>"

BASE_PATH ="https://cloud.prevision.io/ext/v1"

projectsurl = f"{BASE_PATH}/projects"
request = urllib.request.Request(projectsurl)
request.add_header('Authorization',MASTER_TOKEN )
# Disable SSL check
projectslist = urllib.request.urlopen(request, context=ssl.SSLContext()).read()
projectslist = json.loads(projectslist)