Climaps API  version 1
Static Public Member Functions | List of all members
downloads Class Reference

Static Public Member Functions

static addJob ()
 
static getOwnJob ()
 
static getOwnJobs ()
 

Static Public Attributes

static STATUS_QUEUED = 1
 The job is queued and will be processed as soon as a download slot will be available.
 
static STATUS_ONGOING = 2
 The job is currently being processed.
 
static STATUS_COMPLETED = 3
 The job has been completed and data is ready to be downloaded.
 
static MAX_DOWNLOAD_RANGE = 315360000
 Maximum range in seconds, scale with the number of stations (e.g., 1 station: MAX_DOWNLOAD_RANGE, 2 stations: MAX_DOWNLOAD_RANGE / 2, ...)
 
static MAX_CONCURRENT_JOBS = 5
 Maximum number of concurrent jobs (queued or ongoing) for a single user.
 

Detailed Description

This class lets you asynchronously download large amounts of data as a .zip file.

There is a global queue among all Climaps users where jobs are stored. Once a download slot becomes free, the oldest queued job is processed. Once completed, a zip file with the requested data is generated and the job is removed from the queue.

Usage is as follows:

Note
Zip files are automatically removed after a few days (typically 5 days)

Member Function Documentation

static downloads::addJob ( )
static

Queue a new download job.

Parameters
stringnameThe job name
intfromBegining of the time interval, in epoch time
inttoEnd of the time interval, in epoch time
stringstationsThe list of stations as a comma-separated string (e.g., '300,652,666')
stringfileFormatOptional The file format: csv, csvxls, or matlab (default)
stringdateFormatOptional The date format: epoch (default), xlstime, plaintext, or iso8601
inttimezoneOffsetOptional Local timezone offset in minutes (e.g., 120 for GMT+2), default is 0 (UTC)
stringdataResolutionOptional Resolution of the data, can be either full (default), 15m, 1h, or 1d
intuseRawOptional Include raw instead of converted values: 0 (default), or 1
intincludeStatusOptional Include status data (e.g., battery level): 0 (default), or 1
intincludePicturesOptional Include sensorcam pictures: 0 (default), or 1
Returns

An object such as:

Property Type Description
success boolean Whether the job could be added to the download queue
error string An error message in case of a failure
jobId int The id of the new queued job in case of success
Note
The maximum downloadable data for a single station is defined by downloads::MAX_DOWNLOAD_RANGE, queue multiple jobs if you need to download more data
The local timezone offset is required to get meaningful dates when the date format does not generate UTC time (e.g., plaintext)
static downloads::getOwnJob ( )
static

Get the status of a particular job.

Parameters
intjobIdJob id
Returns

An object such as:

Property Type Description
id int Job id
name string Job name
status int Job status (e.g., downloads::STATUS_ONGOING)
progress float Percentage of completion, if the job is ongoing
epochCreated int Creation date in epoch time
epochCompleted int Completion date in epoch time, if the job has been completed
link string Download link for the zip file, if the job has been completed
static downloads::getOwnJobs ( )
static

Get the most recent download jobs of the current user.

Parameters
inthowManyOptional Number of jobs to retrieve (defaults to 1)
Returns

An array of objects such as:

Property Type Description
totalCount int Total number of jobs of the user
jobs array Array of recent jobs

The jobs are objects such as:

Property Type Description
id int Job id
name string Job name
status int Job status (e.g., downloads::STATUS_ONGOING)
progress float Percentage of completion, if the job is ongoing
epochCreated int Creation date in epoch time
epochCompleted int Completion date in epoch time, if the job has been completed
link string Download link for the zip file, if the job has been completed
Note
The length of the array may be less than the requested number of jobs if there are too few jobs available
The array of jobs is sorted by creation date, most recent first