Latest 1.8.0
Homepage https://github.com/maxep/DiscogsAPI
License MIT
Platforms ios 8.0, requires ARC
Authors

CI Status
Version
License
Platform

An Objective-C interface for Discogs API v2.0.

The implementation is based on RestKit.

Features

  • Supports OAuth process and store the token in keychain.
  • Supports Discogs Auth.
  • Database support: Release, Master Release, Master Release Versions, Artist, Artist Releases, Label, All Label Releases, Search.
  • User support: Identify, Profile, Collection, Wantlist.
  • Marketplace: Inventory, Listing.
  • Image support.

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects.

Podfile
pod 'DiscogsAPI'

Usage

If you want to try it, simply run:

pod try DiscogsAPI

Or clone the repo and run pod install from the Example directory first.

Authentication

Configure the .plist for your project:

Right-click your .plist file and choose "Open As Source Code".
Copy & Paste the XML snippet into the body of your file (<dict>...</dict>). You can use rather the key/secret pair or your personal access token (you can create them in your profile settings).

Key/Secret

Replace DISCOGS_APP_CONSUMER_KEY and DISCOGS_APP_CONSUMER_SECRET with your Discogs App consumer key and secret.

<key>DiscogsConsumerKey</key>
<string>DISCOGS_APP_CONSUMER_Key</string>
<key>DiscogsConsumerSecret</key>
<string>DISCOGS_APP_CONSUMER_SECRET</string>
Personal Access Token

Replace DISCOGS_PERSONAL_ACCESS_TOKEN by you personal access token.

<key>DiscogsAccessToken</key>
<string>DISCOGS_PERSONAL_ACCESS_TOKEN</string>

Authentication flow

Discogs supports two authentication methods: The Discogs Auth and OAuth. Please refer to the documentation for more details.

Discogs Auth

The key/secret or your personal access token will be automatically retrieved from your project configuration and used in your request headers. Nothing to be done on your side.

OAuth

OAuth process is all handled by the ‘authentication’ endpoint. You just have to show the ‘authView’ view to let the user enter his credentials and authorize the application. The token will be automatically stored in the keychains.

    [Discogs.api.authentication authenticateWithPreparedAuthorizationViewHandler:^(UIView *authView) {

        // Show the authView

    } success:^{
        NSLog(@"The user has been successfully authentified");
    } failure:^(NSError *error) {
        NSLog(@"Error: %@", error);
    }];

Database

The following examples shows how to access Discogs database objects through the api.

Release
    [Discogs.api.database getRelease:@249504 success:^(DGRelease *release) {
        NSLog(@"Release: %@", release);
    } failure:^(NSError *error) {
        NSLog(@"Error: %@", error);
    }];
Master Release
    [Discogs.api.database getMaster:@1000 success:^(DGMaster *master) {
        NSLog(@"Master: %@", master);
    } failure:^(NSError *error) {
        NSLog(@"Error: %@", error);
    }];
Master Release Versions
    DGMasterVersionsRequest *request = [DGMasterVersionsRequest new];
    request.masterID = @1000;
    request.pagination.page = @3;
    request.pagination.perPage = @25;

    [Discogs.api.database getMasterVersion:request success:^(DGMasterVersionsResponse *response) {
        NSLog(@"Versions: %@", response.versions);
    } failure:^(NSError *error) {
        NSLog(@"Error: %@", error);
    }];
Artist
    [Discogs.api.database getArtist:@108713 success:^(DGArtist *artist) {
        NSLog(@"Artist: %@", artist);
    } failure:^(NSError *error) {
        NSLog(@"Error: %@", error);
    }];
Artist Releases
    DGArtistReleasesRequest *request = [DGArtistReleasesRequest new];
    request.artistID = @108713;
    request.pagination.page = @3;
    request.pagination.perPage = @25;

    [Discogs.api.database getArtistReleases:request success:^(DGArtistReleasesResponse *response) {
        NSLog(@"Releases: %@", response.releases);
    } failure:^(NSError *error) {
        NSLog(@"Error: %@", error);
    }];
Label
    [Discogs.api.database getLabel:@1 success:^(DGLabel *label) {
        NSLog(@"Label: %@", label);
    } failure:^(NSError *error) {
        NSLog(@"Error: %@", error);
    }];
Label Releases
    DGLabelReleasesRequest *request = [DGLabelReleasesRequest new];
    request.labelID = @1;
    request.pagination.page = @3;
    request.pagination.perPage = @25;

    [Discogs.api.database getLabelReleases:request success:^(DGLabelReleasesResponse *response) {
        NSLog(@"Releases: %@", response.releases);
    } failure:^(NSError *error) {
        NSLog(@"Error: %@", error);
    }];
Search
    DGSearchRequest *request = [DGSearchRequest new];
    request.query = @"Cool band";
    request.type = @"artist";
    request.pagination.perPage = @25;

    [Discogs.api.database searchFor:request success:^(DGSearchResponse *response) {
        NSLog(@"Results: %@", response.results);
    } failure:^(NSError *error) {
        NSLog(@"Error: %@", error);
    }];

Pagination

From a paginated response, loading the next page is made easy by the DGPaginated protocol:

    [response loadNextPageWithSuccess:^{
        // Update UI
    } failure:^(NSError * _Nullable error) {
        NSLog(@"Error : %@", error);
    }];

More usage

Detailed usage instructions are available in the Wiki.

Documentation

Documentation is available through CocoaDocs

Author

Maxime Epain

Twitter

License

DiscogsAPI is available under MIT License. See the LICENSE for more info.

Latest podspec

{
    "name": "DiscogsAPI",
    "version": "1.8.0",
    "summary": "An Objective-C interface for Discogs API v2.0.",
    "description": "Features:n- Supports OAuth process and store the token in keychain.n               - Supports Discogs Auth.n- Database support: Release, Master Release, Master Release Versions, Artist, Artist Releases, Label, All Label Releases, Search.n- User support: Identify, Profile, Collection, Wantlist.n               - Marketplace support: Price suggestions, Listings, Orders.n- Image support.",
    "homepage": "https://github.com/maxep/DiscogsAPI",
    "license": "MIT",
    "authors": {
        "Maxime Epain": "[email protected]"
    },
    "social_media_url": "https://twitter.com/MaximeEpain",
    "source": {
        "git": "https://github.com/maxep/DiscogsAPI.git",
        "tag": "1.8.0"
    },
    "documentation_url": "http://cocoadocs.org/docsets/DiscogsAPI",
    "requires_arc": true,
    "platforms": {
        "ios": "8.0"
    },
    "ios": {
        "frameworks": [
            "CFNetwork",
            "MobileCoreServices",
            "SystemConfiguration"
        ]
    },
    "osx": {
        "frameworks": [
            "CoreServices",
            "SystemConfiguration"
        ]
    },
    "source_files": "DiscogsAPI/*.{h,m}",
    "default_subspecs": [
        "Authentication",
        "Database",
        "User",
        "Marketplace",
        "Resource"
    ],
    "subspecs": [
        {
            "name": "Core",
            "source_files": [
                "DiscogsAPI/Core",
                "DiscogsAPI/Core/Internal",
                "AFOAuth1Client/AFOAuth1Client"
            ],
            "prefix_header_contents": [
                "#import ",
                "#import ",
                "#import ",
                "#import "
            ],
            "private_header_files": [
                "DiscogsAPI/Core/Internal/*.h",
                "AFOAuth1Client/AFOAuth1Client/*.h"
            ],
            "dependencies": {
                "DiscogsAPI/Mapping": [],
                "RestKit/ObjectMapping": [
                    "~> 0.27.2"
                ],
                "RestKit/Network": [
                    "~> 0.27.2"
                ]
            }
        },
        {
            "name": "Authentication",
            "source_files": [
                "DiscogsAPI/Authentication",
                "DiscogsAPI/Authentication/Identity",
                "DiscogsAPI/Mapping/Authentication/**/*"
            ],
            "private_header_files": [
                "DiscogsAPI/Authentication/DGAuthView.h",
                "DiscogsAPI/Authentication/DGTokenStore.h",
                "DiscogsAPI/Authentication/Identity/DGIdentity+Keychain.h",
                "DiscogsAPI/Mapping/Authentication/**/*.h"
            ],
            "dependencies": {
                "DiscogsAPI/Core": []
            }
        },
        {
            "name": "Database",
            "source_files": [
                "DiscogsAPI/Database",
                "DiscogsAPI/Database/Release",
                "DiscogsAPI/Database/Artist",
                "DiscogsAPI/Database/Label",
                "DiscogsAPI/Database/Master",
                "DiscogsAPI/Database/Search",
                "DiscogsAPI/Database/Data",
                "DiscogsAPI/Mapping/Database/**/*"
            ],
            "private_header_files": "DiscogsAPI/Mapping/Database/**/*.h",
            "dependencies": {
                "DiscogsAPI/Pagination": []
            }
        },
        {
            "name": "User",
            "source_files": [
                "DiscogsAPI/User",
                "DiscogsAPI/User/Profile",
                "DiscogsAPI/User/Collection",
                "DiscogsAPI/User/Wantlist",
                "DiscogsAPI/Mapping/User/**/*"
            ],
            "private_header_files": "DiscogsAPI/Mapping/User/**/*.h",
            "dependencies": {
                "DiscogsAPI/Database": []
            }
        },
        {
            "name": "Marketplace",
            "source_files": [
                "DiscogsAPI/Marketplace",
                "DiscogsAPI/Marketplace/Price",
                "DiscogsAPI/Marketplace/Listing",
                "DiscogsAPI/Marketplace/Order",
                "DiscogsAPI/Mapping/Marketplace/**/*"
            ],
            "private_header_files": "DiscogsAPI/Mapping/Marketplace/**/*.h",
            "dependencies": {
                "DiscogsAPI/User": []
            }
        },
        {
            "name": "Pagination",
            "source_files": [
                "DiscogsAPI/Pagination",
                "DiscogsAPI/Mapping/Pagination"
            ],
            "private_header_files": "DiscogsAPI/Mapping/Pagination/**/*.h",
            "dependencies": {
                "DiscogsAPI/Core": []
            }
        },
        {
            "name": "Resource",
            "source_files": "DiscogsAPI/Resource",
            "dependencies": {
                "DiscogsAPI/Core": []
            }
        },
        {
            "name": "Mapping",
            "source_files": "DiscogsAPI/Mapping",
            "private_header_files": "DiscogsAPI/Mapping/*.h"
        }
    ]
}

Pin It on Pinterest

Share This