Skip to main content

2 posts tagged with "web API"

View All Tags

· One min read
Mario Frei

We are happy to announce that we have published version three of Cozie-Apple. We worked towards a cleaner, simpler code base in the app and the backend while also improving reliability. We have already started working with Cozie v3 and it is already deployed for research.

New features in Cozie v3

We have added more content to the website:

· One min read
Mario Frei

We have updated the web APi for Cozie data retrieval. The change became necessary as the requests from some users exceeded the current payload limit of 6 MB. The example script was changed in to places:

  1. The 'shutil' module needs to be imported at the beginning
import shutil
  1. The new web API doesn't serve the data as JSON string. Instead, it is a two-step process. Firstly, a link is provided to a zipped .csv-file containing the data. Hence, the provided link needs to be called to then download the actual data.
# Download zipped CSV file with Cozie data
with requests.get(url, stream=True) as r:
with open('', 'wb') as f:
shutil.copyfileobj(r.raw, f)

# Convert zipped CSV file with Cozie to dataframe
with open('', 'rb') as f:
df = pd.read_csv(f, compression={'method': 'zip', 'archive_name': 'sample.csv'})

df = df.drop(columns=['Unnamed: 0'])

The initial call of the web API and the timezone manipulation of the dataframe remains the same, as does the resulting Pandas dataframe.