Yandex.Money SDK for Java
Latest commit e5c914a Aug 16, 2018

Yandex.Money SDK for Java


This Java library contains classes that allows you to do payments and call other methods of Yandex.Money public API.


The library uses:


Gradle Dependency (jCenter)


To use the library in your project write this code to your build.gradle:

buildscript {
    repositories {

dependencies {
    compile ''

App Registration

To be able to use the library you: the first thing you need to do is to register your application and get your unique client id. To do that please follow the steps described on this page (also available in Russian).


All API methods are represented as classes in package

Some methods require an unique id to get the response. To get it use API method instance-id passing your client id. Once obtained instance id can be used to perform those methods.

Do NOT request instance id every time you need to call an API method. Obtain it once, store it safely and reuse it in future requests.

Performing Request

To perform request from package you will need to use ApiClient. For your convenience there is default implementation of the ApiClient called DefaultApiClient. It is suitable for most cases. So the very first thing you need to do, is to create ApiClient.

The minimal implementation will look like this:

ApiClient client = new DefaultApiClient.Builder()

If you want to perform a method that requires user's authentication you need request access token. The easiest way to do this is to get AuthorizationData from a client:

AuthorizationParameters parameters = new AuthorizationParameters.Builder()
AuthorizationData data = client.createAuthorizationData(parameters);

Provided AuthorizationParameters allows you to set request parameters as described here. When created AuthorizationData will have URL and POST parameters for OAuth2 authorization.

To get the result from redirect uri you may want to use AuthorizationCodeResponse.parse(redirectUri) method. If successful the instance of AuthorizationCodeResponse will contain temporary authorization code that must be immediately exchanged for an access token:

// parse redirect uri from web browser
AuthorizationCodeResponse response = AuthorizationCodeResponse.parse(redirectUri);

if (response.error == null) {
    // try to get OAuth2 access token
    Token token = client.execute(new Token.Request(response.code, client.getClientId(), myRedirectUri, myClientSecret));
    if (token.error == null) {
        ... // store token.accessToken safely for future uses

        // and authorize client to perform methods that require user's authentication
    } else {
} else {

Now you can perform any request with authorized client. For instance, if you want to get InstanceId you can do it like this:

InstanceId instanceId = client.execute(new InstanceId.Request(clientId));
// do something with instance id


  1. Yandex.Money API (in English, in Russian)
  2. Yandex.Money Java SDK on Bintray