Hide

Accessing Public Data

Overview

An ever-growing number of public datasets is available in Google Maps Engine for use by developers in their maps or data visualization applications. You can retrieve this data with a simple HTTP request. No authorization is required, and authentication is accomplished through the use of an API key obtained from the Google APIs Console.

The following request points to a publicly-accessible datasource in Google Maps Engine:

  https://www.googleapis.com/mapsengine/v1/tables/12421761926155747447-06672618218968397709/features
  ?maxResults=500
  &version=published
  &key={API_KEY}

You can send the above sample request from your browser, with a pre-filled API key that works only from this documentation site. Try it now.

The response is a JSON object containing the set of features from the specified table.

Making your data public

There are two ways to make your data publicly accessible:

Preparing to access public data

Before you can make any requests to the Google Maps Engine API from your own application, you need to sign up, activate the API in the Google APIs Console, and create an API key. Follow the instructions in the getting-started guide, then return to this page. You can skip the section on getting an OAuth 2.0 client ID, because you don't need it to access public data.

Now you can use your own API key to send the above request to the Google Maps Engine API. Copy the request URL without an API key and replace {API_KEY} with your API key. (That is the key for browser apps available for your project in the Google APIs Console. See the section on API keys in the getting-started guide.) Then paste the URL into your browser's address bar.

The response is a JSON object containing the set of features from the specified table.

Getting to know the API

Let's examine the components of the API request that we used above, as a good example to get you started with the API.

Requesting features from a public vector table

The URL for public vector table requests looks like this:

https://www.googleapis.com/mapsengine/v1/tables/table_id/features?parameters

In the URL path:

  • table_id: This is the asset ID of the vector table that you want to access. A table is a datasource in Google Maps Engine. For a conceptual overview of the Google Maps Engine components, see the conceptual guide.

You'll need to specify these URL parameters:

  • version=published: This indicates that you're accessing the publicly-accessible version of the table.
  • key: The value of the key parameter must be a valid key obtained from the Google APIs Console. See the instructions above.

For a full list of URL parameters, see the reference documentation. These are some of the optional parameters:

  • limit: Defines an upper bound on the number of features to return.
  • maxResults: Defines an upper bound on the number of features to return per results page. If more results match the request, a nextPageToken is included in the response. The request can be repeated with the nextPageToken as the value of a pageToken parameter to retrieve additional results.
  • orderBy: Determines the order in which features are returned. See the orderBy parameter section for details.
  • pageToken: Accepts the value of a previous request's nextPageToken field. Used to page through results.
  • select: Defines the columns to include in the response. See the select parameter section for details.
  • where: Allows SQL-like logic to be applied to the data. See the where parameter section for details.

For example:

  https://www.googleapis.com/mapsengine/v1/tables/12421761926155747447-06672618218968397709/features
  ?version=published
  &key=AIzaSyAzgdOiFagRujMB4kr-vyRTbPw3V6d1bWw
  &limit=75
  &maxResults=50
  &orderBy=LENGTH
  &pageToken=CGQSE0VnTXhPRGtZaHQ3dTJZNkl0d0k
  &select=LENGTH
  &where=LENGTH<0.1

orderBy

When requesting a list of features in a table, you may specify an orderBy value that determines the order in which features are returned.

GET https://www.googleapis.com/mapsengine/v1/tables/table_id/features
  ?select=ST_DISTANCE(location,ST_POINT(1,2)) AS distance
  orderBy=distance DESC
  &limit=50

The following rules apply to ordering:

  • Only one order key is supported.
  • The key must be defined in the SELECT clause. You may assign values to a temporary column alias (in this case distance):

    select=ST_DISTANCE(location,ST_POINT(1,2)) AS distance
      &orderBy=distance
    

    Or you may select an existing column in the table:

    select=location&orderBy=location
    
  • The sort order is stable. Features with identical keys are sorted by id.
  • Sorting defaults to ascending order. You may append ASC or DESC to the orderBy clause to specify an order.

    select=location&orderBy=location DESC
    
  • When including an orderBy parameter, you must also include a limit parameter, whose value is less than or equal to 75.

select

This parameter defines the columns to include in the response. The select parameter accepts column names:

select=location,name,"opening hours"

You may also use one of the supported geometry functions and a column alias:

select="opening hours",ST_DISTANCE(location,ST_POINT(1,2)) AS distance

The response includes only the specified properties, in the same order as they are specified.

When using the select parameter, note the following:

  • Property names are case sensitive.
  • The request must not specify duplicate or non-existent properties.
  • Property names do not need to be enclosed in quotation marks (for example, select=prop_1) if the name starts with a letter or an underscore, and is followed only by letters, numbers, and/or underscores.
  • All other property names must be enclosed in quotation marks (for example, select="Property One"). Single quotes are not supported.
  • If a property name includes quotation marks or backslashes, these must be escaped with a backslash (for example, select="Property \"Hello!\"").
  • The geometry property that occurs first in the list will be shown in the geometry field of the GeoJSON output.
  • If there are no geometry properties in the list, the geometry field will be null.

where

The Google Maps Engine API supports a limited SQL-like query language for requesting table features. A SQL-like predicate can be passed as the value of the where parameter, as follows:

GET https://www.googleapis.com/mapsengine/v1/tables/table_id/features?where=age>10
  • The predicate must include a column name from the specified table (age in the example above) and a supported operator:

    >, <, >=, <=, =, <>
    
  • Predicates can be joined with AND and/or OR. Note that AND has precedence over OR:

    where=age>10 AND income<=50000
    
  • You may use a supported geometry function:

    where=ST_DISTANCE(location,ST_POINT(1.23,4.56)) > 100
    
  • As with all parts of a request URL, predicates must be URL-encoded:

    where=age%3E10+AND+income%3C%3D50000
    

    Examples in this documentation are not encoded, for ease of reading.

Send feedback about...

Google Maps Engine API (Deprecated)