MapLarge SDK Overview

MapLarge API Connector

The MapLarge API Connector (MapLargeConnector) is a convenience class that facilitates access of the MapLarge API. The class MapLargeConnector has been implemented in 4 languages: Python, Java, C#, and PHP. The main class MapLargeConnector is used to establish and manage a session with a MapLarge API server. This class exposes several methods for accessing functionality on the MapLarge server.

Visit to Get Connected

Methods

Constructor

The Constructor follows this basic pattern, with slight differences depending on language. It is overloaded to allow for passing of username/password or username/authtoken for authentication.

/** * Constructor. Creates a connection to a MapLarge API server with a * username and token as credentials. * * @param urlApiServer * URL of API server. Must begin with valid protocol * (http/https). * @param username * Username to use for connection credentials. * @param token * Authentication token to use for connection credentials. */ MapLargeConnector(string urlApiServer, string username, int token) /** * Constructor. Creates a connection to a MapLarge API server with a * username and token as credentials. * * @param urlApiServer * URL of API server. Must begin with valid protocol * (http/https). * @param username * Username to use for connection credentials. * @param password * Authentication token to use for connection credentials. */ MapLargeConnector(string urlApiServer, string username, string password)

InvokeAPIRequest

Used to Invoke API requests over HTTP that can be handled sufficiently by GET requests. This would be for relatively short data, such as Account or Table Listings. Files can be uploaded, but only in the limited case of passing files by URL. Uploading of file data directly must use the POST method below.

 /** * * @param actionname * Name of API action being called. * @param paramlist * Array of key value pairs. * @return API response, usually a JSON formatted string. Returns "ERROR" on * exception. */ string InvokeAPIRequest(string actionname, Dictionary<string, string=""> paramlist) </string,>

InvokeAPIRequestPost

Performs the same API Requests as the first method, but can handle sending and receiveing of large amounts of data as HTTP POST is used. This also allows for full featured Binary file uploads directly from your client application.

 /** * * @param actionname * Name of API action being called. * @param kvp * Array of key value pairs. * @param filepaths * Array of files to attach to request. Use full file path. * @return API response, usually a JSON formatted string. Returns "ERROR" on * exception. */ string InvokeAPIRequestPost(string actionname, Dictionary<string, string=""> paramlist) /** * * @param actionname * Name of API action being called. * @param kvp * Array of key value pairs. * @param filepaths * Array of files to attach to request. Use full file path. * @return API response, usually a JSON formatted string. Returns "ERROR" on * exception. */ string InvokeAPIRequestPost(string actionname, Dictionary<string, string=""> paramlist, string[] filepaths) </string,></string,>

NO_WEB_CALLS

A property that when set to true causes the API to "simulate" functionality. HTTP calls will not actually occur and debug info about the call is returned from methods. Useful for debugging.

MapLargeConnector.NO_WEB_CALLS = true; string response = mlconnPassword.InvokeAPIRequest("CreateTableSynchronous", paramlist); //Outputs Debug info Console.WriteLine(response);

GetRemoteAuthToken

A convenience method to allow retrieval of the Auth Token -- a common use case among many users.

 /** * * @param user Username to create authentication token for * @param password Password for supplied username * @param ipAddress IP address of the user for whom you want to build an authentication token * @return The authentication token in string form. */ string GetRemoteAuthToken(string user, string password, string ipAddress)

General Usage

General usage involves instantiation of the MapLargeConnector and subsequent calls to the server via the InvokeAPI methods.

 //Authentication inforamtion string server = "<a href="http://server.maplarge.com/";">http://server.maplarge.com/";</a> string user = "<a href="mailto:user@ml.com">user@ml.com</a>"; string pass = "pw123456"; //HTTP Parameters Dictionary<string, string=""> paramlist = new Dictionary<string, string="">(); //CREATE MAPLARGE CONNECTION WITH USER / PASSWORD MapLargeConnector mlconnPassword = new MapLargeConnector(server, user, pass); //CREATE TABLE SYNCHRONOUSLY //Set parameters: account, tablename &amp; file URL paramlist.Add("account", "test"); paramlist.Add("tablename", "testJavaSdkTable"); paramlist.Add("fileurl", "<a href="http://www.domain.com/testfile.csv"">http://www.domain.com/testfile.csv"</a>); string response = mlconnPassword.InvokeAPIRequest("CreateTableSynchronous", paramlist); </string,></string,>

Language Specific Usage

C# Mapping Software API Example

  1. //DEFAULT CREDENTIALS
  2. string server = "<a href="http://server.maplarge.com/";
  3. string">http://server.maplarge.com/";
  4. string</a> user = "<a href="mailto:user@ml.com">user@ml.com</a>";
  5. string pass = "pw123456";
  6. int token = 123456789;
  7.  
  8. Dictionary<string, string> paramlist = new Dictionary<string, string>();
  9.  
  10. //CREATE MAPLARGE CONNECTION WITH USER / PASSWORD
  11. MapLargeConnector mlconnPassword = new MapLargeConnector(server, user, pass);
  12.  
  13. //CREATE MAPLARGE CONNECTION WITH USER / AUTH TOKEN
  14. MapLargeConnector mlconnToken = new MapLargeConnector(server, user, token);
  15.  
  16. //CREATE TABLE SYNCHRONOUS (NO WEB CALL)
  17. paramlist.Add("account", "test");
  18. paramlist.Add("tablename", "testJavaSdkTable");
  19. paramlist.Add("fileurl", "<a href="http://www.domain.com/testfile.csv"">http://www.domain.com/testfile.csv"</a>);
  20. MapLargeConnector.NO_WEB_CALLS = true;
  21. string response = mlconnPassword.InvokeAPIRequest("CreateTableSynchronous", paramlist);
  22. Console.WriteLine(response);
  23. MapLargeConnector.NO_WEB_CALLS = false;
  24.  
  25. //RETRIEVE REMOTE USER AUTH TOKEN
  26. response = mlconnPassword.GetRemoteAuthToken(user, pass, "255.255.255.255");
  27. Console.WriteLine(response);
  28.  
  29. //LIST GROUPS
  30. paramlist.Clear();
  31. paramlist.Add("account", "test");
  32. response = mlconnToken.InvokeAPIRequestPost("ListGroups", paramlist);
  33. Console.WriteLine(response);
  34.  
  35. //CREATE TABLE WITH FILES SYNCHRONOUS
  36. paramlist.Clear();
  37. paramlist.Add("account", "test");
  38. paramlist.Add("tablename", "PostedTableImport");
  39. response = mlconnToken.InvokeAPIRequestPost("CreateTableWithFilesSynchronous", paramlist,
  40. new string[] { "C:\\Data\\TestFile.csv" });
  41. Console.WriteLine(response);

PHP for MapLarge SDK

//DEFAULT CREDENTIALS $server = "http://server.maplarge.com/"; $user = "user@ml.com"; $pass = "pw123456"; $token = 921129417; //CREATE MAPLARGE CONNECTION WITH USER / PASSWORD $mlconnPassword = MapLargeConnector::CreateFromPassword($server, $user, $pass); //CREATE MAPLARGE CONNECTION WITH USER / AUTH TOKEN $mlconnToken = MapLargeConnector::CreateFromToken($server, $user, $token); //CREATE TABLE SYNCHRONOUS (NO WEB CALL) $paramlist = array( 'account' => 'aidsvualpha', 'tablename' => 'testPHPSDKTable', 'fileurl' => 'http://www.domain.com/testfile.csv' ); MapLargeConnector::$NO_WEB_CALLS = true; $response = $mlconnPassword->InvokeAPIRequest("CreateTableSynchronous", $paramlist); echo $response . PHP_EOL; MapLargeConnector::$NO_WEB_CALLS = false; //RETRIEVE REMOTE USER AUTH TOKEN $response = $mlconnPassword->GetRemoteAuthToken($user, $pass, "255.255.255.255"); echo $response . PHP_EOL; //LIST GROUPS $paramlist = array( 'account' => 'test', ); $response = $mlconnToken->InvokeAPIRequestPost("ListGroups", $paramlist); echo $response . PHP_EOL; //CREATE TABLE WITH FILES SYNCHRONOUS $paramlist = array( 'account' => 'test', 'tablename' => 'PostedTableImportPHP', ); $response = $mlconnToken->InvokeAPIRequestPostWithFiles("CreateTableWithFilesSynchronous", $paramlist, array("N:\\MergedPhoenix.csv")); echo $response . PHP_EOL; echo 'DONE' . PHP_EOL;

Java for MapLarge SDK

  1. //DEFAULT CREDENTIALS
  2. String server = "<a href="http://server.maplarge.com/";
  3. String">http://server.maplarge.com/";
  4. String</a> user = "<a href="mailto:user@ml.com">user@ml.com</a>";
  5. String pass = "pw123456";
  6. int token = 123456789;
  7.  
  8. Map<String, String> params = new HashMap<String, String>();
  9.  
  10. //CREATE MAPLARGE CONNECTION WITH USER / PASSWORD
  11. MapLargeConnector mlconnPassword = new MapLargeConnector(server, user, pass);
  12.  
  13. //CREATE MAPLARGE CONNECTION WITH USER / AUTH TOKEN
  14. MapLargeConnector mlconnToken = new MapLargeConnector(server, user, token);
  15.  
  16. //CREATE TABLE SYNCHRONOUS (NO WEB CALL)
  17. params.put("account", "test");
  18. params.put("tablename", "testJavaSdkTable");
  19. params.put("fileurl", "<a href="http://localhost/testfile.csv"">http://localhost/testfile.csv"</a>);
  20. MapLargeConnector.NO_WEB_CALLS = true;
  21. String response = mlconnPassword.InvokeAPIRequest("CreateTableSynchronous", params);
  22. System.out.println(response);
  23. MapLargeConnector.NO_WEB_CALLS = false;
  24.  
  25. //RETRIEVE REMOTE USER AUTH TOKEN
  26. response = mlconnPassword.GetRemoteAuthToken(user, pass, "255.255.255.255");
  27. System.out.println(response);
  28.  
  29. //LIST GROUPS
  30. params.clear();
  31. params.put("account", "test");
  32. response = mlconnToken.InvokeAPIRequestPost("ListGroups", params);
  33. System.out.println(response);
  34.  
  35. //CREATE TABLE WITH FILES SYNCHRONOUS
  36. params.clear();
  37. params.put("account", "test");
  38. params.put("tablename", "PostedTableImport");
  39. response = mlconnToken.InvokeAPIRequestPost("CreateTableWithFilesSynchronous", params, new String[] { "C:\\temp\\usa.csv" });
  40. System.out.println(response);

Java for MapLarge SDK

  1. server = "<a href="http://server.maplarge.com/"
  2. user">http://server.maplarge.com/"
  3. user</a> = "<a href="mailto:user@ml.com">user@ml.com</a>"
  4. pw = "pw123456"
  5.  
  6. #CREATE MAPLARGE CONNECTION WITH USER / PASSWORD
  7. mlconnPassword = MapLargeConnector(server, user, pw)
  8.  
  9. #CREATE MAPLARGE CONNECTION WITH USER / AUTH TOKEN
  10. mlconnToken = MapLargeConnector(server, user, token)
  11.  
  12. #CREATE TABLE SYNCHRONOUS (NO WEB CALL)
  13. params = {"account": "aidsvualpha", "tablename": "testPythonSdkTable", "fileurl": "<a href="http://localhost/testfile.csv"">http://localhost/testfile.csv"</a>}
  14. mlconnToken.NO_WEB_CALLS = True
  15. response = mlconnToken.InvokeAPIRequest("CreateTableSynchronous", params)
  16. print response
  17.  
  18. mlconnPassword.NO_WEB_CALLS = False
  19.  
  20. #RETRIEVE REMOTE USER AUTH TOKEN
  21. response = mlconnPassword.GetRemoteAuthToken(user, pw, "255.255.255.255")
  22. print response
  23.  
  24. #List Groups
  25. params = {"account": "aidsvualpha"}
  26. response = mlconnPassword.InvokeAPIRequestPost("ListGroups", params)
  27. print response
  28.  
  29. #CREATE TABLE WITH FILES SYNCHRONOUS
  30. params = {"account": "aidsvualpha", "tablename": "testTable"}
  31. fileList = ["c:\\temp\\usa.csv"]
  32. print mlconnPassword.InvokeAPIRequestPost("CreateTableWithFilesSynchronous", params, fileList)

Platform for Building Geospatial and IoT Applications