• teo over 8 years ago

    teo edited over 7 years ago
    Today we are rolling out an updated version of the Discogs API! Our original API was released in 2007 and we've seen many interesting applications come out of it. This new version lays the foundation for more enhancements like user login, managing your collection/wantlist/sales inventory, and other cool things we'll be working on this year.

    Some of the major changes:
    * The API uses a new url: api.discogs.com
    * An API key is no longer required
    * We have removed the 5,000 requests per day limit*
    * We are offering an official Python API client. Check it out on github (http://github.com/discogs ). Feel free to fork it and submit pull requests. You can help us improve it!
    * Responses are returned in JSON format now. You can still request XML if you prefer that.
    * JSONP support

    NOTE
    We are phasing out the old API and it will be shut down on Jan 15, 2012. We will email all users with an API key asking them to migrate to the new version.

    * API requests are still throttled, but if you are interested in unrestricted access, we are developing a premium API, please get in touch.

    Dec 12, 2011: We have extended the cutoff date to Jan 15, 2012.
  • jweijde over 8 years ago

    Previously I was able to open an API url in my browser (Firefox 3), now I keep getting 'Invalid API request' errors. Why?

    http://api.discogs.com/release/465740?f=xml
    http://api.discogs.com/release/465740
  • jweijde over 8 years ago

    Works now but http://api.discogs.com/release/465740 seems to return XML, is that right?
  • jahsavage over 8 years ago

    All url forms (including '?f=json') still return an Invalid API request.
  • vreon over 8 years ago

    Make sure you're supplying the Accept-Encoding header, since large responses may be compressed.

    As an example, this will fail:

    $ curl -A "VreonClient/0.1" http://api.discogs.com/release/1165273
    {"resp": {"status": false, "version": "2.0", "error": "Invalid API request"}}

    But this works:

    $ curl -H "Accept-Encoding: gzip" -A "VreonClient/0.1" http://api.discogs.com/release/1165273
    {"resp": {"status": true, "release": { ... }, "version": "2.0"}}

    If you're seeing XML by default instead of JSON, your browser is likely sending the Accept: application/xml header on your behalf. You can verify this with the Network tab in Chrome Inspector or Firebug. The ?f= query string parameter takes precedence over the Accept header, so use that for in-browser debugging.
  • mbj over 8 years ago

    Hi,

    When I send a GET request to http://api.discogs.com/search, I get a bunch of results back. This is fine, but I miss a link to retrieve more info through the api. For example, the request:

    http://api.discogs.com/search?q=kraftwerk+ralf+florian

    will return some results of type "release". There's a "uri" field, but it points to www.discogs.com. I would like a link to http://api.discogs.com/release/NNN for each such release.

    Also, it seems a master release is always returned first. Is this something we can rely on?
  • vreon over 8 years ago

    Regarding your first point, if you want a URL representing an API request for a release object, I recommend you pull the ID off of the end of the URL returned and use that to construct an http://api.discogs.com/release/NNN URL.

    It's not the prettiest solution -- ultimately I'd like to return the ID in its own key -- but this is what our own Python client / reference implementation does, so you can be confident we won't break that usage pattern.

    As for master releases always being returned first, you ought not to rely on that. Consider the order of any element's children undefined (and that goes for JSON arrays and objects too).
  • jahsavage over 8 years ago

    Looking at the Artist's releases xml I notice the master version lacks label and format information, could this please be added to match the release data since currently the master data is a bit of a poor cousin.

    Also is it possible to request just the master releases?
  • vreon over 8 years ago

    jahsavage
    I notice the master version lacks label and format information


    My gut feeling is that "label" and "format" don't make sense in the context of a master release, and should you need that information, you should look at the master's main release (either by fetching the master and iterating through its versions array or fetching the release directly).

    But the goal of adding masters to the artist's releases list was to bring the API into sync with artist pages, which I notice display the label of the main release next to each master. So I'll consult the rest of the team about this one.

    jahsavage
    Also is it possible to request just the master releases?


    That's unlikely to be implemented in the short term, since you can just filter the data you get back. (Though I do like the idea of having ?releases=1 for the old behavior, ?masters=1 for just masters, and both for the present behavior.)
  • jahsavage over 8 years ago

    For API 1.0 it was possible to filter an Artist's Release by format, now with the introduction of master entry without its corresponding release entry, its no longer possible without first fetching the master details.

    As you might expect this shall result in an increased server load and client side complexity.



  • jahsavage over 8 years ago

    Sorry to rant but the Master/Release issue will have enormous impact on the ease use and the flexibility of client software. The ability of request just master releases would simplify many operations and make many possible UI presentations easily achievable without bombarding the server.

    A larger range of flexible APIs would enable API requests to become more targeted so less data needs to be delivered and therefore discarded at the client end. The Artist Release structure is currently quite large and monolithic; breaking it down into smaller fragments by format, master, year would result in a more flexible solution which would load the server less.

    The price to pay is of course more API's at the server end to maintain, but the gain is a more scalable solution which provides more flexibility for users of the API.

    While I'm in full rant mode I might as ask if you have any plans to offer an API for discogs ads and a corresponding client reward scheme?

  • jahsavage over 8 years ago

    After playing with the 2.0 API over the weekend I think using masters to reduce the bulk of Artist release section is a great. Unfortunately we have lost detail in the process, could we please have a format tag added to the master entries which represents a merge of the children formats?

    Since API 2.0 limits request to 1 per second it is not be easy to determine this information any other way.
  • vreon over 8 years ago

    I like the idea of merging the formats. I'll pass that along and see what the others think.

    To address your older posts:

    jahsavage
    Sorry to rant


    Don't worry about it :) I really appreciate the feedback. It helps us understand how people are using the API so we can identify the weak spots and make it better.

    jahsavage
    The Artist Release structure is currently quite large and monolithic


    I definitely want to set up pagination at the very least; many artists have far too many releases than are reasonable to return in a single request. In your case, where you want to get a comprehensive list of certain formats, this would actually result in *more* requests, because you'd have to crawl the pages. So there's an argument for filtering as well, I just need to mull over how best to do that.

    jahsavage
    While I'm in full rant mode I might as ask if you have any plans to offer an API for discogs ads and a corresponding client reward scheme?


    Not presently, no.
  • hydroponic1 over 8 years ago

    Are there any limitations on commercial use of this API?
  • fzero over 8 years ago

    I agree with the jahsavage idea to put a format tag into the master entries to represents format of release...
  • jahsavage over 8 years ago

    Any idea when you might be adding API support to retrieve and upload user collections and wanted lists?
  • kevinvds over 8 years ago

    When I search for "doors" on the website, discogs returns me 2 exact matches.

    If I call this through the api:

    http://api.discogs.com/search?q=doors

    I get a much smaller result list, with "Dark Doors" as the only result tagged as an artist. I'd like to be able to get the same results through the api, if possible. :-)
    If I pass "Doors, The" to the api, it doesn't even give me an artist result.
    am I doing something wrong here?

    cheers
    Kevin
  • jahsavage over 8 years ago

    Add &type=releases and all will be well!
  • pjv over 8 years ago

    For Collectionista, I've switched to v2 using JSON (see here http://bazaar.launchpad.net/~pjv/collectionista/trunk/revision/346). I wrote a small library that entirely matches the google-api-java-client with generated models.

    For those not familiar with google-api-java-client (http://code.google.com/p/google-api-java-client), it is the one official standard way of accessing all (most?) modern Google APIs, either via JSON or XML, be it via Java, Android (what I'm using it for) or App Engine, with possibility for OAuth and so on, transparent for transport mechanisms and parsers, and in an efficient manner.

    Mine is just a small layer that just calls the right REST methods, and a set of model classes, mirrored after the google-api-services-books-v1-1.0.0-beta.jar. It is currently limited to the Search and Release resources, but to add the rest would be routine.

    You guys from Discogs should have a look in there, as to how Google makes really powerful APIs, that are yet cheap and simple to implement. Especially when the Books API could be so comparable. I'm talking about the collections and methods (parts of the URIs), the "filter", the fact that they allow to prepend q with "ISBN:", the projection (which really would save bandwidth), and so much more. What I do like about the Discogs APIs is how complete they are, and the amount of useful and clean information they contain.

    If anybody is interested I can extract the Discogs Java library from my code and repository. Just let me know.
  • vreon over 8 years ago

    jahsavage
    Any idea when you might be adding API support to retrieve and upload user collections and wanted lists?


    That and Marketplace data will be coming in the next big API update, but the timeline for that is sort of vague. I'll go with "soon", but not next-couple-of-weeks-soon.

    kevinvds
    When I search for "doors" on the website, discogs returns me 2 exact matches.


    jahsavage
    Add &type=releases and all will be well!


    jahsavage has it, though I think he means &type=artists :)

    pjv
    You guys from Discogs should have a look in there


    Thanks for the pointer! The Books API does look really flexible. We plan to add similar filtering and pagination so your clients don't explode when they try to load EMI's releases (for example).

    My ultimate goal is to bring full-fledged HATEOAS to the Discogs API, much like GitHub has done with their API v3.
  • skardas over 8 years ago

    skardas edited over 8 years ago
    We are phasing out the old API and it will be shut down on Dec 15, 2011.


    How come that old API not supported now? Ive used old API few years without problem, but today I got response from new API - in result my parser wont work.

    edit: updated to new api - should be new and unique user-agent...
    i hope xml will be supported and after december

  • pyc over 8 years ago

    Seems like old API is not working any more? Somebody confirm?
  • b33dewd over 8 years ago

    I can confim. Since yesterday it's not working :|

    IF only someone from the dev team could tell us what is going on..
  • pyc over 8 years ago

    Is there a chance old code will work soon? So we don't make changes that are not required...?
  • b33dewd over 8 years ago

    solution in my case: need to define a non genereric user-agent in the request process
  • pkanz over 8 years ago

      b33dewd - You shouldn't use some other companies user-agent and a href from their site. It's o.k. to use your site info.
  • richnrgflash over 8 years ago

    Same problem here, api stopped working today,

    shall we hang on till its up and running again?

    or has it changed for good?
  • combox over 8 years ago

    hello! I use foobar 2000pack v.0.9.4 b1
    And I had there a discogs tagger (v.1.13) and he always worked fine last 2 years but 2-3 days ago the discogs tagger for my foobar dont want to work. It says:"discogs error: release id=3012429:XML parse error".
    Can you please help me how to get rid of this error becourse as i could get a right view a problem - you have changed something)
    Please help!
  • pkanz over 8 years ago

      combox - Please have the developers of the apps in question open a support request at http://www.discogs.com/support/new We'll work with them to identify the issue.
  • kevinvds over 8 years ago

    kevinvds edited over 8 years ago
    I'm a bit late, but: thanks for the answers!

    I was wondering whether the limitation on requests (1 per sec/IP) is also the case for images? If I were to make multiple requests per second to http://s.dsimg.com, would this work?
    Cause my app is experiencing symptoms like that and I want to make sure this really is the problem before I spend an awful lot of time trying to figure out a way to fix this..
  • jweijde over 8 years ago

    Just reposting a Support Request here.

    I encountered the following using API 2.0:
    http://api.discogs.com/label/Mercury+Music+Entertainment does not have any releases in the response, while there are four items on the http://www.discogs.com/label/Mercury+Music+Entertainment page.

    Someone else reported that the Year of a release is missing in the label responses:
    http://www.discogs.com/help/forums/topic/268123

    looks like something is wrong here. Can you take a look at it?
    The old API seems to be working fine.
  • Misko19 over 8 years ago

    Would it be possible to add the number of versions that each master release has as part of what is provided when doing an artist API query using releases=1? With API v1.0, I parsed the results myself to determine how many versions there were for each album (comparing artist, title, and year), but that's no longer possible with master releases. Now I have to request each master release and count the number of child nodes of the versions node.

    Don't get me wrong, the new version of the API is absolutely great. I love the idea of the master releases, and love that thumbnails are provided for each release returned from an artist query. The only thing that's missing for me is the number of versions.

    You stated in an earlier post that the goal is to bring the API in sync with the artist pages. Adding the number of versions would do just that.

    Thanks for all of your hard work. It's greatly appreciated.
  • vreon over 8 years ago

    jweijde
    I encountered the following using API 2.0:
    http://api.discogs.com/label/Mercury+Music+Entertainment does not have any
    releases in the response, while there are four items on the http://www.discogs.com/label/Mercury+Music+Entertainment page.


    I think you want http://api.discogs.com/label/Mercury+Music+Entertainment?releases=1 .

    jweijde
    Someone else reported that the Year of a release is missing in the label responses


    Misko19
    Would it be possible to add the number of versions that each master release has


    These are both slated to be added in the next batch of API enhancements :)
  • RichGuk over 8 years ago

    I think the year is missing from master, or I'm not understanding it correctly.

    http://www.discogs.com/master/4030 and http://www.discogs.com/master/38630 both have a year.

    but this isn't shown on http://api.discogs.com/master/4030 and http://api.discogs.com/master/38630

    Wasn't too sure if this is intentional, how reliable is the date from the master? I basically want to fetch the original release date for any given master, or release.

Log In You must be logged in to post.