Giter VIP home page Giter VIP logo

discogsapi's Introduction

DiscogsAPI wrapper for Python

Build Status

Discogs API for Python

This is a Discogs API wrapper for Python. (API version 2.0)

Usage

>>> from discogsapi import Discogs
>>> discogs = Discogs(user_agent="HeyBaldock/1.0 +http://heybaldock.com.br")
>>> artist = discogs.artists.get(45)
>>> artist
<Artist: Aphex Twin>
>>> artist.name
'Aphex Twin'

The argument user_agent is required. Discogs API will block ips from requests with bad user_agent names. See the advise below from www.discogs.com/developers/accessing.html: " Your application must provide a User-Agent string that identifie itself - preferably something that follows RFC 1945. Some good examples include: AwesomeDiscogsBrowser/0.1 +http://adb.example.com LibraryMetadataEnhancer/0.3 +http://example.com/lime MyDiscogsClient/1.0 +http://mydiscogsclient.org

Please don't just copy one of those! Make it unique so we can let you know if your application starts to misbehave - the alternative is that we just silently block it, which will confuse and infuriate your users. Here are some bad examples that are unclear or obscure the nature of the application: curl/7.9.8 (i686-pc-linux-gnu) libcurl 7.9.8 (OpenSSL 0.9.6b) Mozilla/5.0 (X11; Linux i686; rv:6.0.2) Gecko/20100101 Firefox/6.0 my app "

Resources

Discogs API has many resources in 3 categories:

  • Database
    • Artists
    • Releases
    • Masters
    • Labels
    • Image
    • Search
  • Market Place
    • Fee
    • Inventory
    • Listing
    • Order
    • Price Suggestions
  • User
    • Colletion
    • Identify
    • Profile
    • Wantlist

Database Category

Artists

>>> from discogsapi import Discogs
>>> discogs = Discogs(user_agent="HeyBaldock/1.0 +http://heybaldock.com.br")
>>> artist = discogs.artists.get(45)
>>> artist
<Artist: Aphex Twin>
>>> artist.name
'Aphex Twin'
>>> releases = artist.releases()
>>> releases
<discogsapi.resource.database.release.Releases Generator: [<Release: Analog Bubblebath Vol 2>, <Release: Analogue Bubblebath>, <Release: Digeridoo>, '...']>
>>> releases.next()
<Release: Analog Bubblebath Vol 2>
>>> releases.next()
<Release: Analogue Bubblebath>

Possible Artist attributes:

  • images
  • members
  • name
  • namevariations
  • realname
  • urls
  • releases -> will retrieve a generator with Release instances

Releases

The Discogs.releases resource retrieves a generator with Release instances, see below:

>>> from discogs import Discogs
>>> from resource.database.artist import ArtistsResource
>>> discogs = Discogs("HeyBaldock/1.0 +http://heybaldock.com.br")
>>> releases = discogs.releases.get(45)
>>> releases
<Release: Push Along EP>

Masters

The Discogs.masters resource retrieves a Master instance with the correspond details:

>>> discogs = Discogs("HeyBaldock/1.0 +http://heybaldock.com.br")
>>> discogs.masters.get(8471)
<Master: Back In Black>

Labels

The Discogs.masters resource retrieves a Master instance with the correspond details:

>>> discogs = Discogs("HeyBaldock/1.0 +http://heybaldock.com.br")
>>> discogs.labels.get(45)
<Label: Groovin' Records>

Image

The Discogs.images resource provides an Image instance with the response image data:

>>> discogs = Discogs("HeyBaldock/1.0 +http://heybaldock.com.br")
>>> image = discogs.images.get('R-150-63114-1148806222.jpeg')
>>> image
<Image: R-150-63114-1148806222.jpeg>
>>> getattr(image, 'response', None) is not None
True

Search

The Discogs.search resource provides a query search:

>>> discogs = Discogs("HeyBaldock/1.0 +http://heybaldock.com.br")
>>> results = discogs.search.query(dict(q='The Beatles', type='artist'))
>>> isinstance(results, dict)
True
>>> results.has_key('resp')
True
>>> results['resp'].has_key('status')
True
>>> results['resp'].has_key('search')
True
>>> results['resp']['search'].has_key('searchresults')
True
>>> results['resp']['search']['searchresults'].has_key('numResults')
True
>>> results['resp']['search']['searchresults']['numResults'].isdigit()
True
>>> int(results['resp']['search']['searchresults']['numResults']) > 0
True

Licence

License (GPLv3)

Copyright (C) 2013 Rogerio Hilbert Lima [email protected]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

discogsapi's People

Contributors

rogerhil avatar

Stargazers

Luiz Consani avatar  avatar Paulo avatar

Watchers

 avatar James Cloos avatar Luiz Consani 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.