Client
LastFM(user_agent, api_key, api_secret=None, password_hash=None, reset_cache=False)
A client for interacting with the LastFM API.
This class provides methods to access various endpoints of the LastFM API, allowing users to retrieve information about albums, artists, charts, tags, tracks, and users.
Initializes the LastFM client with the necessary credentials and settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_agent |
str
|
The user-agent string to be used for API requests. |
required |
api_key |
str
|
The API key required for authentication with the LastFM API. |
required |
api_secret |
str
|
The API secret for authentication (if needed). Defaults to None. |
None
|
password_hash |
str
|
A hashed password for authentication (if needed). Defaults to None. |
None
|
reset_cache |
bool
|
If True, clears the existing cache of responses. Defaults to False. |
False
|
Source code in pylastfmapi/client.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
get_album_info(album=None, artist=None, mbid=None, autocorrect=False, lang='en', username=None)
Fetches information about an album from the LastFM API.
This method retrieves detailed information about an album,
such as its artist, title, and other metadata.
You must provide either the artist and album or the mbid to
make the request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
album |
str
|
The name of the album. Defaults to None. |
None
|
artist |
str
|
The name of the artist. Defaults to None. |
None
|
mbid |
str
|
The MusicBrainz ID (MBID) of the album. Defaults to None. |
None
|
autocorrect |
bool
|
If set to True, corrects misspelled artist or album names. Defaults to False. |
False
|
lang |
T_ISO639Alpha2Code
|
The language code for the response. Defaults to 'en'. |
'en'
|
username |
str
|
The LastFM username to fetch personalized data for. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing the album information. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
get_album_tags(user, album=None, artist=None, mbid=None, autocorrect=False)
Fetches user-assigned tags for an album from the LastFM API.
This method retrieves the tags a specific user has assigned
to an album. You must provide either the artist and album or
the mbid to make the request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The LastFM username whose tags are to be retrieved. |
required |
album |
str
|
The name of the album. Defaults to None. |
None
|
artist |
str
|
The name of the artist. Defaults to None. |
None
|
mbid |
str
|
The MusicBrainz ID (MBID) of the album. Defaults to None. |
None
|
autocorrect |
bool
|
If set to True, corrects misspelled artist or album names. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the user's tags for the album. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
get_album_top_tags(album=None, artist=None, mbid=None, autocorrect=False)
Fetches the top tags for an album from the LastFM API.
This method retrieves the most popular tags associated with an album,
based on all users' tagging activity. You must provide either the
artist and album or the mbid to make the request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
album |
str
|
The name of the album. Defaults to None. |
None
|
artist |
str
|
The name of the artist. Defaults to None. |
None
|
mbid |
str
|
The MusicBrainz ID (MBID) of the album. Defaults to None. |
None
|
autocorrect |
bool
|
If set to True, corrects misspelled artist or album names. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the top tags for the album. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
get_artist_correction(artist)
Checks if the supplied artist name has a correction to a canonical artist.
This method uses the LastFM corrections data to determine if the given artist name has a correction that maps it to a canonical artist name. It returns a list of possible corrections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artist |
str
|
The artist name to check for corrections. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The corrected canonical artist name. |
Source code in pylastfmapi/client.py
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | |
get_artist_info(artist=None, mbid=None, autocorrect=False, lang='en', username=None)
Fetches information about an artist from the LastFM API.
This method retrieves detailed information about an artist.
You must provide either the artist or the mbid to make the request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artist |
str
|
The name of the artist. Defaults to None. |
None
|
mbid |
str
|
The MusicBrainz ID (MBID) of the artist. Defaults to None. |
None
|
autocorrect |
bool
|
If set to True, corrects misspelled artist names. Defaults to False. |
False
|
lang |
str
|
The language code for the response. Defaults to 'en'. |
'en'
|
username |
str
|
The LastFM username to fetch personalized data for. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing the artist information. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
get_artist_similar(artist=None, mbid=None, autocorrect=False, amount=30)
Fetches similar artists for a given artist from the LastFM API.
This method retrieves a list of artists similar to the specified
artist.
You must provide either the artist or the mbid to make the request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artist |
str
|
The name of the artist. Defaults to None. |
None
|
mbid |
str
|
The MusicBrainz ID (MBID) of the artist. Defaults to None. |
None
|
autocorrect |
bool
|
If set to True, corrects misspelled artist names. Defaults to False. |
False
|
amount |
int
|
The number of similar artists to retrieve. Defaults to 30. |
30
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing a list of similar artists. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | |
get_artist_tags(user, artist=None, mbid=None, autocorrect=False)
Fetches user-assigned tags for an artist from the LastFM API.
This method retrieves the tags a specific user has assigned to
an artist.
You must provide either the artist or the mbid to make the request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The LastFM username whose tags are to be retrieved. |
required |
artist |
str
|
The name of the artist. Defaults to None. |
None
|
mbid |
str
|
The MusicBrainz ID (MBID) of the artist. Defaults to None. |
None
|
autocorrect |
bool
|
If set to True, corrects misspelled artist names. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the user's tags for |
list[dict]
|
the artist. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
get_artist_top_albums(artist=None, mbid=None, autocorrect=False, amount=None)
Fetches the top albums for an artist from the LastFM API.
This method retrieves the most popular albums associated with an
artist.
You must provide either the artist or the mbid to make the request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artist |
str
|
The name of the artist. Defaults to None. |
None
|
mbid |
str
|
The MusicBrainz ID (MBID) of the artist. Defaults to None. |
None
|
autocorrect |
bool
|
If set to True, corrects misspelled artist names. Defaults to False. |
False
|
amount |
int
|
The total number of albums to retrieve. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the artist's top albums. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | |
get_artist_top_tags(artist=None, mbid=None, autocorrect=False)
Fetches the top tags for an artist from the LastFM API.
This method retrieves the most popular tags associated with an artist,
based on all users' tagging activity. You must provide either the
artist or the mbid to make the request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artist |
str
|
The name of the artist. Defaults to None. |
None
|
mbid |
str
|
The MusicBrainz ID (MBID) of the artist. Defaults to None. |
None
|
autocorrect |
bool
|
If set to True, corrects misspelled artist names. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the top tags |
list[dict]
|
for the artist. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | |
get_artist_top_tracks(artist=None, mbid=None, autocorrect=False, amount=None)
Fetches the top tracks for an artist from the LastFM API.
This method retrieves the most popular tracks associated with an
artist.
You must provide either the artist or the mbid to make the request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artist |
str
|
The name of the artist. Defaults to None. |
None
|
mbid |
str
|
The MusicBrainz ID (MBID) of the artist. Defaults to None. |
None
|
autocorrect |
bool
|
If set to True, corrects misspelled artist names. Defaults to False. |
False
|
amount |
int
|
The total number of tracks to retrieve. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the artist's top tracks. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | |
get_country_top_artists(country, amount=None)
Fetches the top artists for a specified country.
This method retrieves the top artists in a given country based on LastFM data. It supports pagination to handle large result sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country |
T_ISO3166CountryNames
|
The country code (ISO 3166-1 alpha-2) to get top artists for. |
required |
amount |
int
|
The number of top artists to retrieve. If not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the top artists in the specified country. |
Source code in pylastfmapi/client.py
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 | |
get_country_top_tracks(country, location=None, amount=None)
Fetches the top tracks for a specified country and optional location.
This method retrieves the top tracks in a given country, and optionally, a specific location within that country. It supports pagination to handle large result sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country |
T_ISO3166CountryNames
|
The country code (ISO 3166-1 alpha-2) to get top tracks for. |
required |
location |
str
|
Specific location within the country to filter tracks. If not provided, defaults to country-wide data. |
None
|
amount |
int
|
The number of top tracks to retrieve. If not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the top tracks in the specified country and location. |
Source code in pylastfmapi/client.py
1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 | |
get_tag_info(tag, lang='en')
Fetches detailed information about a specific tag.
This method retrieves detailed information about a given tag from the LastFM database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag |
str
|
The name of the tag to get information about. |
required |
lang |
T_ISO639Alpha2Code
|
The language for the tag information. Defaults to 'en'. |
'en'
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing information about the specified tag. |
Source code in pylastfmapi/client.py
1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 | |
get_tag_similar(tag=None)
Fetches similar tags to the specified tag.
This method retrieves tags that are similar to the provided tag from the LastFM database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag |
str
|
The name of the tag to find similar tags for. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing tags that are similar to the specified tag. |
Source code in pylastfmapi/client.py
1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 | |
get_tag_top_albums(tag, amount=None)
Fetches the top albums associated with a specific tag.
This method retrieves a list of top albums associated with the provided tag from the LastFM database. Supports pagination to handle large result sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag |
str
|
The name of the tag to get top albums for. |
required |
amount |
int
|
The number of top albums to retrieve. If not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the top albums associated with the specified tag. |
Source code in pylastfmapi/client.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 | |
get_tag_top_artists(tag, amount=None)
Fetches the top artists associated with a specific tag.
This method retrieves a list of top artists associated with the provided tag from the LastFM database. Supports pagination to handle large result sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag |
str
|
The name of the tag to get top artists for. |
required |
amount |
int
|
The number of top artists to retrieve. If not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the top albums associated with the specified tag. |
Source code in pylastfmapi/client.py
1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 | |
get_tag_top_tracks(tag, amount=None)
Fetches the top tracks associated with a specific tag.
This method retrieves a list of top tracks associated with the provided tag from the LastFM database. Supports pagination to handle large result sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag |
str
|
The name of the tag to get top tracks for. |
required |
amount |
int
|
The number of top tracks to retrieve. If not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the top albums associated with the specified tag. |
Source code in pylastfmapi/client.py
1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 | |
get_top_artists(amount=None)
Fetches the top artists from the LastFM charts.
This method retrieves the top artists based on the LastFM charts and supports pagination to gather a specified amount of data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
amount |
int
|
The total number of artists to retrieve. If None, retrieves all available artists. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing requested data. |
Source code in pylastfmapi/client.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
get_top_tags(amount=None)
Fetches the top tags from the LastFM charts.
This method retrieves the top tags based on the LastFM charts and supports pagination to gather a specified amount of data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
amount |
int
|
The total number of tags to retrieve. If None, retrieves all available tags. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing requested data. |
Source code in pylastfmapi/client.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
get_top_tracks(amount=None)
Fetches the top tracks from the LastFM charts.
This method retrieves the top tracks based on the LastFM charts and supports pagination to gather a specified amount of data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
amount |
int
|
The total number of tracks to retrieve. If None, retrieves all available tracks. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing requested data. |
Source code in pylastfmapi/client.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
get_track_correction(track, artist)
Uses LastFM corrections data to check whether the supplied track has a correction to a canonical track.
This method queries LastFM's corrections data to determine if the given track name has a correction to a canonical track. You must provide both the track name and the artist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track |
str
|
The name of the track to check for corrections. |
required |
artist |
str
|
The name of the artist. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing detailed information about the track. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If either |
Source code in pylastfmapi/client.py
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 | |
get_track_info(track=None, artist=None, mbid=None, autocorrect=False, username=None)
Retrieves detailed information about a track.
This method fetches detailed information about a track from the LastFM API. You need to provide either the artist name and track name or the track's MusicBrainz ID (MBID). Optionally, you can specify a username to retrieve user-specific data and enable autocorrection for potential misspellings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track |
str
|
The name of the track.
Required if |
None
|
artist |
str
|
The name of the artist.
Required if |
None
|
mbid |
str
|
The MusicBrainz ID of the track.
Required if |
None
|
autocorrect |
bool
|
Whether to autocorrect misspellings. Defaults to False. |
False
|
username |
str
|
The username to retrieve user-specific data. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing detailed information about the track. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 | |
get_track_similar(track=None, artist=None, mbid=None, autocorrect=False, amount=100)
Retrieves a list of tracks similar to the specified track.
This method fetches a list of tracks similar to the given track from the LastFM API. You must provide either the track name and artist or the track's MusicBrainz ID (MBID). Optionally, you can enable autocorrection for misspellings and specify the number of similar tracks to retrieve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track |
str
|
The name of the track.
Required if |
None
|
artist |
str
|
The name of the artist.
Required if |
None
|
mbid |
str
|
The MusicBrainz ID of the track.
Required if |
None
|
autocorrect |
bool
|
Whether to autocorrect misspellings. Defaults to False. |
False
|
amount |
int
|
The number of similar tracks to retrieve. Defaults to 100. |
100
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing similar tracks to the specified track. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 | |
get_track_tags(user, track=None, artist=None, mbid=None, autocorrect=False)
Fetches tags assigned to a track by a specific user.
This method retrieves tags that a user has assigned to a track from the LastFM API. You must provide the username and either the track's name and artist or the track's MusicBrainz ID (MBID). Optionally, you can enable autocorrection for potential misspellings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username who assigned the tags. |
required |
track |
str
|
The name of the track. Required if |
None
|
artist |
str
|
The name of the artist. Required if |
None
|
mbid |
str
|
The MusicBrainz ID of the track. Required if
|
None
|
autocorrect |
bool
|
Whether to autocorrect misspellings. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing tags assigned to the track. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 | |
get_track_top_tags(track=None, artist=None, mbid=None, autocorrect=False)
Retrieves the top tags for a track.
This method fetches the top tags assigned to a track based on user tagging from the LastFM API. You need to provide either the track name and artist or the track's MusicBrainz ID (MBID). Optionally, you can enable autocorrection for potential misspellings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track |
str
|
The name of the track.
Required if |
None
|
artist |
str
|
The name of the artist.
Required if |
None
|
mbid |
str
|
The MusicBrainz ID of the track.
Required if |
None
|
autocorrect |
bool
|
Whether to autocorrect misspellings. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the top tags for the track. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If neither |
Source code in pylastfmapi/client.py
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 | |
get_user_friends(user, recenttracks=False, amount=None)
Fetches a list of friends for a specific user.
This method retrieves a list of friends for the given user from the LastFM database. Supports pagination to handle large result sets and can optionally include recent tracks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose friends are to be retrieved. |
required |
recenttracks |
bool
|
If True, includes recent tracks by friends. Defaults to False. |
False
|
amount |
int
|
The number of friends to retrieve. If not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing information about a friend of the specified user. |
Source code in pylastfmapi/client.py
912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 | |
get_user_info(user)
Fetches detailed information about a specific user.
This method retrieves detailed information about the given user from the LastFM database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose information is to be retrieved. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing detailed information about the specified user. |
Source code in pylastfmapi/client.py
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 | |
get_user_library_artists(user, amount=None)
Fetches a list of artists from a user's library.
This method retrieves a list of artists from the library of the given user from the LastFM database. Supports pagination to handle large result sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose library artists are to be retrieved. |
required |
amount |
int
|
The number of library artists to retrieve. If not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing information about an artist in the user's library. |
Source code in pylastfmapi/client.py
988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 | |
get_user_loved_tracks(user, amount=None)
Fetches a list of tracks loved by a specific user.
This method retrieves a list of tracks that the given user has marked as loved from the LastFM database. Supports pagination to handle large result sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose loved tracks are to be retrieved. |
required |
amount |
int
|
The number of loved tracks to retrieve. If not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing information about a loved track of the specified user. |
Source code in pylastfmapi/client.py
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 | |
get_user_personal_tags(user, tag, taggingtype, amount=None)
Fetches a list of personal tags applied by a user to a specific tagging type.
This method retrieves a list of items (artists, albums, or tracks) that the given user has tagged with the specified tag. Supports pagination to handle large result sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose personal tags are to be retrieved. |
required |
tag |
str
|
The tag applied to the items. |
required |
taggingtype |
Literal['artist', 'album', 'track']
|
The type of items that are tagged. |
required |
amount |
int
|
The number of tagged items to retrieve. f not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing information about an item tagged by the user. |
Source code in pylastfmapi/client.py
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 | |
get_user_recent_tracks(user, amount=None, date_from=None, date_to=None, extended=False)
Fetches the recent tracks listened to by a specific user.
This method retrieves a list of tracks recently listened to by the
user. Supports pagination
and date filtering. If both date_from and date_to are provided,
they must be valid dates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose recent tracks are to be retrieved. |
required |
amount |
int
|
The number of tracks to retrieve. |
None
|
date_from |
str
|
The start date of the range in "YYYY-MM-DD" or "YYYY-MM-DD HH:MM" format. |
None
|
date_to |
str
|
The end date of the range in "YYYY-MM-DD" or "YYYY-MM-DD HH:MM" format. |
None
|
extended |
bool
|
Whether to include extended data such as images. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing information about a track in the user's recent history. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If |
Source code in pylastfmapi/client.py
1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 | |
get_user_top_albums(user, period='overall', amount=None)
Fetches a list of top albums for a specific user.
This method retrieves a list of the top albums listened to by the given user over a specified period. Supports pagination to handle large result sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose top albums are to be retrieved. |
required |
period |
T_Period
|
The period over which to fetch top albums. Defaults to 'overall'. |
'overall'
|
amount |
int
|
The number of top albums to retrieve. If not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing information about a top album of the specified user. |
Source code in pylastfmapi/client.py
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 | |
get_user_top_artists(user, period='overall', amount=None)
Fetches a list of top artists for a specific user.
This method retrieves a list of the top artists listened to by the given user over a specified period. Supports pagination to handle large result sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose top artists are to be retrieved. |
required |
period |
T_Period
|
The period over which to fetch top artists. Defaults to 'overall'. |
'overall'
|
amount |
int
|
The number of top artists to retrieve. If not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing information about a top artist of the specified user. |
Source code in pylastfmapi/client.py
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 | |
get_user_top_tags(user, amount=None)
Fetches a list of top tags used by a specific user.
This method retrieves a list of the top tags applied by the given user to their items. The tags represent the user's most frequently used tags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose top tags are to be retrieved. |
required |
amount |
int
|
The number of top tags to retrieve. If not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing information about a top tag of the specified user. |
Source code in pylastfmapi/client.py
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 | |
get_user_top_tracks(user, period='overall', amount=None)
Fetches a list of top tracks for a specific user.
This method retrieves a list of the top tracks listened to by the given user over a specified period. Supports pagination to handle large result sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose top tracks are to be retrieved. |
required |
period |
T_Period
|
The period over which to fetch top tracks. Defaults to 'overall'. |
'overall'
|
amount |
int
|
The number of top tracks to retrieve. If not provided, defaults to all available. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing information about a top track of the specified user. |
Source code in pylastfmapi/client.py
1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | |
get_user_weekly_album_chart(user, amount=None, date_from=None, date_to=None)
Fetches a weekly chart of albums listened to by a specific user.
This method retrieves a list of albums that the user has listened to over a specified week. Supports pagination and date filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose weekly album chart is to be retrieved. |
required |
amount |
int
|
The number of albums to retrieve. The maximum allowed is 1000. If not provided, defaults to all available. |
None
|
date_from |
str
|
The start date of the range in "YYYY-MM-DD" or "YYYY-MM-DD HH:MM" format. |
None
|
date_to |
str
|
The end date of the range in "YYYY-MM-DD" or "YYYY-MM-DD HH:MM" format. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing information about an album in the user's weekly chart. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If |
Source code in pylastfmapi/client.py
1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 | |
get_user_weekly_artist_chart(user, amount=None, date_from=None, date_to=None)
Fetches a weekly chart of artists listened to by a specific user.
This method retrieves a list of artists that the user has listened to over a specified week. Supports pagination and date filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose weekly artist chart is to be retrieved. |
required |
amount |
int
|
The number of artists to retrieve. The maximum allowed is 1000. If not provided, defaults to all available. |
None
|
date_from |
str
|
The start date of the range in "YYYY-MM-DD" or "YYYY-MM-DD HH:MM" format. |
None
|
date_to |
str
|
The end date of the range in "YYYY-MM-DD" or "YYYY-MM-DD HH:MM" format. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing information about an artist in the user's weekly chart. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If |
Source code in pylastfmapi/client.py
1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 | |
get_user_weekly_track_chart(user, amount=None, date_from=None, date_to=None)
Fetches a weekly chart of tracks listened to by a specific user.
This method retrieves a list of tracks that the user has listened to over a specified week. Supports pagination and date filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user |
str
|
The username of the user whose weekly track chart is to be retrieved. |
required |
amount |
int
|
The number of tracks to retrieve. The maximum allowed is 1000. If not provided, defaults to all available. |
None
|
date_from |
str
|
The start date of the range in "YYYY-MM-DD" or "YYYY-MM-DD HH:MM" format. |
None
|
date_to |
str
|
The end date of the range in "YYYY-MM-DD" or "YYYY-MM-DD HH:MM" format. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries, each containing information about a track in the user's weekly chart. |
Raises:
| Type | Description |
|---|---|
LastFMException
|
If |
Source code in pylastfmapi/client.py
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 | |
search_album(album, amount=None)
Searches for albums on LastFM matching the given name.
This method searches the LastFM database for albums that match the given album name. It supports pagination to gather a specified amount of search results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
album |
str
|
The name of the album to search for. |
required |
amount |
int
|
The total number of results to retrieve. If None, retrieves all available results. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the search results. |
Source code in pylastfmapi/client.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | |
search_artist(artist, amount=None)
Searches for artists on LastFM that match the given name.
This method queries the LastFM database for artists that match
the specified artist name. You can control the number of results
returned by specifying the amount parameter. Results are paginated
if more results are available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artist |
str
|
The name of the artist to search for. |
required |
amount |
int
|
The total number of search results to retrieve. If None, retrieves all available results. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing the search results. Each dictionary represents an artist. |
Source code in pylastfmapi/client.py
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | |
search_track(track, artist=None, amount=None)
Searches for tracks that match the given track name and artist.
This method searches for tracks from the LastFM API based on the provided track name and optionally artist. You can also specify the number of search results to return.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track |
str
|
The name of the track to search for. |
required |
artist |
str
|
The name of the artist. Optional. |
None
|
amount |
int
|
The number of search results to return. Optional. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: A list of dictionaries containing tracks that match the search criteria. |
Source code in pylastfmapi/client.py
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 | |