API - Planyo Web Services - get_resource_usage

You are here: Planyo » Help » API » get_resource_usage

get_resource_usage

Description:

This function will return usage/availability information of given resource (or entire site) for specified period of time. Note that the output is minimized, so only periods with usage (reservations or vacations) will be returned.

Input:

resource_id int optional
ID of the resource. Pass null if you want info for all resources to be returned. In this case and if using a metasite API key, you'll need to pass the site id in the site_id parameter.
site_id int optional
Required only for metasite API keys and when resource_id is null. Otherwise skip this parameter.
start_date DateTime required
Start date of the period
end_date DateTime required
End date of the period
separate_periods bool required
If set to true, then this function will return usage by grouping together time ranges with the same usage value instead of returning it for each time slot. See the output format for more information. By default this is set to false.
separate_units bool optional
You can retrieve usage for individual units if you set this to true
method string required
must be set to get_resource_usage
language string optional
by specifying a 2-letter (ISO 639-1) language code (all capital letters e.g. EN, DE, FR, ES, IT) you can change the language of the text values returned
api_key string required
your API key - Click here to get your key. If your API key uses a hash key, you must also include the parameters hash_key and hash_timestamp.

Output:

usage array
Resource usage. This is a multi-dimentional array whose format depends on the separate_periods parameter. When false (default), then the first dimention is the resource ID, the second is the year, then the month followed by day number, then for hour-based resources it's the hour and in case of quarter-based resource the last array dimention is the number of minutes (00, 15, 30 or 45). The array value is the number of units used (unavailable) in given time slot (day, hour or quarter). Subtracting the number of used units from the total quantity gives you the availability. If separate_periods is set to true, then for each returned resource, a list of arrays with the keys from (timestamp), to (timestamp), q (int) is returned representing grouped periods of identical availability. Note that you can also add a parameter return_as_text=true in order for the output array to include times as text instead of timestamps.

API playground:

Click here to test this function in the API playground.