/java-sdk

MercadoLibre's Java SDK

Primary LanguageJava

Mercado Libre Developers

MercadoLibre's JAVA SDK

This is the official JAVA SDK for MercadoLibre's Platform.

Requirements

Building the API client library requires:

  1. Java 1.7+
  2. Maven/Gradle

Installation

To install the API client library to your local Maven repository, simply execute:

mvn clean install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn clean deploy

Refer to the OSSRH Guide for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>org.openapitools</groupId>
  <artifactId>openapi-java-client</artifactId>
  <version>0.1.7</version>
  <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "org.openapitools:openapi-java-client:0.1.7"

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/openapi-java-client-0.1.7.jar
  • target/lib/*.jar

Usage

// Import classes:
import meli.ApiClient;
import meli.ApiException;
import meli.Configuration;
import meli.models.*;
import meli_marketplace_lib.CategoriesApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("https://api.mercadolibre.com");

    CategoriesApi apiInstance = new CategoriesApi(defaultClient);
    String categoryId = "categoryId_example"; // String | 
    try {
      apiInstance.categoriesCategoryIdGet(categoryId);
    } catch (ApiException e) {
      System.err.println("Exception when calling CategoriesApi#categoriesCategoryIdGet");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Documentation & Important notes

The URIs are relative to https://api.mercadolibre.com
The Authorization URLs (set the correct country domain): https://auth.mercadolibre.{country_domain}
All docs for the library are located here
Check out our examples codes in the folder examples
Don’t forget to check out our developer site