Building the API client library requires:
- Java 1.7+
- Maven/Gradle
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.
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>
Add this dependency to your project's build file:
compile "org.openapitools:openapi-java-client:0.1.7"
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
// 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();
}
}
}
It's recommended to create an instance of ApiClient
per thread in a multithreaded environment to avoid any potential issues.