Back to Documentation
Example Usage
data "spotify_weather" "current" {}
output "weather_condition" {
value = data.spotify_weather.current.condition
}
output "weather_mood" {
value = data.spotify_weather.current.mood
}
output "temperature" {
value = "${data.spotify_weather.current.temperature}°C"
}
resource "spotify_playlist" "weather_based" {
name = "${data.spotify_weather.current.mood} Weather Mix"
description = "Music for ${data.spotify_weather.current.condition} weather at ${data.spotify_weather.current.temperature}°C"
public = true
}
Custom Location Example
data "spotify_weather" "paris" {
location = {
city = "Paris"
country = "FR"
}
}
output "paris_weather" {
value = "${data.spotify_weather.paris.condition} at ${data.spotify_weather.paris.temperature}°C"
}
Argument Reference
| Argument |
Description |
location |
(Optional) A map containing location information. If not provided, the provider will attempt to determine the current location. |
location.city |
(Optional) The city name. |
location.country |
(Optional) The country code (ISO 3166-1 alpha-2). |
location.lat |
(Optional) The latitude coordinate. |
location.lon |
(Optional) The longitude coordinate. |
api_key |
(Optional) A custom API key for the weather service. If not provided, the provider will use the configured API key. |
Attribute Reference
| Attribute |
Description |
id |
A unique identifier for this data source. |
condition |
The current weather condition (e.g., "clear", "cloudy", "rain", "snow"). |
temperature |
The current temperature in Celsius. |
humidity |
The current humidity percentage. |
wind_speed |
The current wind speed in meters per second. |
mood |
A suggested mood based on the current weather conditions. |
suggested_moods |
A list of suggested moods based on the current weather conditions. |
suggested_genres |
A list of suggested genres based on the current weather conditions. |
location_name |
The name of the location for which weather data was retrieved. |