Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/exogen/graphbrainz-extension-lastfm
Last.fm GraphQL extension for GraphBrainz.
https://github.com/exogen/graphbrainz-extension-lastfm
graphbrainz graphql graphql-schema lastfm lastfm-api musicbrainz musicbrainz-api
Last synced: 11 days ago
JSON representation
Last.fm GraphQL extension for GraphBrainz.
- Host: GitHub
- URL: https://github.com/exogen/graphbrainz-extension-lastfm
- Owner: exogen
- License: mit
- Created: 2017-11-05T01:35:52.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-04T22:48:48.000Z (over 6 years ago)
- Last Synced: 2024-12-18T19:10:37.819Z (15 days ago)
- Topics: graphbrainz, graphql, graphql-schema, lastfm, lastfm-api, musicbrainz, musicbrainz-api
- Language: JavaScript
- Homepage:
- Size: 1.14 MB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GraphBrainz Extension: Last.fm
[![build status](https://img.shields.io/travis/exogen/graphbrainz-extension-lastfm/master.svg)](https://travis-ci.org/exogen/graphbrainz-extension-lastfm)
[![coverage](https://img.shields.io/codecov/c/github/exogen/graphbrainz-extension-lastfm.svg)](https://codecov.io/gh/exogen/graphbrainz-extension-lastfm)
[![npm version](https://img.shields.io/npm/v/graphbrainz-extension-lastfm.svg)](https://www.npmjs.com/package/graphbrainz-extension-lastfm)
[![license](https://img.shields.io/npm/l/graphbrainz-extension-lastfm.svg)](https://github.com/exogen/graphbrainz-extension-lastfm/blob/master/LICENSE)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!][demo]** :bulb: Use the “Docs” sidebar or the
documentation below to help construct your query.## Installation
To use this extension, install [GraphBrainz][] then:
```console
$ npm install graphbrainz-extension-lastfm
$ GRAPHBRAINZ_EXTENSIONS='["graphbrainz-extension-lastfm"]' graphbrainz
```Or, if you are using the middleware directly:
```js
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 to `http://ws.audioscrobbler.com/2.0/`.
* **`LASTFM_CACHE_SIZE`**: The number of items to keep in the cache. Defaults to
`GRAPHBRAINZ_CACHE_SIZE` if defined, or `8192`.
* **`LASTFM_CACHE_TTL`**: The number of seconds to keep items in the cache.
Defaults to `GRAPHBRAINZ_CACHE_TTL` if defined, or `86400000` (one day).This extension uses its own cache, separate from the MusicBrainz loader cache.
## Example Queries
Find the MBIDs of similar recordings ([try it](https://graphbrainz-extension-lastfm.herokuapp.com/?query=%7B%0A%20%20search%20%7B%0A%20%20%20%20recordings(query%3A%20%22Dream%20Baby%20Dream%20artist%3ASuicide%22%2C%20first%3A%201)%20%7B%0A%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20mbid%0A%20%20%20%20%20%20%20%20title%0A%20%20%20%20%20%20%20%20lastFM%20%7B%0A%20%20%20%20%20%20%20%20%20%20similarTracks(first%3A%205)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20edges%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20matchScore%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20node%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mbid%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20title%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20artist%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A)):
```graphql
{
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
Table of Contents
* [Objects](#objects)
* [Area](#area)
* [Artist](#artist)
* [LastFMAlbum](#lastfmalbum)
* [LastFMAlbumConnection](#lastfmalbumconnection)
* [LastFMAlbumEdge](#lastfmalbumedge)
* [LastFMArtist](#lastfmartist)
* [LastFMArtistConnection](#lastfmartistconnection)
* [LastFMArtistEdge](#lastfmartistedge)
* [LastFMChartQuery](#lastfmchartquery)
* [LastFMCountry](#lastfmcountry)
* [LastFMQuery](#lastfmquery)
* [LastFMTag](#lastfmtag)
* [LastFMTagConnection](#lastfmtagconnection)
* [LastFMTagEdge](#lastfmtagedge)
* [LastFMTrack](#lastfmtrack)
* [LastFMTrackConnection](#lastfmtrackconnection)
* [LastFMTrackEdge](#lastfmtrackedge)
* [LastFMWikiContent](#lastfmwikicontent)
* [Query](#query)
* [Recording](#recording)
* [Release](#release)
* [Enums](#enums)
* [LastFMImageSize](#lastfmimagesize)### Objects
#### Area
:small_blue_diamond: *This type has been extended.
See the [base schema](https://github.com/exogen/graphbrainz/docs/types.md) for a description and additional fields.*Field
Argument
Type
DescriptionlastFM
LastFMCountryChart data available for this area on [Last.fm](https://www.last.fm/), if
the area represents a country with an [ISO 3166 code](https://en.wikipedia.org/wiki/ISO_3166).
This field is provided by the Last.fm extension.#### Artist
:small_blue_diamond: *This type has been extended.
See the [base schema](https://github.com/exogen/graphbrainz/docs/types.md) for a description and additional fields.*Field
Argument
Type
DescriptionlastFM
LastFMArtistData about the artist from [Last.fm](https://www.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](https://www.last.fm/) corresponding with a MusicBrainz
Release.Field
Argument
Type
Descriptionmbid
MBIDThe MBID of the corresponding MusicBrainz release.
title
StringThe title of the album according to [Last.fm](https://www.last.fm/).
url
URLString!The URL for the album on [Last.fm](https://www.last.fm/).
image
URLStringAn image of the cover artwork of the release.
size
LastFMImageSizeThe size of the image to retrieve.
listenerCount
FloatThe number of listeners recorded for the album.
playCount
FloatThe number of plays recorded for the album.
description
LastFMWikiContentHistorical information written about the album, often available in several
languages.lang
StringThe two-letter code for the language in which to retrieve the description.
artist
LastFMArtistThe artist who released the album. This returns the Last.fm artist info,
not the MusicBrainz artist.topTags
LastFMTagConnectionA list of tags applied to the artist by users, ordered by popularity.
first
IntThe maximum number of tags to retrieve.
after
StringThe cursor of the edge after which more tags will be retrieved.
#### LastFMAlbumConnection
A connection to a list of items.
Field
Argument
Type
DescriptionpageInfo
PageInfo!Information to aid in pagination.
edges
[LastFMAlbumEdge]A list of edges.
nodes
[LastFMAlbum]A list of nodes in the connection (without going through the `edges` field).
totalCount
IntA count of the total number of items in this connection, ignoring pagination.
#### LastFMAlbumEdge
An edge in a connection.
Field
Argument
Type
Descriptionnode
LastFMAlbumThe item at the end of the edge.
cursor
String!A cursor for use in pagination.
#### LastFMArtist
An artist on [Last.fm](https://www.last.fm/).
Field
Argument
Type
Descriptionmbid
MBIDThe MBID of the corresponding MusicBrainz artist.
name
StringThe name of the artist according to [Last.fm](https://www.last.fm/).
url
URLString!The URL for the artist on [Last.fm](https://www.last.fm/).
image
URLStringAn image of the artist.
size
LastFMImageSizeThe size of the image to retrieve.
listenerCount
FloatThe number of listeners recorded for the artist.
playCount
FloatThe number of plays recorded for the artist.
similarArtists
LastFMArtistConnectionA list of similar artists.
first
IntThe maximum number of artists to retrieve.
after
StringThe cursor of the edge after which more artists will be retrieved.
topAlbums
LastFMAlbumConnectionA list of the artist’s most popular albums.
first
IntThe maximum number of albums to retrieve.
after
StringThe cursor of the edge after which more albums will be retrieved.
topTags
LastFMTagConnectionA list of tags applied to the artist by users, ordered by popularity.
first
IntThe maximum number of tags to retrieve.
after
StringThe cursor of the edge after which more tags will be retrieved.
topTracks
LastFMTrackConnectionA list of the artist’s most popular tracks.
first
IntThe maximum number of tracks to retrieve.
after
StringThe cursor of the edge after which more tracks will be retrieved.
biography
LastFMWikiContentA biography of the artist, often available in several languages.
lang
StringThe two-letter code for the language in which to retrieve the biography.
#### LastFMArtistConnection
A connection to a list of items.
Field
Argument
Type
DescriptionpageInfo
PageInfo!Information to aid in pagination.
edges
[LastFMArtistEdge]A list of edges.
nodes
[LastFMArtist]A list of nodes in the connection (without going through the `edges` field).
totalCount
IntA count of the total number of items in this connection, ignoring pagination.
#### LastFMArtistEdge
An edge in a connection.
Field
Argument
Type
Descriptionnode
LastFMArtistThe item at the end of the edge.
cursor
String!A cursor for use in pagination.
matchScore
FloatThe artist similarity score (0–1) as determined by [Last.fm](https://www.last.fm/),
if this connection is with another artist.#### LastFMChartQuery
A query for chart data on [Last.fm](https://www.last.fm/).
Field
Argument
Type
DescriptiontopArtists
LastFMArtistConnectionThe most popular artists, ordered by popularity. If a country code is
given, retrieve the most popular artists in that country.country
StringA two-letter [ISO 3166 country code](https://en.wikipedia.org/wiki/ISO_3166).
first
IntThe maximum number of artists to retrieve.
after
StringThe cursor of the edge after which more artists will be retrieved.
topTags
LastFMTagConnectionThe most popular tags, ordered by popularity.
first
IntThe maximum number of tags to retrieve.
after
StringThe cursor of the edge after which more tags will be retrieved.
topTracks
LastFMTrackConnectionThe most popular tracks, ordered by popularity. If a country code is
given, retrieve the most popular tracks in that country.country
StringA two-letter [ISO 3166 country code](https://en.wikipedia.org/wiki/ISO_3166).
first
IntThe maximum number of tracks to retrieve.
after
StringThe cursor of the edge after which more tracks will be retrieved.
#### LastFMCountry
A country with chart data available on [Last.fm](https://www.last.fm/).
Field
Argument
Type
DescriptiontopArtists
LastFMArtistConnectionThe top artists in this country, ordered by popularity.
first
IntThe maximum number of artists to retrieve.
after
StringThe cursor of the edge after which more artists will be retrieved.
topTracks
LastFMTrackConnectionThe top tracks in this country, ordered by popularity.
first
IntThe maximum number of tracks to retrieve.
after
StringThe cursor of the edge after which more tracks will be retrieved.
#### LastFMQuery
The different types of [Last.fm](https://www.last.fm/) queries that can be
made that are not connected to any particular MusicBrainz entity.Field
Argument
Type
Descriptionchart
LastFMChartQuery!A query for chart data.
#### LastFMTag
A tag added by users to an entity on [Last.fm](https://www.last.fm/).
Field
Argument
Type
Descriptionname
String!The tag name.
url
URLString!The URL for the tag on [Last.fm](https://www.last.fm/).
#### LastFMTagConnection
A connection to a list of items.
Field
Argument
Type
DescriptionpageInfo
PageInfo!Information to aid in pagination.
edges
[LastFMTagEdge]A list of edges.
nodes
[LastFMTag]A list of nodes in the connection (without going through the `edges` field).
totalCount
IntA count of the total number of items in this connection, ignoring pagination.
#### LastFMTagEdge
An edge in a connection.
Field
Argument
Type
Descriptionnode
LastFMTagThe item at the end of the edge.
cursor
String!A cursor for use in pagination.
tagCount
IntThe number of times the tag has been applied to the item in question.
#### LastFMTrack
A track on [Last.fm](https://www.last.fm/) corresponding with a MusicBrainz
Recording.Field
Argument
Type
Descriptionmbid
MBIDThe MBID of the corresponding MusicBrainz recording.
title
StringThe title of the track according to [Last.fm](https://www.last.fm/).
url
URLString!The URL for the track on [Last.fm](https://www.last.fm/).
duration
DurationThe length of the track.
listenerCount
FloatThe number of listeners recorded for the track.
playCount
FloatThe number of plays recorded for the track.
description
LastFMWikiContentHistorical information written about the track, often available in several
languages.lang
StringThe two-letter code for the language in which to retrieve the description.
artist
LastFMArtistThe artist who released the track. This returns the Last.fm artist info,
not the MusicBrainz artist.album
LastFMAlbumThe album on which the track appears. This returns the Last.fm album info,
not the MusicBrainz release.similarTracks
LastFMTrackConnectionA list of similar tracks.
first
IntThe maximum number of tracks to retrieve.
after
StringThe cursor of the edge after which more tracks will be retrieved.
topTags
LastFMTagConnectionA list of tags applied to the track by users, ordered by popularity.
first
IntThe maximum number of tags to retrieve.
after
StringThe cursor of the edge after which more tags will be retrieved.
#### LastFMTrackConnection
A connection to a list of items.
Field
Argument
Type
DescriptionpageInfo
PageInfo!Information to aid in pagination.
edges
[LastFMTrackEdge]A list of edges.
nodes
[LastFMTrack]A list of nodes in the connection (without going through the `edges` field).
totalCount
IntA count of the total number of items in this connection, ignoring pagination.
#### LastFMTrackEdge
An edge in a connection.
Field
Argument
Type
Descriptionnode
LastFMTrackThe item at the end of the edge.
cursor
String!A cursor for use in pagination.
matchScore
FloatThe track similarity score (0–1) as determined by [Last.fm](https://www.last.fm/),
if this connection is with another track.#### LastFMWikiContent
Biographical or background information written about an entity on
[Last.fm](https://www.last.fm/).Field
Argument
Type
DescriptionsummaryHTML
StringA summary of the wiki content, which may contain HTML.
contentHTML
StringThe full wiki content, which may contain HTML.
publishDate
DateThe date the content was published. The data is reformatted from the
Last.fm API’s original format into the Date scalar format.publishTime
TimeThe 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.url
URLStringThe URL at which the content was published.
#### Query
:small_blue_diamond: *This type has been extended.
See the [base schema](https://github.com/exogen/graphbrainz/docs/types.md) for a description and additional fields.*Field
Argument
Type
DescriptionlastFM
LastFMQueryA query for data on [Last.fm](https://www.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](https://github.com/exogen/graphbrainz/docs/types.md) for a description and additional fields.*Field
Argument
Type
DescriptionlastFM
LastFMTrackData about the recording from [Last.fm](https://www.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](https://github.com/exogen/graphbrainz/docs/types.md) for a description and additional fields.*Field
Argument
Type
DescriptionlastFM
LastFMAlbumData about the release from [Last.fm](https://www.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](https://www.last.fm/).
Value
DescriptionSMALL
A maximum dimension of 34px.
MEDIUM
A maximum dimension of 64px.
LARGE
A maximum dimension of 174px.
EXTRALARGE
A maximum dimension of 300px.
MEGA
A maximum dimension of 300px.
[Last.fm]: https://www.last.fm/
[Last.fm API]: https://www.last.fm/api
[GraphBrainz]: https://github.com/exogen/graphbrainz
[demo]: https://graphbrainz-extension-lastfm.herokuapp.com/