Java client library for the Cardmarket (formerly MagicCardMarket / MKM) API v2.0. It wraps authentication, XML parsing, and the most common marketplace workflows so Java applications can search products, manage stock, handle want lists, inspect orders, and work with shopping carts through a small service-oriented API.
Note This project is an unofficial Java implementation for the Cardmarket API. You need valid Cardmarket API credentials before you can call authenticated endpoints.
- OAuth 1.0 request signing for Cardmarket API calls
- Product and metaproduct search helpers
- Article lookup by seller or product
- Shopping cart management
- Stock import, export, add, update, and delete operations
- Want list create, rename, delete, item add/update/delete, and item loading
- Order listing, order lookup, and tracking number updates
- User lookup, vacation mode, messaging, and authenticated account lookup
- Game, expansion, and category lookup
- XML response mapping to Java model classes
- Java 21 or newer
- Maven 3.x for building from source
- Cardmarket API application token/secret and access token/secret
<dependency>
<groupId>com.github.nicho92</groupId>
<artifactId>mkm-api-java</artifactId>
<version>0.26</version>
</dependency>implementation 'com.github.nicho92:mkm-api-java:0.26'Initialize the singleton API configuration once at application startup, then use service classes for each API domain.
import java.util.List;
import org.api.mkm.modele.Game;
import org.api.mkm.modele.User;
import org.api.mkm.services.GameService;
import org.api.mkm.tools.MkmAPIConfig;
public class Example {
public static void main(String[] args) throws Exception {
MkmAPIConfig.getInstance().init(
System.getenv("MKM_ACCESS_TOKEN_SECRET"),
System.getenv("MKM_ACCESS_TOKEN"),
System.getenv("MKM_APP_SECRET"),
System.getenv("MKM_APP_TOKEN")
);
User me = MkmAPIConfig.getInstance()
.getAuthenticator()
.getAuthenticatedUser();
List<Game> games = new GameService().listGames();
System.out.println("Authenticated as: " + me.getUsername());
System.out.println("Available games: " + games.size());
}
}You can initialize credentials directly:
MkmAPIConfig.getInstance().init(
accessTokenSecret,
accessToken,
appSecret,
appToken
);Or load them from a Java Properties object or file containing these keys:
APP_ACCESS_TOKEN_SECRET=your-access-token-secret
APP_ACCESS_TOKEN=your-access-token
APP_SECRET=your-application-secret
APP_TOKEN=your-application-tokenMkmAPIConfig.getInstance().init(new File("cardmarket.properties"));Keep credentials out of source control. Prefer environment variables, secret managers, or ignored local property files.
| Service | Purpose |
|---|---|
AuthenticationServices |
Authenticate requests and fetch the authenticated account. |
ArticleService |
Find seller articles or articles for a product. |
CartServices |
Add, remove, empty, and read shopping cart contents. |
GameService |
List games, expansions, and product categories. |
OrderService |
List orders, load an order by ID, and update tracking numbers. |
ProductServices |
Search products/metaproducts, fetch product data, and export product/price-guide files. |
StockService |
Read, export, add, update, remove, and inspect stock articles. |
UserService |
Search users, set vacation mode, send messages, and read message threads. |
WantsService |
Manage want lists and want-list items. |
DevelopperServices |
Execute lower-level custom API requests. |
ProductServices products = new ProductServices();
List<Product> results = products.findProduct("Lightning Bolt", null);WantsService wants = new WantsService();
List<Wantslist> lists = wants.getWantList();
for (Wantslist list : lists) {
wants.loadItems(list);
System.out.println(list.getName() + ": " + list.getItem().size() + " items");
}CartServices cart = new CartServices();
cart.addArticle(article);
Basket basket = cart.getBasket();MkmAPIConfig tracks the latest X-Request-Limit-Max and
X-Request-Limit-Count response headers observed by the library:
int used = MkmAPIConfig.getInstance().getCountCall();
int max = MkmAPIConfig.getInstance().getMaxCall();Clone the repository and build with Maven:
git clone https://github.com/nicho92/mkm-api-java.git
cd mkm-api-java
mvn clean testCreate the package locally:
mvn clean packagesrc/main/java/org/api/mkm/services Service classes for Cardmarket endpoints
src/main/java/org/api/mkm/modele API model classes
src/main/java/org/api/mkm/tools Configuration, constants, XML, and utility helpers
src/main/java/org/api/mkm/exceptions Custom exception types
src/main/java/org/mkm/gui Optional Swing GUI helpers
src/test/java Tests
Most service methods throw IOException for network and parsing failures.
Authentication setup can throw MkmException when required credential fields are
missing. Non-successful HTTP responses are surfaced through MkmNetworkException
where implemented.
Contributions are welcome. A typical workflow is:
- Fork the repository.
- Create a feature branch.
- Make your changes with tests when possible.
- Run
mvn clean test. - Open a pull request describing the change and any compatibility impact.
This project is distributed under the Apache License, Version 2.0, as declared in
pom.xml.