https://github.com/michiwend/gomusicbrainz
a Go (Golang) MusicBrainz WS2 client library - work in progress
https://github.com/michiwend/gomusicbrainz
client client-library go golang musicbrainz musicbrainz-api
Last synced: 4 months ago
JSON representation
a Go (Golang) MusicBrainz WS2 client library - work in progress
- Host: GitHub
- URL: https://github.com/michiwend/gomusicbrainz
- Owner: michiwend
- License: mit
- Created: 2014-09-10T16:42:33.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-05-15T09:58:33.000Z (over 2 years ago)
- Last Synced: 2025-04-19T21:54:08.378Z (7 months ago)
- Topics: client, client-library, go, golang, musicbrainz, musicbrainz-api
- Language: Go
- Homepage:
- Size: 184 KB
- Stars: 60
- Watchers: 5
- Forks: 24
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go-cn - GoMusicBrainz
- awesome-go-plus - GoMusicBrainz - Go MusicBrainz WS2 client library.  (Third-party APIs / Utility/Miscellaneous)
- fucking-awesome-go - :octocat: GoMusicBrainz - a Go MusicBrainz WS2 client library. :star: 18 :fork_and_knife: 6 (Third-party APIs / Advanced Console UIs)
- awesome-go - GoMusicBrainz - Go MusicBrainz WS2 client library. (Third-party APIs / Utility/Miscellaneous)
- awesome-go - GoMusicBrainz - | - | - | (Third-party APIs / HTTP Clients)
- awesome-go - GoMusicBrainz - Go MusicBrainz WS2 client library. - :arrow_down:8 - :star:19 (Third-party APIs / HTTP Clients)
- awesome-go - gomusicbrainz - a Go (Golang) MusicBrainz WS2 client library - work in progress - ★ 31 (Third-party APIs)
- awesome-go-cn - GoMusicBrainz
- awesome-go - GoMusicBrainz - Go MusicBrainz WS2 client library. (Third-party APIs / Utility/Miscellaneous)
- awesome-go - GoMusicBrainz - Go MusicBrainz WS2 client library. (Third-party APIs / Utility/Miscellaneous)
- awesome-go-cn - GoMusicBrainz
- awesome-go-with-stars - GoMusicBrainz - Go MusicBrainz WS2 client library. (Third-party APIs / Utility/Miscellaneous)
- fucking-awesome-go - GoMusicBrainz - Go MusicBrainz WS2 client library. (Third-party APIs / Utility/Miscellaneous)
- awesome-Char - GoMusicBrainz - Go MusicBrainz WS2 client library. (Third-party APIs / HTTP Clients)
- awesome-go-cn - GoMusicBrainz
- awesome-go - GoMusicBrainz - Go MusicBrainz WS2 client library. (Third-party APIs / Advanced Console UIs)
- awesome-go - GoMusicBrainz - Go MusicBrainz WS2 client library. (Third-party APIs / HTTP Clients)
- awesome-go-zh - GoMusicBrainz
- awesome-go-extra - gomusicbrainz - work in progress|46|18|5|2014-09-10T16:42:33Z|2021-02-09T23:41:40Z| (Third-party APIs / Fail injection)
- awesome-go - GoMusicBrainz - Go MusicBrainz WS2 client library. (<span id="第三方api-third-party-apis">第三方API Third-party APIs</span> / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go - GoMusicBrainz - Go MusicBrainz WS2 client library. (Third-party APIs / Utility/Miscellaneous)
- awesome-go - GoMusicBrainz - Go MusicBrainz WS2 client library. (Third-party APIs / Utility/Miscellaneous)
README
# gomusicbrainz [](http://opensource.org/licenses/MIT) [](https://godoc.org/github.com/michiwend/gomusicbrainz) [](https://gowalker.org/github.com/michiwend/gomusicbrainz) [](https://travis-ci.org/michiwend/gomusicbrainz)
a Go (Golang) MusicBrainz WS2 client library - a work in progress.

## Current state
Currently GoMusicBrainz provides methods to perform search and lookup requests. Browse requests are not supported yet.
## Installation
```bash
$ go get github.com/michiwend/gomusicbrainz
```
## Search Requests
GoMusicBrainz provides a search method for every WS2 search request in the form:
```Go
func (*WS2Client) Search(searchTerm, limit, offset) (SearchResponse, error)
```
searchTerm follows the Apache Lucene syntax and can either contain multiple
fields with logical operators or just a simple search string. Please refer to
[lucene.apache.org](https://lucene.apache.org/core/4_3_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description)
for more details on the lucene syntax. In addition the
[MusicBrainz website] (https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2/Search)
provides information about all possible query-fields.
### Example
This example demonstrates a simple search requests to find the artist
*Parov Stelar*. You can find it as a runnable go program in the samples folder.
```Go
// create a new WS2Client.
client := gomusicbrainz.NewWS2Client(
"https://musicbrainz.org/ws/2",
"A GoMusicBrainz example",
"0.0.1-beta",
"http://github.com/michiwend/gomusicbrainz")
// Search for some artist(s)
resp, _ := client.SearchArtist(`artist:"Parov Stelar"`, -1, -1)
// Pretty print Name and score of each returned artist.
for _, artist := range resp.Artists {
fmt.Printf("Name: %-25sScore: %d\n", artist.Name, resp.Scores[artist])
}
```
the above code will produce the following output:
```
Name: Parov Stelar Score: 100
Name: Parov Stelar Trio Score: 80
Name: Parov Stelar & the Band Score: 70
```
## Lookup Requests
GoMusicBrainz provides two ways to perform lookup requests: Either the specific
lookup method that is implemented for each entity that has a lookup endpoint in
the form
```Go
func(*WS2Client) Lookup(id MBID, inc ...string) (*, error)
```
or the common lookup method if you already have an entity (with MBID) that
implements the MBLookupEntity interface:
```Go
func(*WS2Client) Lookup(entity MBLookupEntity, inc ...string) error
```
### Example
The following example demonstrates the (specific) LookupArtist method. You can
find it as a runnable go program in the samples folder.
```Go
// create a new WS2Client.
client, _ := gomusicbrainz.NewWS2Client(
"https://musicbrainz.org/ws/2",
"A GoMusicBrainz example",
"0.0.1-beta",
"http://github.com/michiwend/gomusicbrainz")
// Lookup artist by id.
artist, err := client.LookupArtist("9a709693-b4f8-4da9-8cc1-038c911a61be")
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("%+v", artist)
```
## Package Documentation
Full documentation for this package can be found at
[GoDoc](https://godoc.org/github.com/michiwend/gomusicbrainz)
and [GoWalker](https://gowalker.org/github.com/michiwend/gomusicbrainz)