/java-sdk

MercadoLibre's Java SDK

Primary LanguageJavaApache License 2.0Apache-2.0

Java Client SDK

Requirements

Building the API client library requires Maven to be installed.

Installation

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

mvn install

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

mvn deploy

Others

At first generate the JAR by executing:

mvn package

Then manually install the following JARs:

  • target/java-client-sdk-master.jar
  • target/lib/*.jar

Getting Started

Please follow the installation instruction and execute the following Java code:

import io.swagger.client.ApiException;
import io.swagger.client.api.DefaultApi;
import io.swagger.client.model.*;


public class DefaultApiExample {

/*Replace with your application Client Id, Client Secret and RedirectUri*/

    Long ClientId = 0;  
    String SecretKey = "abc123";
    String redirectUri = "https://your_url.com";
    
    private final DefaultApi api = new DefaultApi();
    
    private static void getAuthUrl() throws UnsupportedEncodingException {
           DefaultApi api = new DefaultApi(new ApiClient(), clientId, clientSecret);
           String response = api.getAuthUrl(redirectUri, Configuration.AuthUrls.{your_site_id});
    }
    
    private static void getAccessToken() throws UnsupportedEncodingException {
               DefaultApi api = new DefaultApi(new ApiClient(), clientId, clientSecret);
               String code = "{your_code}";
               AccessToken response = api.authorize(code, redirectUri);
    }
     
    private static void refreshToken() throws UnsupportedEncodingException {
                    DefaultApi api = new DefaultApi(new ApiClient(), clientId, clientSecret);
                    String refreshToken = "{your_refresh_token}";
                    RefreshToken response = api.refreshAccessToken(refreshToken);
    }
    
    private static void GET() throws ApiException {
            String resource = "{api_resource}";
            Object response = api.defaultGet(resource);
    }
    
    public void POST() throws ApiException {
            String resource = "{api_resource}";
            Object body = new Object();
            body.field("{some_value}");
            Object response = api.defaultPost(accessToken, resource, body);
    }
        
    public void PUT() throws ApiException {
                String id = "{object_id}";
                String resource = "{api_resource}";
                Object body = new Object();
                body.field("{some_value}");
                Object response = api.defaultPut(resource, id, accessToken, body);
    }
    
    public void DELETE() throws ApiException {
                 String id = "{object_id}";
                 String resource = "{api_resource}";
                 Object response = api.defaultDelete(resource, id, accessToken);
    }

}

Documentation for API Endpoints

All URIs are relative to https://api.mercadolibre.com

Class Method HTTP request Description
DefaultApi defaultGet GET /{resource}/{id} Returns details about an object.
DefaultApi defaultPut PUT /{resource}/{id}/attributes Updates an object.
DefaultApi defaultPost POST /{resource}/ Creates an object.
DefaultApi defaultDelete DELETE /{resource}/{id} Deletes an object.
DefaultApi categoriesCategoryIdAttributesGet GET /categories/{category_id}/attributes Returns all attributes from a category.
DefaultApi categoriesCategoryIdGet GET /categories/{category_id} Returns information about a category.
DefaultApi itemsItemIdGet GET /items/{item_id} Return item infromation.
DefaultApi itemsItemIdPut PUT /items/{item_id} Update an item.
DefaultApi itemsPost POST /items List an item.
DefaultApi itemsValidatePost POST /items/validate Validate the JSON before listing an item.
DefaultApi messagesMessageIdGet GET /messages/{message_id} Get a message by ID.
DefaultApi messagesOrdersOrderIdGet GET /messages/orders/{order_id} Return all messages from a order.
DefaultApi messagesPost POST /messages Send a message.
DefaultApi ordersOrderIdGet GET /orders/{order_id} Get an order by ID.
DefaultApi ordersSearchGet GET /orders/search Search orders by seller or buyer.
DefaultApi shipmentsShipmentIdGet GET /shipments/{shipment_id} Retrieves all data to make a delivery.
DefaultApi sitesGet GET /sites Return all sites where MercadoLibre operates.
DefaultApi sitesSiteIdCategoryPredictorPredictGet GET /sites/{site_id}/category_predictor/predict Predict category by title.
DefaultApi sitesSiteIdGet GET /sites/{site_id} Return information about a site.
DefaultApi usersMeGet GET /users/me Return account information about the authenticated user.
DefaultApi usersUserIdGet GET /users/{user_id} Return user account information.

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

oAuth2

Recommendation

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

Author

Florencia Solari (fsolari)

Most code was auto generated by swagger code generator

Old version

If you are looking for the older java-sdk, please refer to here