Avantalytics External API Documentation v3.26

FusionMaps Geolocation - DISCONTINUED (Jump to Section)

Last Change: June 29, 2018



API Overview

Overview Of Our External REST API


  • - 100% Secure HTTP Protocol Communication (SSL)

  • - Compact Response Format (JSON)

  • - High Performance, Concurrent, Fault Tolerant.





Avantalytics provides customers who purchase services access to certain API methods for the purposes of better integrating the data with the customer's in-house and/or third party systems. This documentation describes the available API calls and necessary parameters and return values. Currently all API output is only available via JSON format as described below. See below for details.


Base URL Access


All access to the external API can be reached only through the following address: https://www.avantalytics.com/REST/. For all URLs listed below it is assumed that they are relative to this address. Please note, it is case sensitive.


Customer Specific Security Access Tokens


All API calls below require you to use your unique customer access token in order to receive meaningful responses. This should have been given to you, by us, during the initial API access discussions or during account signup. If you do not have one yet, please contact Avantalytics support (support@avantalytics.com) to discuss the options.


API Standard Responses


All API calls to registered API URLs will always respond with an HTTP response code 200. Because access is managed within the application layer, the response body itself will determine whether the call actually succeeded or not. The only exception to this rule is a 404 HTTP response code, which will be returned if you provide a mal-formed REST request.

Every API call will provide the following fields providing some information detailing whether the result was successful and/or limited based upon permissions.

The output fragment below shows the response portion relating to a succesful API call. Please note: an API call is considered sucessful from a REST status - even if the data it returns signifies an error occured. In this way, we treat the success of the application call separately from the success of the HTTP response. So, the code below is a successful REST API call, even if the error field value below was "true". It is your job to use the results of these standard fields to determine whether your application should continue it's processing.


{
  "curr_time": 1540226339,
  "success": 1,
  "error": 0,
  "msg": "The operation was successful.",
  "permission": 1,
  "finished": 1,
  "start_time": 1540226337,
  "authenticated": 1,
  "msec": 1573,
  "result": [...]
  ...
}



Additional fields may be provided depending on the API target being called.

We recommend checking each of these in your application handling logic before relying on the output that follows. Also note - it is possible for success and error to have different boolean codes. The permission field returns true if your account has been granted access to this API call or the underlying functions supporting it. The authenticated field, by contrast, only tells you whether you have authenticated correctly - a false value here will indicate in incorrect apikey/accountid combination. If this happens, the API will throttle itself to one request every 3 seconds until a correct combination has been submitted. It does this to avert DDoS attacks by potential attackers.


Simple Test GET Request Usage Examples


The examples above are meant to provide you with the minimal request/response for several popular languages. In all cases you should arrive with a json serialized string which you should deserialize into and object or array for consumption.




FusionMaps Geolocation - DISCONTINUED API Calls



This API is designed to extend the functionality of FusionMaps XT library. The FusionMaps XT library as offered by FusionCharts, while wonderful in so many ways, is limited in its lack of dynamic, fine-grained, geolocation capabilities. This API provides a remedy for this limitation and creates extensive capabilities for visualizing all facets of geolocation in your FusionMaps. . These API calls demonstrate how you can integrate custom GPS coordinate point generation as well as zip code point generation, area covering, city covering and more for any of FusionMaps maps in the United States (including the state maps) and a growing list of other FusionMaps from around the world.

For a complete list of FusionMaps which we support Geolocation for click here. . Click on any of the API calls below to learn more.


Click Here to View A Live Demo Example




API CALL GET Zip Code To XML Marker Generation


This API call is made available to enhance our customers and partners ability to maximize the functionality of FusionMaps. As we use Fusionmaps ourselves and were dissapointed with the lack of dynamic point creation based on zip codes or GPS coordinates we decided to make it ourselves. A lot of census data and some crazy math and some coding, we're offering it out to our customers. Of course, for this to be useful, you'd need Fusionmaps - check it out here. We like it because its Flash OR Javascript capable, so its (Apple) flexible and reasonably priced. Currently, this is only available for points within the US. We may expand it globally if we receive need request.

URI Notes Method
REST Access:

zipmappoint/{accountid}/{customer apikey}/{mapname}/{zip}/
All parameters are required.

{accountid} - integer.

{customer apikey} - string, 40 characters.

{mapname} - 2 character state code, or 'USA'(default).

{zip} - string, 5 digits.

GET

Response Output Fields


The response fields listed are in addition to the standard response fields. Currently the most often used map FusionMap format is XML so we're supporting that. The response below will include a field which when JSON decoded will have one or more map markers corresponding to the requested zip. This is directly injectable into your map XML data as is documented by FusionMaps.

We plan to enhance this in the next three months to include passing data marker attributes for the XML injection to prevent the need to do so afterward. This would include point size and color according to FusionMaps documentation. Until this time, if you require a great level of customization of your data points - use the XY API below to get just the coordinates and construct your own custom XML.

Below is an example output for successful request/response using our home zip code 22201 (Arlington, VA). Please notice that the response shows the XML in the field "xml" and because it is a field in a JSON response, the XML has been escaped and therefore cannot be used directly - you will need to unescape it. The URL we used looks like this:

https://www.avantalytics.com/REST/zipmappoint/xxxx/0000000000000000000000000000000000000000/USA/22201/

where xxxx is a valid account id and 0000000000000000000000000000000000000000 is the account's 40 character unique key.

Sample Response JSON Output


      
      {
        "success": true,
        "error": false,
        "html": "The operation was successful.",
        "msg": "The operation was successful.",
        "permission": true,
        "authenticated": true,
      
        
        
      }
      
      
Currently, this REST interface only supports HTTP GET requests and each request/response is limited to a single ZIP code. In practice you would probably have several to perhaps hundreds of points you'd like to place on a FusionMap. While you can make repeated requests and concatenate the XML response to construct a set of markers, this can reduce the speed of display when you make more than a few requests in realtime. In this case instead of fetching each point in realtime, you would want to pre-fetch and cache each request to increase the responsiveness of your application.




API CALL GET Zip Code To X/Y Map Coordinate Translation



This API call is for those who wish to dynamically map points, but want to have more control over the look of their points on a FusionMap. It is nearly identical in invocation to the XML Marker API call except its response provides no XML, but instead simple X/Y coordinates for a given zip code suitable for mapping on your choice of FusionMap.

URI Notes Method
REST Access:

zipmappointxy/{accountid}/{customer apikey}/{mapname}/{zip}/
All parameters are required.

{accountid} - integer.

{customer apikey} - string, 40 characters.

{mapname} - 2 character state code, or 'USA'(default).

{zip} - string, 5 digits.

GET

Response Output Fields


The response fields listed are shown in addition to the standard response fields. Below is an example output for successful request/response using our home zip code 22201 (Arlington, VA) suitable for display on the FusionMaps USA map. The URL we used looks like this:

https://www.avantalytics.com/REST/zipmappointxy/xxxx/0000000000000000000000000000000000000000/USA/22201/

where xxxx is a valid account id and 0000000000000000000000000000000000000000 is the account's 40 character unique key.

Sample Response JSON Output



NOTE: the coordinates are returned as strings.



      
      {
        "success": true,
        "error": false,
        "html": "The operation was successful.",
        "msg": "The operation was successful.",
        "permission": true,
        "authenticated": true,
        "coordinates": {
          "coordinates": [
            {
              "x": "601",
              "y": "186",
              "name": "22201"
            }
          ]
        }
      }
      
      


Please note that the above request response has an JSON object property named coordinates which is itself an object with a property coordinates which is an array of (x,y) coordinates. This is because it allows for the returning of more than one coordinate potentially while preserving the parent object format.

Below is an example output for successful request/response using our home zip code 22201 (Arlington, VA) suitable for display on the FusionMaps Virginia map. The URL we used looks like this:

https://www.avantalytics.com/REST/zipmappointxy/xxxx/0000000000000000000000000000000000000000/VA/22201/

where xxxx is a valid account id and 0000000000000000000000000000000000000000 is the account's 40 character unique key.

Sample Response JSON Output - State Map



Note, we use the 2-character state code, not the FusionMap map name (because most customers databases store states according to their codes).



      
        {
        "success": true,
        "error": false,
        "html": "The operation was successful.",
        "msg": "The operation was successful.",
        "permission": true,
        "authenticated": true,
        "coordinates": {
          "coordinates": [
            {
              "x": "685",
              "y": "121",
              "name": "22201"
            }
          ]
        }
      }
      
      

Sample Error Response JSON Output -- Bad Zip Code


The URL we used looks like this:

https://www.avantalytics.com/REST/zipmappointxy/xxxx/0000000000000000000000000000000000000000/VA/00000/

where xxxx is a valid account id and 0000000000000000000000000000000000000000 is the account's 40 character unique key.


      
       {
        "success": false,
        "error": true,
        "html": "The operation was unsuccessful.",
        "msg": "Bad Zip 0000",
        "permission": true,
        "authenticated": false,
        "coordinates": []
      }
      
      


Sample Erroneous Response JSON Output -- Zip Not in State



Please note this particular case where the zip code supplied is VALID, but in reality it is not located within the state requested. In this case, the operation will report success, however you will not be given any result in the array
The URL we used looks like this - here we requested to map zip code 01243 (Somerville,MA) on the map of Virginia:

https://www.avantalytics.com/REST/zipmappointxy/xxxx/0000000000000000000000000000000000000000/VA/02143/

where xxxx is a valid account id and 0000000000000000000000000000000000000000 is the account's 40 character unique key.


      
      {
        "success": true,
        "error": false,
        "html": "The operation was successful.",
        "msg": "The operation was successful.",
        "permission": true,
        "authenticated": true,
        "coordinates": {
          "coordinates": [
            
          ]
        }
      }
      



API CALL GET Zip Code X/Y Map Coordinate "Pointilation"



This API call is a special feature unique to Avantalytics. We use a method derived from an art-form known as "pointilism" which involves the filling in of an area (a canvas or a FusionMaps map, for example) by creating a number of "points" (in this case x/y coordinate points) such that the given area on the canvas is appears "covered" or "filled in" by the points.

We find this more useful than a simple circle or polygon to cover highly complex polygonal areas on a given map. This usually occurs when using maps of smaller regions (states) where you want a higher level of precision covering an area. Zip codes just so happen to be these types of areas, and hence this function.

You provide a zip code much as with the calls above and you receive the distinct (X/Y) coordinates required to adequately cover the zip code on the map requested!

Note: This is best utilized for small numbers of areas - using this with many points may cause your browser rendering to become sluggish


URI Notes Method
REST Access:

zippointilatexy/{accountid}/{customer apikey}/{mapname}/{zip}/
All parameters are required.

{accountid} - integer.

{customer apikey} - string, 40 characters.

{mapname} - 2 character state code, or 'USA'(default).

{zip} - string, 5 digits.

GET

Response Output Fields


The response fields listed are shown in addition to the standard response fields. Below is an example output for successful request/response using a famous zip code: 90210, suitable for display on the FusionMaps USA map. The URL we used looks like this:

https://www.avantalytics.com/REST/zippointilatexy/xxxx/0000000000000000000000000000000000000000/USA/90210/

where xxxx is a valid account id and 0000000000000000000000000000000000000000 is the account's 40 character unique key.

Sample Response JSON Output



NOTE: the coordinates are returned as strings.



      
      {
        "success": true,
        "error": false,
        "html": "The operation was successful.",
        "msg": "The operation was successful.",
        "permission": true,
        "authenticated": true,
        "coordinates": {
          "coordinates": [
            {
              "x": "93",
              "y": "259",
              "name": ""
            },
            {
              "x": "92",
              "y": "259",
              "name": ""
            },
            {
              "x": "92",
              "y": "258",
              "name": ""
            },
            {
              "x": "93",
              "y": "258",
              "name": ""
            },
            {
              "x": "94",
              "y": "258",
              "name": ""
            }
          ]
        }
      }
      
      


Please note that the above request response has an JSON object property named coordinates which is itself an object with a property coordinates which is an array of (x,y) coordinates. This is because it allows for the returning of more than one coordinate potentially while preserving the parent object format.


API CALL GET City,State X/Y Map Coordinate "Pointilation"



This API call uses a special feature unique to Avantalytics. We use a method derived from an art-form known as "pointilism" which involves the filling in of an area (a canvas or a FusionMaps map, for example) by creating a number of "points" (in this case x/y coordinate points) such that the given area on the canvas is appears "covered" or "filled in" by the points.

We find this useful more useful than a simple circle or polygon to cover highly complex polygonal areas on a given map. This usually occurs when using maps of smaller regions (states) where you want a higher level of precision covering an area. Cities just so happen to be these types of areas, and hence this function.

You provide a city, state much as with the calls above and you receive the distinct (X/Y) coordinates required to adequately cover the city on the map requested!

Note: This is best utilized for small numbers of areas - using this with many points may cause your browser rendering to become sluggish


URI Notes Method
REST Access:

citypointilatexy/{accountid}/{customer apikey}/{mapname}/{state}/{city}/
All parameters are required.

{accountid} - integer.

{customer apikey} - string, 40 characters.

{mapname} - 2 character state code, or 'USA'(default).

{city} - string, name of the city.

{state} - string, 2 character state code.

GET

Response Output Fields


The response fields listed are shown in addition to the standard response fields. Below is an example output for successful request/response using Arlington, TX and is suitable for display on the FusionMaps USA map. The URL we used looks like this:

https://www.avantalytics.com/REST/citypointilatexy/xxxx/0000000000000000000000000000000000000000/USA/TX/Arlington/

where xxxx is a valid account id and 0000000000000000000000000000000000000000 is the account's 40 character unique key.

Sample Response JSON Output



NOTE: the coordinates are returned as strings.



      
       {
          "success": true,
          "error": false,
          "html": "

The operation was successful.<\/p>", "msg": "The operation was successful.", "permission": true, "authenticated": true, "coordinates": { "coordinates": [ { "x": "359", "y": "281", "name": "" }, { "x": "357", "y": "281", "name": "" }, { "x": "358", "y": "281", "name": "" }, { "x": "358", "y": "280", "name": "" }, { "x": "357", "y": "280", "name": "" }, { "x": "359", "y": "280", "name": "" }, { "x": "359", "y": "279", "name": "" }, { "x": "358", "y": "279", "name": "" }, { "x": "358", "y": "278", "name": "" }, { "x": "359", "y": "278", "name": "" } ] } }



Please note that the above request response has an JSON object property named coordinates which is itself an object with a property coordinates which is an array of (x,y) coordinates. This is because it allows for the returning of more than one coordinate potentially while preserving the parent object format.


API CALL GET GPS Coordinate (Lat/Lon) To X/Y Coordinate Translation

This API call provides the capability of mapping GPS coordinates on a map. This is useful when you have raw location-based data which you'd like to map directly without doing any further translation. Please note that while the latitude and longitude values accepted include accuracies of well over 5 decimals, each point must be mapped to an X/Y coordinate that will require rounding and limit the ability to use the extended decimal somewhat.


URI Notes Method
REST Access:

gpsmappointxy/{accountid}/{customer apikey}/{mapname}/{latitude}/{longitude}/
All parameters are required.

{accountid} - integer.

{customer apikey} - string, 40 characters.

{mapname} - 2 character state code, or 'USA'(default).

{latitude} - float.

{longitude} - float.

GET

Response Output Fields


The response fields listed are in addition to the standard response fields. and the response is identical to the zip code API call returning X/Y coordinates.

Below is an example output for successful request/response using our home zip code 22201 (Arlington, VA). The URL we used looks like this:

https://www.avantalytics.com/REST/gpsmappointxy/xxxx/0000000000000000000000000000000000000000/USA/25.79/-80.32/

where xxxx is a valid account id and 0000000000000000000000000000000000000000 is the account's 40 character unique key.

Sample Response JSON Output


      
       {
        "success": true,
        "error": false,
        "html": "The operation was successful.",
        "msg": "The operation was successful.",
        "permission": true,
        "authenticated": true,
        "coordinates": {
          "coordinates": [
            {
              "x": "352",
              "y": "1791"
            }
          ]
        }
      }
      
Currently, this REST interface only supports single zip/gps/point GET requests and therefore all each GET style request/response is limited to a single ZIP / GPS Coordinate. In practice you would probably have several to perhaps hundreds of points you'd like to place on a FusionMap. While you can make repeated requests to construct a set of markers, this can reduce the speed of display when you make more than a few requests in realtime due to multiple network roundtrips. In this case instead of fetching each point in realtime via GET, you would want to pre-fetch and cache each request to increase the responsiveness of your application.

For those customers looking to get maximum performance from their application, you may wish to utilize our POST request interface as it will allow you to bulk submit many zips/coordinates in a single request. While it requires a bit more involvement in the request itself, you can save a lot of response time lag by compressing any network latency into one request. Below we'll show you the POST request interface.



API CALL POST Multiple Zip Code To X/Y Map Coordinate Translation



This API call is for those who wish to dynamically map points, want to have more control over the look of their points on a FusionMap and wish to map many points at once in the most efficent manner. Doing so requires the use of POST requests. The response format for all responses is identical to the GET requests described above, except you will see the coordinates field will now contain multiple pieces of data corresponding to your post request parameters.

While the response format is identical, please note that the request URL is shorter


This is reflective of the fact that you will pass your accountid and customer key, map name and zip request data in the post request itself as a JSON string.

URI Notes Method
REST Access:

zipmappointxy/
The POST version accepts one parameter data, listed below. The format of the parameter must be valid JSON as shown below.

{data} - string (JSON Format).


              data = {
                "map":"USA",
                "zips":[22201,90210,10001,...],
                "accountid":"000",
                "custkey":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
              }
            

As indicated above - all of the required parameters necessary in a GET request should be moved into the JSON string. The difference now being that you can pass in an array of zip codes in the zips property of the JSON string and you will receive each's coordinates back in the response.
POST

Response Output Fields


The response fields listed are shown in addition to the standard response fields. Below is an example output for a successful POST request/response using the three zip codes: our home zip code 22201 (Arlington, VA), 90210 - Beverly Hills, CA, and 10001 - New York, NY.

Sample Response JSON Output



NOTE: the coordinates are returned as strings.



      
      { 
        "success": true, 
        "error": false, 
        "html": "The operation was successful.", 
        "msg": "The operation was successful.", 
        "permission": true, 
        "authenticated": true, 
        "coordinates": { 
          "coordinates": [ 
              { "x": "601", "y": "186", "name": "22201" }, 
              { "x": "93", "y": "259", "name": "90210" }, 
              { "x": "643", "y": "158", "name": "10001" }
          ] 
        } 
      }
      


Please note that the above request response has an JSON object property named coordinates which is itself and object with a property coordinates which is an array of objects containing the (x,y) coordinates. This is because it allows for the returning of more than one coordinate potentially while preserving the parent object format.

Also note - unlike the single zip code submission - when submitting multiple zip codes, the API does not provide a single error or success code for each zip code, but only returns those lookups that were successful. If the user requests any invalid zip codes they are simply dropped at the API and no information is returned. If at least one zip code was correct and could be returned, the call is deemed to have succeeded.

API Call Count Note: this call consumes one call per zip in the POST submitted

Example Request Code Fragments


Below are code fragments to explain how to make a POST request in a variety of popular server programming languages in order to integrate the use of this API into your code.




API CALL POST Multiple GPS To X/Y Map Coordinate Translation



This API call is for those who wish to dynamically map points, want to have more control over the look of their points on a FusionMap and wish to map many points at once in the most efficent manner. Doing so requires the use of POST requests. The response format for all responses is identical to the GET requests described above, except you will see the coordinates field will now contain multiple pieces of data corresponding to your post request parameters.

While the response format is identical, please note that the request URL is shorter


This is reflective of the fact that you will pass your accountid and customer key, map name and GPS request data in the post request itself as a JSON string.

URI Notes Method
REST Access:

gpsmappointxy/
The POST version accepts one parameter data, listed below. The format of the parameter must be valid JSON as shown below.

{data} - string (JSON Format).


              data = {
                "map":"USA",
                "coordinates":[{"lat" : "38.880344", "lon" : "-77.108260"}, {"lat" : "34.07376", "lon" : "-118.400592"},...],
                "accountid":"000",
                "custkey":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
              }
            

As indicated above - all of the required parameters necessary in a GET request should be moved into the JSON string. The difference now being that you can pass in an array of GPS codes in the coordinates property of the JSON string and you will receive each's X/Y coordinate back in the response.
POST

Response Output Fields


The response fields listed are shown in addition to the standard response fields. Below is an example output for a successful POST request/response using the three GPS coordinates: our home zip code 22201 (Arlington, VA), 90210 - Beverly Hills, CA, and 10001 - New York, NY.

Sample Response JSON Output



NOTE: the coordinates are returned as strings.



      
      {
          "success": true,
          "error": false,
          "html": "The operation was successful.",
          "msg": "The operation was successful.",
          "permission": true,
          "authenticated": true,
          "coordinates": {
            "coordinates": [
              {
                "x": "93",
                "y": "259",
                "name": ""
              },
              {
                "x": "92",
                "y": "259",
                "name": ""
              },
              {
                "x": "92",
                "y": "258",
                "name": ""
              },
              {
                "x": "93",
                "y": "258",
                "name": ""
              },
              {
                "x": "94",
                "y": "258",
                "name": ""
              }
            ]
          }
        }
      


Please note that the above request response has an JSON object property named coordinates which is itself and object with a property coordinates which is an array of objects containing the (x,y) coordinates. This is because it allows for the returning of more than one coordinate potentially while preserving the parent object format.

API Call Count Note: this call consumes one call per coordinate pair in the POST submitted



Should you have any trouble or questions regarding this or any other API call, please contact Avantalytics Support.


* Avantalytics targets 100msec average response time over each 24hr period. Response time is determined by the computational response time and does not include network transfer time between the service and the requester which may vary according to the requester's network connection and geographic distance from the API resources.

EOF