dark theme
hamburger menu
Stock market charts
Historical price charts
In this section, we will learn how to use Python's Matplotlib module to build interactive charting tools for any stock we input. We are going to take a look at a simple historical price chart with a one year timeframe by filtering the API by the yearly key.
import requests
import json
import matplotlib.pyplot as plt

secret = "..."
url = "" + secret

r = requests.get(url).json()["priceData"]["yearlyPrices"]
Explanation: We first defined variables for our account secret key, and the main Styvio V2 API URL. Then, we used requests.get() in combination with .json() to query the yearly prices from the response. From there, Matplotlib makes it very easy to generate a simple interactive plot.
guide image View price data docs arrow vector
Shareholder donut
Here you will learn to query the shareholder response from the API in order to build a donut chart for that breaks down general publi, insider, and institutional ownership of your inputted stock.
import requests
import json
matplotlib.pyplot as plt

secret = "..."
url = "" + secret

r = requests.get(url).json()["fundamentals"]["shareholderBreakdown"]
Explanation: Instead of selecting price values from the API response, we filter out the shareholder breakdown this time. Now using those values, we build and plot an array using a Matplotlib donut chart.
guide image View shareholder docs arrow vector
ZipLine storage examples
Uploading files
Select a file from your computer or server and upload it to your zipline storage account. Connect via your storage key.
import requests
import json
import os

uploadFiles={'uploadFile': open('myPhoto.png','rb')}
body={"storageKey": "..."}
r = = url, data=body).json()

response =, files=uploadFiles, data=body).json()
Explanation: Here we imported some basic modules, and then defined variables for our local file we want to upload, the API endpoint, and the POST body. Printing the JSON response helps us confirm the file was uploaded as well as copy the link to use inside projects.
{'connectedUser': '...', 'uploadedFileID': '...', 'uploadedFileLink': 'https://styviostorage...'}
Response: The JSON response will contain the keys: connectedUser, uploadedFileID, and uploadedFileLink. If you are uploading static files to use inside a project the uploadedFileLink value can be copied directly into your code to serve the files.
View zipline docs arrow vector
Downloading files
Enter an object ID from your zipline storage account to receive a download or CDN link to use in your projects. This example uses that link to save a downloaded file to your desktop.
import requests
import json
import os

def download_file(url):
local_filename = url.split('/')[-1]

with requests.get(url, stream=True) as r:

with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
Explanation: Here we imported some modules we will use, as well as set up a function for processing a streamed file. This function accepts a download link, and downloads to our local desktop.
body={"storageKey": "...", "fileID": "..."}
linkFile =, data=body).json()["downloadLink"]

Explanation: This is the zipLine API call. We save the "downloadLink" of the response to a local variable called linkFile, which we then pass to our download_file function. Our file appears on the desktop.
View zipline docs arrow vector