Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

EchoMTG Java API Wrapper

An api wrapper written in Java for the magic the gathering application EchoMTG. More at

See PHP wrapper: by @andrewgioia

This is an open-source library, and contributions are welcome.


Google Volley

dependencies {
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'

Add the INTERNET Permission

To use Volley, you must add the android.permission.INTERNET permission to your app's manifest. Without this, your app won't be able to connect to the network.

Gradle Install

Currently not working until version 1.0 is release Please copy code into your project for now.

repositories {
    maven {
        url  "" 

Example Usage

From an inside a Activity or Fragment, you need to instantiate the singleton and feed it a call back along with parameters. In this example, shared prerences is instantiated to store the token recieved from Auth. That token will be used for every other request that will be made, and also for business logic like, if no token, show a login, else show inventory.

Imports for File

import com.thoughtbombstudios.echomtg.EchoMTGWrapper.EchoMTGJavaAPIWrapper;
import org.json.JSONException;
import org.json.JSONObject;

Example of using the EchoMTGAPI Wrapper Singleton with a call back in an activity or fragment class

// auth example, would be inside an activity or fragment class method
SharedPreferences sharedPref; // use to store token locally
sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); 
String email = ""; // passed through UI input
String pass = "asdfsbfsbsadfsa"; // passed through UI input 
EchoMTGJavaAPIWrapper.getInstance(getActivity().getApplicationContext()).authRequest(new EchoMTGJavaAPIWrapper.EchoCallback(){
      public void onSuccess(JSONObject result){
          JSONObject jsonObject = result;
          String token = null;
          try {
              token = jsonObject.getString("token");
          } catch (JSONException e) {
          // example code to store token to shared preferences
          SharedPreferences.Editor editor = sharedPref.edit();
          editor.putString(getString(R.string.token_reference), token);
      public void onFailure(Error result) {
        //your error code

Link to Gist

Example of adding to inventory

public void addToInventory(final int multiverse_id, final boolean foil) {
    Log.e(TAG,"add to inventory");
    final String[] message = new String[1];
    String auth = getToken(); // this is a method to get a locally stored token, it accesses shared preferences

    EchoMTGJavaAPIWrapper.getInstance(getApplicationContext()).addToInventory(new EchoMTGJavaAPIWrapper.EchoCallback(){
        public void onSuccess(JSONObject jsonObject){

            try {

                message[0] = jsonObject.getString("message");
                Snackbar.make(getCurrentFocus(), message[0], Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();

               // if you run local SQL run your logic here

            } catch (JSONException e) {


        public void onFailure(String error) {


    }, auth, multiverse_id, foil );


Exmaple getToken() method

public String getToken(){
    token = sharedPref.getString( getString(R.string.token_reference), "" );
    return token;


An api wrapper written in Java for the magic the gathering application EchoMTG. More at



No packages published


You can’t perform that action at this time.