The v1 DMAPI will be deprecated on 1/1/2016. If you have questions or need assistance migrating to the latest version please contact us

Java

The reference implementation for the SpatialKey Data Import API is built in Java. We provide an example application that you can download, customize and deploy called the SpatialKey Data Poller. The SpatialKey Data Poller uses the Spring framework. The application is designed as an XML configurable scheduling engine that will “read” from an FTP location, download a .csv and .xml (data description) file, and then process those files through the SpatialKey Data Management API.

.NET

There are two .NET reference projects written in C# and Visual Basic. Both projects are command line applications that optionally take an XML configuration file (defaults to SpatialKeyUploadConfig.xml). This configuration file describes the parameters need to authenticate and import a file. Just run the command line application and it will import the data as configured.

Two files are needed in order to use the Data Import API; a CSV file containing the data to upload and an XML file describing that data. The CSV file should be no different than CSV files used in the SpatialKey client upload wizard. The XML file describes the column datatypes in the CSV file and the columns needed for geocoding or the existing lat/lon columns for your location based data. There are several XML examples in our API documentation. Each column in your CSV data has a specific data format that is described in the XML you can find the data types in the documentation.

The VisualBasic code can be downloaded here.

Coldfusion

If you are looking for an easy way to get your data into SpatialKey then you need to look no further than this ColdFusion example. With only a few lines of code you can get push your CSV data into SpatialKey.  The sample for Coldfusion can be downloaded here.

Two files are needed in order to use the Data Import API; a CSV file containing the data to upload and an XML file describing that data. The CSV file should be no different than CSV files used in the SpatialKey client upload wizard.  It should be pretty simple to programatically produce a CSV file in ColdFusion and this article will not cover that process.  The XML file describes the column datatypes in the CSV file and the columns needed for geocoding or the existing lat/lon columns for your location based data. There are several XML examples in our API documentation.  Each column in your CSV data has a specific data format that is described in the XML you can find the data types in the documentation.

Now that you have an XML and CSV file you are ready to import your data into SpatialKey. You will need to first download our example ColdFusion component which is utilized in the examples below.

This example instantiates the SK_DataPublisherAPI component, logs into the SpatialKey server then uploads both the CSV and XML files.  If the dataset does not exist SpatialKey will create it.  If the dataset already exists then the “action” argument for the upload method controls whether the data will get appended to the existing data or if it overwrites (deletes then adds). In the example below we have set the action=’overwrite’, if you want to append just change it to action=’append’.

<cfscript>
 objSKdp=createObject('component','SK_DataPublisherAPI');
 currDir = GetDirectoryFromPath(GetCurrentTemplatePath());
 xmlFile= currDir & 'SalesData.xml';
 csvFile= currDir & 'SalesData.csv';
 
 /* login */
 objSKdp.login(hostname='mysite.spatialkey.com',username='un',password='pw');

 /* example uploading both a CSV and XML */

 objSKdp.upload(csvfile=csvFile,xmlfile=xmlFile,action='overwrite');
</cfscript>

You should zip up your CSV and XML file into a single file to save bandwidth and improve the upload speeds of your imports. With <CFZIP> you can simply combine the files then use the following code to import your data.

<cfscript>
 objSKdp=createObject('component','SK_DataPublisherAPI');
 currDir = GetDirectoryFromPath(GetCurrentTemplatePath());
 zipFile= currDir & 'SalesData.zip';
 

 /* login */
 objSKdp.login(hostname='mysite.spatialkey.com',username='un',password='pw');

 /* example uploading both a CSV and XML */
 objSKdp.upload(zipfile=zipFile,action='overwrite');
</cfscript>

That is all there is to getting your data into SpatialKey with Coldfusion using the SpatialKey Data Import API.