What is the queryCost parameter?

The queryCost parameter can be found in the response of the Timeline Weather API. QueryCost is used to indicate how many result records the query counts as towards your metered billing or any daily or monthly query cost limit that may apply to the plan being used.

For full information about result record costs, please see ‘What exactly is a weather record?’

Examples of the queryCost parameter

Weather Forecast Request

The following represents the response to a standard Weather API request for the forecast.

https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/Sterling%2C%20VA%2C%20US?unitGroup=us&key=YOUR_API_KEY

Weather forecast queries are defined as having a cost of one even though they include multiple days, hours and other features such as alerts, events and current conditions.

 {
    "queryCost": 1,
    "latitude": 39.0334,
    "longitude": -77.4071,
    ...
} 

Historical weather and historical forecast request

The cost of historical weather data requests is based upon the number of records that are returned. This includes Historical Forecast queries. Here is an example of a request for a week of historical data that includes both the daily and hourly values.

https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/Sterling%2C%20VA%2C%20US/2021-1-1/2021-1-7?unitGroup=us&key=YOUR_API_KEY

The cost of the query is 168 because there are 168 hours in a week (24 multiplied by 7).

 {
   "queryCost": 168,
   "latitude": 39.0334,
   "longitude": -77.4071,
   ...
} 

The ‘includes’ parameter cab be used to limit the result set to daily only data:

https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/Sterling%2C%20VA%2C%20US/2021-1-1/2021-1-7?unitGroup=us&key=YOUR_API_KEY&include=days

The cost of the query is reduced to 7:

{
   "queryCost": 7,
   "latitude": 39.0334,
   "longitude": -77.4071,
  ...
}

Sub-hourly requests can have significantly higher query costs because each returned minute-level record contributes to the request cost. For example, a full day at 15-minute intervals can return 96 sub-hourly records.

The elements parameter controls which weather fields are returned, but query cost is generally based on the number and type of records returned rather than the number of weather fields in each record. To reduce historical query cost, reducing the requested time resolution with include=days, include=hours, or other appropriate data sections is generally more important than reducing the element list.

For Multiple Location Timeline requests, the costs for each requested location are summed. For example, a four-location forecast request has a query cost of 4, while seven days of daily historical weather for four locations has a query cost of 28.

What is the total cost I can run with my subscription, license or plan?

Visual Crossing plans have different usage limits, included record allowances, and billing models. The queryCost value shows how much record usage a request consumes, but the amount of usage available to your account depends on your current plan.

See the current Visual Crossing pricing and plan information for applicable limits and pricing.

Questions or need help?

For immediate help, try our AI Support Assistant, which can answer questions about Visual Crossing Weather data, APIs, documentation, and common technical issues. You can also post questions on our actively monitored support forum or contact our Support Team directly.