The Billboard module provides access to current Billboard Hot 100 chart data.
hot100()
Returns the current Billboard Hot 100 chart data as an array of song objects.
Returns:
Array of dictionaries, where each dictionary contains:
- song
(string): Title of the song
- artist
(string): Name of the artist
- this_week
(integer): Current position on the chart
- last_week
(integer): Previous week's position
- peak_position
(integer): Highest position achieved on the chart
- weeks_on_chart
(integer): Total number of weeks on the chart
Example Usage:
from billboard import hot100
chart_data = hot100()
for song in chart_data:
print(f"{song['this_week']}. {song['song']} - {song['artist']}")
The Dogs module provides access to dog breed information and images.
breeds()
Returns a list of available dog breeds.
Returns:
Array of strings containing breed names.
random_image_by_breed(breed)
Fetches a random image URL for a specified dog breed.
Parameters:
- breed
(string): Name of the dog breed
Returns:
String containing the URL of a random image for the specified breed.
Raises:
- TypeError
: If the specified breed cannot be found
Example Usage:
from dogs import breeds, random_image_by_breed
# Get all available breeds
all_breeds = breeds()
# Get random image for a specific breed
try:
image_url = random_image_by_breed('labrador')
document['labrador-image'].src = image_url
except TypeError as e:
print(f"Error: {e}")
The Weather module provides current weather data for cities.
current_at_city(city)
Retrieves current weather information for a specified city.
Parameters:
- city
(string): Name of the city
Returns:
Dictionary containing detailed weather information including:
- Coordinates (coord
)
- Weather conditions (weather
)
- Temperature data (main
)
- Wind information (wind
)
- Cloud coverage (clouds
)
- Location details (sys
)
- City information (name
, timezone
, etc.)
Temperature data is provided in both Celsius and Fahrenheit.
Example Usage:
from weather import current_at_city
weather_data = current_at_city('London')
temp_c = weather_data['main']['temp_c']
description = weather_data['weather'][0]['description']
print(f"Current weather in {weather_data['name']}: {temp_c}°C, {description}")
Key weather data fields include:
- main
: Contains temperature, humidity, and pressure data
- weather
: Array containing weather condition details and icons
- wind
: Wind speed and direction
- sys
: Sunrise, sunset, and country information
- dt
: Timestamp of the weather data
- name
: City name
- timezone
: Timezone offset in seconds
All temperature values are provided in both Celsius (_c
suffix) and Fahrenheit (_f
suffix) for convenience.