graphbrainz-extension-lastfm
v2.0.0
Published
Last.fm GraphQL extension for GraphBrainz.
Downloads
15
Maintainers
Readme
GraphBrainz Extension: Last.fm
Retrieve artist, release, and recording information from Last.fm.
The extension works by sending the MBIDs of entities to the Last.fm API
whenever their lastFM
field is requested. Only entities with known MBIDs on
Last.fm will have their lastFM
field, otherwise it will be null.
Try out the live demo! :bulb: Use the “Docs” sidebar or the documentation below to help construct your query.
Installation
To use this extension, install GraphBrainz then:
$ npm install graphbrainz-extension-lastfm
$ GRAPHBRAINZ_EXTENSIONS='["graphbrainz-extension-lastfm"]' graphbrainz
Or, if you are using the middleware directly:
import graphbrainz from 'graphbrainz'
const middleware = graphbrainz({
// Don't forget to add the other extensions you use, too.
extensions: ['graphbrainz-extension-lastfm']
})
Configuration
This extension can be configured using environment variables:
LASTFM_API_KEY
: The Last.fm API key to use. This is required for any fields added by the extension to successfully resolve.LASTFM_BASE_URL
: The base URL at which to access the Last.fm API. Defaults tohttp://ws.audioscrobbler.com/2.0/
.LASTFM_CACHE_SIZE
: The number of items to keep in the cache. Defaults toGRAPHBRAINZ_CACHE_SIZE
if defined, or8192
.LASTFM_CACHE_TTL
: The number of seconds to keep items in the cache. Defaults toGRAPHBRAINZ_CACHE_TTL
if defined, or86400000
(one day).
This extension uses its own cache, separate from the MusicBrainz loader cache.
Example Queries
Find the MBIDs of similar recordings (try it):
{
search {
recordings(query: "Dream Baby Dream artist:Suicide", first: 1) {
nodes {
mbid
title
lastFM {
similarTracks(first: 5) {
edges {
matchScore
node {
mbid
title
artist {
name
}
}
}
}
}
}
}
}
}
Schema Types
Objects
Area
:small_blue_diamond: This type has been extended. See the base schema for a description and additional fields.
Chart data available for this area on Last.fm, if the area represents a country with an ISO 3166 code. This field is provided by the Last.fm extension.
Artist
:small_blue_diamond: This type has been extended. See the base schema for a description and additional fields.
Data about the artist from Last.fm, a good source for measuring popularity via listener and play counts. This field is provided by the Last.fm extension.
LastFMAlbum
An album on Last.fm corresponding with a MusicBrainz Release.
The MBID of the corresponding MusicBrainz release.
The title of the album according to Last.fm.
The URL for the album on Last.fm.
An image of the cover artwork of the release.
The size of the image to retrieve.
The number of listeners recorded for the album.
The number of plays recorded for the album.
Historical information written about the album, often available in several languages.
The two-letter code for the language in which to retrieve the description.
The artist who released the album. This returns the Last.fm artist info, not the MusicBrainz artist.
A list of tags applied to the artist by users, ordered by popularity.
The maximum number of tags to retrieve.
The cursor of the edge after which more tags will be retrieved.
LastFMAlbumConnection
A connection to a list of items.
Information to aid in pagination.
A list of edges.
A list of nodes in the connection (without going through the edges
field).
A count of the total number of items in this connection, ignoring pagination.
LastFMAlbumEdge
An edge in a connection.
The item at the end of the edge.
A cursor for use in pagination.
LastFMArtist
An artist on Last.fm.
The MBID of the corresponding MusicBrainz artist.
The name of the artist according to Last.fm.
The URL for the artist on Last.fm.
An image of the artist.
The size of the image to retrieve.
The number of listeners recorded for the artist.
The number of plays recorded for the artist.
A list of similar artists.
The maximum number of artists to retrieve.
The cursor of the edge after which more artists will be retrieved.
A list of the artist’s most popular albums.
The maximum number of albums to retrieve.
The cursor of the edge after which more albums will be retrieved.
A list of tags applied to the artist by users, ordered by popularity.
The maximum number of tags to retrieve.
The cursor of the edge after which more tags will be retrieved.
A list of the artist’s most popular tracks.
The maximum number of tracks to retrieve.
The cursor of the edge after which more tracks will be retrieved.
A biography of the artist, often available in several languages.
The two-letter code for the language in which to retrieve the biography.
LastFMArtistConnection
A connection to a list of items.
Information to aid in pagination.
A list of edges.
A list of nodes in the connection (without going through the edges
field).
A count of the total number of items in this connection, ignoring pagination.
LastFMArtistEdge
An edge in a connection.
The item at the end of the edge.
A cursor for use in pagination.
The artist similarity score (0–1) as determined by Last.fm, if this connection is with another artist.
LastFMChartQuery
A query for chart data on Last.fm.
The most popular artists, ordered by popularity. If a country code is given, retrieve the most popular artists in that country.
A two-letter ISO 3166 country code.
The maximum number of artists to retrieve.
The cursor of the edge after which more artists will be retrieved.
The most popular tags, ordered by popularity.
The maximum number of tags to retrieve.
The cursor of the edge after which more tags will be retrieved.
The most popular tracks, ordered by popularity. If a country code is given, retrieve the most popular tracks in that country.
A two-letter ISO 3166 country code.
The maximum number of tracks to retrieve.
The cursor of the edge after which more tracks will be retrieved.
LastFMCountry
A country with chart data available on Last.fm.
The top artists in this country, ordered by popularity.
The maximum number of artists to retrieve.
The cursor of the edge after which more artists will be retrieved.
The top tracks in this country, ordered by popularity.
The maximum number of tracks to retrieve.
The cursor of the edge after which more tracks will be retrieved.
LastFMQuery
The different types of Last.fm queries that can be made that are not connected to any particular MusicBrainz entity.
A query for chart data.
LastFMTag
A tag added by users to an entity on Last.fm.
The tag name.
The URL for the tag on Last.fm.
LastFMTagConnection
A connection to a list of items.
Information to aid in pagination.
A list of edges.
A list of nodes in the connection (without going through the edges
field).
A count of the total number of items in this connection, ignoring pagination.
LastFMTagEdge
An edge in a connection.
The item at the end of the edge.
A cursor for use in pagination.
The number of times the tag has been applied to the item in question.
LastFMTrack
A track on Last.fm corresponding with a MusicBrainz Recording.
The MBID of the corresponding MusicBrainz recording.
The title of the track according to Last.fm.
The URL for the track on Last.fm.
The length of the track.
The number of listeners recorded for the track.
The number of plays recorded for the track.
Historical information written about the track, often available in several languages.
The two-letter code for the language in which to retrieve the description.
The artist who released the track. This returns the Last.fm artist info, not the MusicBrainz artist.
The album on which the track appears. This returns the Last.fm album info, not the MusicBrainz release.
A list of similar tracks.
The maximum number of tracks to retrieve.
The cursor of the edge after which more tracks will be retrieved.
A list of tags applied to the track by users, ordered by popularity.
The maximum number of tags to retrieve.
The cursor of the edge after which more tags will be retrieved.
LastFMTrackConnection
A connection to a list of items.
Information to aid in pagination.
A list of edges.
A list of nodes in the connection (without going through the edges
field).
A count of the total number of items in this connection, ignoring pagination.
LastFMTrackEdge
An edge in a connection.
The item at the end of the edge.
A cursor for use in pagination.
The track similarity score (0–1) as determined by Last.fm, if this connection is with another track.
LastFMWikiContent
Biographical or background information written about an entity on Last.fm.
A summary of the wiki content, which may contain HTML.
The full wiki content, which may contain HTML.
The date the content was published. The data is reformatted from the Last.fm API’s original format into the Date scalar format.
The time the content was published. The data is reformatted from the Last.fm API’s original format into the Time scalar format. The API offers no indication as to which time zone the time is in.
The URL at which the content was published.
Query
:small_blue_diamond: This type has been extended. See the base schema for a description and additional fields.
A query for data on Last.fm that is not connected to any particular MusicBrainz entity. This field is provided by the Last.fm extension.
Recording
:small_blue_diamond: This type has been extended. See the base schema for a description and additional fields.
Data about the recording from Last.fm, a good source for measuring popularity via listener and play counts. This field is provided by the Last.fm extension.
Release
:small_blue_diamond: This type has been extended. See the base schema for a description and additional fields.
Data about the release from Last.fm, a good source for measuring popularity via listener and play counts. This field is provided by the Last.fm extension.
Enums
LastFMImageSize
The image sizes that may be requested at Last.fm.
A maximum dimension of 34px.
A maximum dimension of 64px.
A maximum dimension of 174px.
A maximum dimension of 300px.
A maximum dimension of 300px.