https://github.com/hypothermic/javacogs
Discogs client library for Java/Kotlin
https://github.com/hypothermic/javacogs
api discogs discogs-api java
Last synced: 7 months ago
JSON representation
Discogs client library for Java/Kotlin
- Host: GitHub
- URL: https://github.com/hypothermic/javacogs
- Owner: hypothermic
- License: bsd-3-clause
- Created: 2018-12-02T14:29:15.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-14T17:50:27.000Z (about 3 years ago)
- Last Synced: 2025-02-14T08:38:19.031Z (over 1 year ago)
- Topics: api, discogs, discogs-api, java
- Language: Java
- Homepage:
- Size: 171 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://ci.hypothermic.nl/job/javacogs/job/master/)
[](https://ci.hypothermic.nl/job/javacogs/job/master/lastSuccessfulBuild/artifact/target/)
[](https://github.com/hypothermic/javacogs/blob/master/LICENSE)
# Javacogs
A professional client library for the Discogs API v2.
Compatible with all Java platforms including Android.
# Features
- Asynchronous networking and response
- Easy authentication with one-time setup
- Built-in adaptive rate limiting
- Handler library structure for ease of use
- Support for Java 6 and up (and Kotlin, of course!)
- No external dependencies except for the JSON parser
# Try it out
Retrieve information about a release by ID:
```java
int releaseId = 249504; // ID of Rick Astley - Never Gonna Give You Up
Javacogs.getInstance().getHandler(Handler.DATABASE)
.getReleaseById(releaseId, new ResponseCallback() {
public void onResult(Response response) {
if (response.hasSucceeded()) {
System.out.println(response.getValue().toString());
} else {
System.out.println("Response failed.");
}
}
});
```
More examples are in the [examples](./src/examples/) directory.
Don't worry, they have proper documentation for beginners!
### Maven dependency
```xml
javacogs-mvn-repo
https://raw.github.com/hypothermic/javacogs/mvn-repo/
nl.hypothermic
javacogs
[1.0.18,)
```
### Gradle dependency
```gradle
repositories {
maven {
url "https://raw.github.com/hypothermic/javacogs/mvn-repo/"
}
}
dependencies {
// Note: use 'api' instead of 'compile' if you're using Android Studio.
compile group: 'nl.hypothermic', name: 'javacogs', version: '1.0.17-RC1'
}
```
# Authentication
You can authenticate to Discogs using the Discogs Auth Flow:
Authenticate using a **Token**:
```java
Javacogs client = new Javacogs();
client.setAuthenticationMethod(new TokenAuthenticationMethod("YOUR-TOKEN"));
```
Authenticate using a **Key** and **Secret**:
```java
client.setAuthenticationMethod(new KeySecretAuthenticationMethod("KEY", "SECRET"));
```
To use **OAuth**, you will need to implement the `AuthenticationMethod` interface in your own implementation.
Then, simply call `client.setAuthenticationMethod(new YourOAuthImplementation(...));`
# Handler structure
At first glance, the handler system might seem a little complicated.
You will soon find out that this design choice is extremely easy to use though.
Here's a structure mapping to get you started:
```
new Javacogs() -> DatabaseHandler() -> getEntitiesBySearch()
-> getReleaseById()
-> getReleasesByArtist()
-> getReleasesByLabel()
-> getMasterById()
-> getArtistById()
-> getLabelById()
-> UserCollectionHandler() -> getFolderById()
-> getFoldersByUser()
-> getFolderContents()
-> getCollectionValue()
-> deleteFolderById()
-> addReleaseToFolder()
-> deleteReleaseFromFolder()
-> UserWantlistHandler() -> getWantlistByUsername()
-> addReleaseToWantlist()
-> deleteReleaseFromWantlist()
-> UserIdentityHandler() -> getProfileByUsername()
-> getUserSubmissions()
-> getUserContributions()
-> ApiStatisticsHandler() -> getLabelsCount()
-> getReleasesCount()
-> getArtistsCount()
```