Code Monkey home page Code Monkey logo

musicgraph's Introduction

MusicGraph

A Ruby gem to access the MusicGraph API.

Installation

Add this line to your application's Gemfile:

gem 'musicgraph'

And then execute:

$ bundle

Or install it yourself as:

$ gem install musicgraph

Usage

MusicGraph.api_key = "[api key]"

artist = MusicGraph::Artist.search('kaiser chiefs').first
artist.name # => "Kaiser Chiefs"
artist.main_genre # => "rock"
artist.decade # => "2000s / 2010s"

artists = MusicGraph::Artist.search({similar_to: "Pink Floyd"})
artists.first.name # => "David Gilmour"
artists.last.name # => "Eric Clapton"

artists = MusicGraph::Artist.search({decade: "1990s"})
artists.first.name # => "Lil Wayne"

artists = MusicGraph::Artist.search({genre: "Soul/R&B"})
artists.last.name # => "Amy Winehouse"

artists = MusicGraph::Artist.search({gender: "female"})
artists.last.name # => "Shakira"

artists = MusicGraph::Artist.search({country: "wales"})
artists.last.name # => "Tom Jones"

artists = MusicGraph::Artist.search({limit: 5})
artists.length # => 5

artist = MusicGraph::Artist.suggest("king").last
artist.name # => "King James"

artist = MusicGraph::Artist.find("e4de0d41-a6b5-11e0-b446-00251188dd67")
artist.name # => "Beck"

artist.edges # => ["albums", "similar", "tracks"]

artist.metadata # => returns all available metadata

artist.similar.first # => "Bob Forrest"

artist.albums # => returns array of albums belonging to artist

artist.tracks # => returns array of tracks belonging to artist

artist = MusicGraph::Artist.find("e4de0d41-a6b5-11e0-b446-00251188dd67", ["id", "name"])
artist.name # => "Beck"
artist.gender # => nil

Testing

To configure the gem for testing, add the following to .env: MUSICGRAPH_API_KEY=xyz (where "xyz" is your MusicGraph API key)

Contributing

  1. Fork it ( https://github.com/[djpowers]/musicgraph/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

musicgraph's People

Contributors

djpowers avatar

Watchers

Nicolas Kaniak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.