Retrieve a list of high-level music genre groups that categorize the more specific genres into broader musical families. Use these genre groups to provide simplified filtering options or to organize genres hierarchically in your application.
You need a valid API key to use this endpoint. Get your API key from the API Access page in your Pictory dashboard.
Genre groups provide a simplified way to categorize music by broad styles. Use them to create top-level navigation or filtering, then combine with the specific genres endpoint for detailed selection.
Hierarchical Organization: These 12 genre groups encompass the 100+ specific genres available through the /music/genres endpoint, providing a logical hierarchy for music organization.
Build a two-level genre selection interface with groups and specific genres:
Report incorrect code
Copy
Ask AI
import requestsheaders = {"Authorization": "YOUR_API_KEY"}# Get genre groupsgroups = requests.get( "https://api.pictory.ai/pictoryapis/v1/music/genres/groups", headers=headers).json()# Get all specific genresall_genres = requests.get( "https://api.pictory.ai/pictoryapis/v1/music/genres", headers=headers).json()# Create hierarchical structuregenre_hierarchy = { "Rock": [g for g in all_genres if 'Rock' in g and 'Folk' not in g], "Electronic": [g for g in all_genres if any(x in g for x in ['Electronic', 'House', 'Techno', 'Trance'])], "Blues & Jazz": [g for g in all_genres if 'Jazz' in g or 'Blues' in g], # ... continue for other groups}
Allow users to quickly filter music by general style before refining:
Report incorrect code
Copy
Ask AI
def get_music_by_genre_group(group_name, api_key): """ Get all specific genres within a genre group """ headers = {"Authorization": api_key} # Get all genres all_genres = requests.get( "https://api.pictory.ai/pictoryapis/v1/music/genres", headers=headers ).json() # Map groups to their genres group_mapping = { "Rock": lambda g: 'Rock' in g and 'Folk' not in g, "Electronic": lambda g: any(x in g for x in ['Electronic', 'House', 'Techno', 'Trance', 'Dubstep']), "Blues & Jazz": lambda g: 'Jazz' in g or 'Blues' in g, "Hip Hop": lambda g: 'Hip Hop' in g or g in ['Trap', 'Gangsta', 'Drill'], "World": lambda g: any(x in g for x in ['African', 'Asian', 'Brazilian', 'Cuban', 'Indian']), # ... other mappings } if group_name in group_mapping: return [g for g in all_genres if group_mapping[group_name](g)] return []# Example usagerock_genres = get_music_by_genre_group("Rock", "YOUR_API_KEY")print(f"Rock genres: {rock_genres}")