Google is a service that… a provider who…. they run the Internet. They have this little mapping service too, so let’s check out the Google Maps API.

First though, two things to consider:

  • If you’re unfamiliar with APIs, you might want to read this first to familiarize yourself.
  • Install Postman, which allows you to access API endpoints without having to write an app, as well as save the calls you make and sync them online.

The Google Maps API isn’t so much an API but a series of APIs - for Android, iOS, web, etc - and each is focused on a small set of tasks. At first this seemed a bit overwhelming, to see a large set of APIs, but each of them is easy to use. I’ll pick a few out to play around with. (does that count as three days then?)

Geocoding API

The first one I thought looked interesting was the Geocoding API, which allows you to convert addresses to geolocation coordinates, and vice versa.

Authorization

Oddly enough, you don’t need an API key to experiment with these calls - they worked fine for me without it. I’m not sure how they rate limit requests then, but you’d still need one for a real product, so if you’re up for it then request an API key before doing anything else. Google’s docs are pretty straightforward so there’s not much else to say, except that you can just select “Create a new project”.

google-maps-geocoding-api—create-project-for-api-key
google-maps-geocoding-api—create-project-for-api-key

Be sure to copy the key it produces, because I can’t find where to view it after the modal dialog closes, other than clicking “Get a key” again. If you figure it out, I’d like to know! As they state, this automatically activates the Google Maps Geocoding API, and generates an unrestricted key.

google-api—get-api-key
google-api—get-api-key

Trying it out

Whether or not you generated a key, you should be able to try a couple things out.

Getting coordinates from an address

Try looking up an address to get information about it, including its coordinates.

GET https://maps.googleapis.com/maps/api/geocode/json?address=50 Public Square Cleveland, Ohio

I decided to lookup the Terminal Tower, a landmark in Cleveland. What I got back included:

  • the parsed address, with information I didn’t even provide like county and zip
  • a nicely, fully formatted string with the address
  • the geolocation coordinates
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{
    "results": [
        {
            "address_components": [
                {
                    "long_name": "50",
                    "short_name": "50",
                    "types": [
                        "street_number"
                    ]
                },
                {
                    "long_name": "Public Square",
                    "short_name": "Public Square",
                    "types": [
                        "route"
                    ]
                },
                {
                    "long_name": "Downtown",
                    "short_name": "Downtown",
                    "types": [
                        "neighborhood",
                        "political"
                    ]
                },
                {
                    "long_name": "Cleveland",
                    "short_name": "Cleveland",
                    "types": [
                        "locality",
                        "political"
                    ]
                },
                {
                    "long_name": "Cuyahoga County",
                    "short_name": "Cuyahoga County",
                    "types": [
                        "administrative_area_level_2",
                        "political"
                    ]
                },
                {
                    "long_name": "Ohio",
                    "short_name": "OH",
                    "types": [
                        "administrative_area_level_1",
                        "political"
                    ]
                },
                {
                    "long_name": "United States",
                    "short_name": "US",
                    "types": [
                        "country",
                        "political"
                    ]
                },
                {
                    "long_name": "44113",
                    "short_name": "44113",
                    "types": [
                        "postal_code"
                    ]
                }
            ],
            "formatted_address": "50 Public Square, Cleveland, OH 44113, USA",
            "geometry": {
                "location": {
                    "lat": 41.4984174,
                    "lng": -81.69372869999999
                },
                "location_type": "ROOFTOP",
                "viewport": {
                    "northeast": {
                        "lat": 41.4997663802915,
                        "lng": -81.6923797197085
                    },
                    "southwest": {
                        "lat": 41.4970684197085,
                        "lng": -81.6950776802915
                    }
                }
            },
            "place_id": "ChIJI9jXsn_wMIgRRyf46mR97eY",
            "types": [
                "street_address"
            ]
        }
    ],
    "status": "OK"
}

Getting an address from coordinates

How about trying the reverse, and getting the address again from the coordinates?

GET https://maps.googleapis.com/maps/api/geocode/json?latlng=41.4984174,-81.69372869999999

I was suprised to find the results (a portion of which is shown below) included far more than I had expected (such as a bus station), only because the coordinates seem so specific.

I searched for my home address and had similar results with the reverse search - the lat/long coords returned my house (cool), an address range on the street that intersects mine (we’re a corner lot, so okay), and a few addresses at the county level and the closest major city (weird and vague). It’s possible the list that gets returned is most to least specific, but why there are multiple hits at all I don’t really get.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
{
    "results": [
        {
            "address_components": [
                {
                    "long_name": "50",
                    "short_name": "50",
                    "types": [
                        "street_number"
                    ]
                },
                {
                    "long_name": "Public Square",
                    "short_name": "Public Square",
                    "types": [
                        "route"
                    ]
                },
                {
                    "long_name": "Downtown",
                    "short_name": "Downtown",
                    "types": [
                        "neighborhood",
                        "political"
                    ]
                },
                {
                    "long_name": "Cleveland",
                    "short_name": "Cleveland",
                    "types": [
                        "locality",
                        "political"
                    ]
                },
                {
                    "long_name": "Cuyahoga County",
                    "short_name": "Cuyahoga County",
                    "types": [
                        "administrative_area_level_2",
                        "political"
                    ]
                },
                {
                    "long_name": "Ohio",
                    "short_name": "OH",
                    "types": [
                        "administrative_area_level_1",
                        "political"
                    ]
                },
                {
                    "long_name": "United States",
                    "short_name": "US",
                    "types": [
                        "country",
                        "political"
                    ]
                },
                {
                    "long_name": "44113",
                    "short_name": "44113",
                    "types": [
                        "postal_code"
                    ]
                }
            ],
            "formatted_address": "50 Public Square, Cleveland, OH 44113, USA",
            "geometry": {
                "location": {
                    "lat": 41.4984174,
                    "lng": -81.69372869999999
                },
                "location_type": "ROOFTOP",
                "viewport": {
                    "northeast": {
                        "lat": 41.4997663802915,
                        "lng": -81.6923797197085
                    },
                    "southwest": {
                        "lat": 41.4970684197085,
                        "lng": -81.6950776802915
                    }
                }
            },
            "place_id": "ChIJI9jXsn_wMIgRRyf46mR97eY",
            "types": [
                "street_address"
            ]
        },
        {
            "address_components": [
                {
                    "long_name": "Euclid Av & Ontario St Station",
                    "short_name": "Euclid Av & Ontario St Station",
                    "types": [
                        "bus_station",
                        "establishment",
                        "point_of_interest",
                        "transit_station"
                    ]
                },
                {
                    "long_name": "Downtown",
                    "short_name": "Downtown",
                    "types": [
                        "neighborhood",
                        "political"
                    ]
                },
                {
                    "long_name": "Cleveland",
                    "short_name": "Cleveland",
                    "types": [
                        "locality",
                        "political"
                    ]
                },
                {
                    "long_name": "Cuyahoga County",
                    "short_name": "Cuyahoga County",
                    "types": [
                        "administrative_area_level_2",
                        "political"
                    ]
                },
                {
                    "long_name": "Ohio",
                    "short_name": "OH",
                    "types": [
                        "administrative_area_level_1",
                        "political"
                    ]
                },
                {
                    "long_name": "United States",
                    "short_name": "US",
                    "types": [
                        "country",
                        "political"
                    ]
                },
                {
                    "long_name": "44113",
                    "short_name": "44113",
                    "types": [
                        "postal_code"
                    ]
                }
            ],
            "formatted_address": "Euclid Av & Ontario St Station, Cleveland, OH 44113, USA",
            "geometry": {
                "location": {
                    "lat": 41.498881,
                    "lng": -81.69354199999999
                },
                "location_type": "GEOMETRIC_CENTER",
                "viewport": {
                    "northeast": {
                        "lat": 41.50022998029149,
                        "lng": -81.69219301970848
                    },
                    "southwest": {
                        "lat": 41.4975320197085,
                        "lng": -81.6948909802915
                    }
                }
            },
            "place_id": "ChIJk7Gntn_wMIgR67oq_t6hmaM",
            "types": [
                "bus_station",
                "establishment",
                "point_of_interest",
                "transit_station"
            ]
        },
        ...
        ...
    ],
    "status": "OK"
}

Directions API

That last API was straight-forward. Let’s try looking up some directions with the Directions API next. You don’t need an API token to test this one either, although certain parameters seem to require it. Create a new key if you want, and append it with &key=<your-api-key>.

Pick an origin and destination. I chose the Terminal Tower (again) as the origin, and a Starbucks around the corner from it as the destination (I know, there’s probably 2 Starbucks inside it), so the results wouldn’t be too large. Note the section in the results called “steps”, each of which have a start and end, total distance and duration, and even a one-line instruction in English.

There are lots of parameters for specifying how the directions should be calculated. In the following request, I’ve chosen “walking” as the travel mode, told it to return alternative routes, and set the language to French.

GET https://maps.googleapis.com/maps/api/directions/json?origin=50+Public+Square+Cleveland,+Ohio&destination=200+Public+Square+130,+Cleveland,+OH+44114&language=fr&mode=walking&alternatives=true
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
{
    "geocoded_waypoints": [
        {
            "geocoder_status": "OK",
            "place_id": "ChIJI9jXsn_wMIgRRyf46mR97eY",
            "types": [
                "street_address"
            ]
        },
        {
            "geocoder_status": "OK",
            "partial_match": true,
            "place_id": "ChIJL83I43_wMIgRdZlcIZMKIJ4",
            "types": [
                "premise"
            ]
        }
    ],
    "routes": [
        {
            "bounds": {
                "northeast": {
                    "lat": 41.4998051,
                    "lng": -81.6923484
                },
                "southwest": {
                    "lat": 41.4986974,
                    "lng": -81.6937592
                }
            },
            "copyrights": "Données cartographiques ©2017 Google",
            "legs": [
                {
                    "distance": {
                        "text": "0,1 miles",
                        "value": 192
                    },
                    "duration": {
                        "text": "3 minutes",
                        "value": 167
                    },
                    "end_address": "200 Public Square, 200 Public Square, Cleveland, OH 44114, États-Unis",
                    "end_location": {
                        "lat": 41.4998051,
                        "lng": -81.69261209999999
                    },
                    "start_address": "50 Public Square, Cleveland, OH 44113, États-Unis",
                    "start_location": {
                        "lat": 41.4986974,
                        "lng": -81.6937592
                    },
                    "steps": [
                        {
                            "distance": {
                                "text": "0,1 miles",
                                "value": 192
                            },
                            "duration": {
                                "text": "3 minutes",
                                "value": 167
                            },
                            "end_location": {
                                "lat": 41.4998051,
                                "lng": -81.69261209999999
                            },
                            "html_instructions": "Prendre la direction <b>nord-est</b> sur <b>S Roadway</b> vers <b>Ontario St</b><div style=\"font-size:0.9em\">Votre destination se trouvera sur la droite.</div>",
                            "polyline": {
                                "points": "{eh|F~xrqN?AAEAGAEc@eASg@Se@c@gAQa@AACACAAAC?C?C@C@CBk@f@ID"
                            },
                            "start_location": {
                                "lat": 41.4986974,
                                "lng": -81.6937592
                            },
                            "travel_mode": "WALKING"
                        }
                    ],
                    "traffic_speed_entry": [],
                    "via_waypoint": []
                }
            ],
            "overview_polyline": {
                "points": "{eh|F~xrqNEUoB{ESc@GCM?}@r@"
            },
            "summary": "S Roadway",
            "warnings": [
                "Le calcul d'itinéraires piétons est en bêta. Faites attention – Cet itinéraire n'est peut-être pas complètement aménagé pour les piétons."
            ],
            "waypoint_order": []
        },
        {
            "bounds": {
                "northeast": {
                    "lat": 41.4998051,
                    "lng": -81.6923484
                },
                "southwest": {
                    "lat": 41.4986913,
                    "lng": -81.69384509999999
                }
            },
            "copyrights": "Données cartographiques ©2017 Google",
            "legs": [
                {
                    "distance": {
                        "text": "0,1 miles",
                        "value": 221
                    },
                    "duration": {
                        "text": "3 minutes",
                        "value": 177
                    },
                    "end_address": "200 Public Square, 200 Public Square, Cleveland, OH 44114, États-Unis",
                    "end_location": {
                        "lat": 41.4998051,
                        "lng": -81.69261209999999
                    },
                    "start_address": "50 Public Square, Cleveland, OH 44113, États-Unis",
                    "start_location": {
                        "lat": 41.4986974,
                        "lng": -81.6937592
                    },
                    "steps": [
                        {
                            "distance": {
                                "text": "23 pieds",
                                "value": 7
                            },
                            "duration": {
                                "text": "1 minute",
                                "value": 5
                            },
                            "end_location": {
                                "lat": 41.49869229999999,
                                "lng": -81.69384509999999
                            },
                            "html_instructions": "Prendre la direction <b>ouest</b> sur <b>S Roadway</b>",
                            "polyline": {
                                "points": "{eh|F~xrqN@B?D?F"
                            },
                            "start_location": {
                                "lat": 41.4986974,
                                "lng": -81.6937592
                            },
                            "travel_mode": "WALKING"
                        },
                        {
                            "distance": {
                                "text": "46 pieds",
                                "value": 14
                            },
                            "duration": {
                                "text": "1 minute",
                                "value": 20
                            },
                            "end_location": {
                                "lat": 41.4988192,
                                "lng": -81.69381389999999
                            },
                            "html_instructions": "Tourner à <b>droite</b> vers <b>E Roadway</b>",
                            "maneuver": "turn-right",
                            "polyline": {
                                "points": "yeh|FpyrqNYG"
                            },
                            "start_location": {
                                "lat": 41.49869229999999,
                                "lng": -81.69384509999999
                            },
                            "travel_mode": "WALKING"
                        },
                        {
                            "distance": {
                                "text": "430 pieds",
                                "value": 131
                            },
                            "duration": {
                                "text": "2 minutes",
                                "value": 93
                            },
                            "end_location": {
                                "lat": 41.4994528,
                                "lng": -81.6925217
                            },
                            "html_instructions": "Tourner à <b>droite</b> vers <b>E Roadway</b>",
                            "maneuver": "turn-right",
                            "polyline": {
                                "points": "sfh|FhyrqN@CAEAIEM[m@MUGQKWKYSq@EMEICGECAA"
                            },
                            "start_location": {
                                "lat": 41.4988192,
                                "lng": -81.69381389999999
                            },
                            "travel_mode": "WALKING"
                        },
                        {
                            "distance": {
                                "text": "46 pieds",
                                "value": 14
                            },
                            "duration": {
                                "text": "1 minute",
                                "value": 11
                            },
                            "end_location": {
                                "lat": 41.4993763,
                                "lng": -81.6923833
                            },
                            "html_instructions": "Tourner à <b>droite</b> vers <b>E Roadway</b>",
                            "maneuver": "turn-right",
                            "polyline": {
                                "points": "qjh|FfqrqN@EJU"
                            },
                            "start_location": {
                                "lat": 41.4994528,
                                "lng": -81.6925217
                            },
                            "travel_mode": "WALKING"
                        },
                        {
                            "distance": {
                                "text": "180 pieds",
                                "value": 55
                            },
                            "duration": {
                                "text": "1 minute",
                                "value": 48
                            },
                            "end_location": {
                                "lat": 41.4998051,
                                "lng": -81.69261209999999
                            },
                            "html_instructions": "Prendre <b>à gauche</b> sur <b>E Roadway</b><div style=\"font-size:0.9em\">Votre destination se trouvera sur la droite.</div>",
                            "maneuver": "turn-left",
                            "polyline": {
                                "points": "cjh|FjprqNAACACAAAC?C?C@C@CBk@f@ID"
                            },
                            "start_location": {
                                "lat": 41.4993763,
                                "lng": -81.6923833
                            },
                            "travel_mode": "WALKING"
                        }
                    ],
                    "traffic_speed_entry": [],
                    "via_waypoint": []
                }
            ],
            "overview_polyline": {
                "points": "{eh|F~xrqN@H?FYG?IGWi@cASi@k@cBIK?GJUAAGCM?}@r@"
            },
            "summary": "E Roadway",
            "warnings": [
                "Le calcul d'itinéraires piétons est en bêta. Faites attention – Cet itinéraire n'est peut-être pas complètement aménagé pour les piétons."
            ],
            "waypoint_order": []
        },
        {
            "bounds": {
                "northeast": {
                    "lat": 41.50007040000001,
                    "lng": -81.69261209999999
                },
                "southwest": {
                    "lat": 41.4986913,
                    "lng": -81.69389630000001
                }
            },
            "copyrights": "Données cartographiques ©2017 Google",
            "legs": [
                {
                    "distance": {
                        "text": "0,2 miles",
                        "value": 244
                    },
                    "duration": {
                        "text": "3 minutes",
                        "value": 193
                    },
                    "end_address": "200 Public Square, 200 Public Square, Cleveland, OH 44114, États-Unis",
                    "end_location": {
                        "lat": 41.4998051,
                        "lng": -81.69261209999999
                    },
                    "start_address": "50 Public Square, Cleveland, OH 44113, États-Unis",
                    "start_location": {
                        "lat": 41.4986974,
                        "lng": -81.6937592
                    },
                    "steps": [
                        {
                            "distance": {
                                "text": "23 pieds",
                                "value": 7
                            },
                            "duration": {
                                "text": "1 minute",
                                "value": 5
                            },
                            "end_location": {
                                "lat": 41.49869229999999,
                                "lng": -81.69384509999999
                            },
                            "html_instructions": "Prendre la direction <b>ouest</b> sur <b>S Roadway</b>",
                            "polyline": {
                                "points": "{eh|F~xrqN@B?D?F"
                            },
                            "start_location": {
                                "lat": 41.4986974,
                                "lng": -81.6937592
                            },
                            "travel_mode": "WALKING"
                        },
                        {
                            "distance": {
                                "text": "72 pieds",
                                "value": 22
                            },
                            "duration": {
                                "text": "1 minute",
                                "value": 25
                            },
                            "end_location": {
                                "lat": 41.4988885,
                                "lng": -81.6937969
                            },
                            "html_instructions": "Tourner à <b>droite</b> vers <b>E Roadway</b>",
                            "maneuver": "turn-right",
                            "polyline": {
                                "points": "yeh|FpyrqNYGMA"
                            },
                            "start_location": {
                                "lat": 41.49869229999999,
                                "lng": -81.69384509999999
                            },
                            "travel_mode": "WALKING"
                        },
                        {
                            "distance": {
                                "text": "259 pieds",
                                "value": 79
                            },
                            "duration": {
                                "text": "1 minute",
                                "value": 54
                            },
                            "end_location": {
                                "lat": 41.4995628,
                                "lng": -81.6938514
                            },
                            "html_instructions": "Tourner à <b>gauche</b> vers <b>E Roadway</b>",
                            "maneuver": "turn-left",
                            "polyline": {
                                "points": "agh|FfyrqNCFEDGBK@KAy@GKAEAE?C?A@A?A@"
                            },
                            "start_location": {
                                "lat": 41.4988885,
                                "lng": -81.6937969
                            },
                            "travel_mode": "WALKING"
                        },
                        {
                            "distance": {
                                "text": "328 pieds",
                                "value": 100
                            },
                            "duration": {
                                "text": "1 minute",
                                "value": 70
                            },
                            "end_location": {
                                "lat": 41.50007040000001,
                                "lng": -81.6928607
                            },
                            "html_instructions": "Tourner à <b>droite</b> vers <b>E Roadway</b>",
                            "maneuver": "turn-right",
                            "polyline": {
                                "points": "gkh|FpyrqNc@eAw@kBIS"
                            },
                            "start_location": {
                                "lat": 41.4995628,
                                "lng": -81.6938514
                            },
                            "travel_mode": "WALKING"
                        },
                        {
                            "distance": {
                                "text": "118 pieds",
                                "value": 36
                            },
                            "duration": {
                                "text": "1 minute",
                                "value": 39
                            },
                            "end_location": {
                                "lat": 41.4998051,
                                "lng": -81.69261209999999
                            },
                            "html_instructions": "Prendre <b>à droite</b> sur <b>E Roadway</b><div style=\"font-size:0.9em\">Votre destination se trouvera sur la gauche.</div>",
                            "maneuver": "turn-right",
                            "polyline": {
                                "points": "mnh|FjsrqN@A^]PQ"
                            },
                            "start_location": {
                                "lat": 41.50007040000001,
                                "lng": -81.6928607
                            },
                            "travel_mode": "WALKING"
                        }
                    ],
                    "traffic_speed_entry": [],
                    "via_waypoint": []
                }
            ],
            "overview_polyline": {
                "points": "{eh|F~xrqN@H?FYGMAILSDeAI[CC@e@cAaA_C`@_@PQ"
            },
            "summary": "S Roadway et E Roadway",
            "warnings": [
                "Le calcul d'itinéraires piétons est en bêta. Faites attention – Cet itinéraire n'est peut-être pas complètement aménagé pour les piétons."
            ],
            "waypoint_order": []
        }
    ],
    "status": "OK"
}

Time Zone API

We’ll try one more. The Time Zone API presents time zone information for a given set of coordinates. Again, the key doesn’t seem to be required for testing, but you can get a key anyway if you’d like. FWIW, when I tried to re-use a previous auth key, it didn’t like that - I got an error:

1
2
3
4
{
    "errorMessage": "This API project is not authorized to use this API. Please ensure this API is activated in the Google Developers Console: https://console.developers.google.com/apis/api/timezone_backend?project=_",
    "status": "REQUEST_DENIED"
}

So for now, just omit the API key. To calculate the required timestamp parameter, which represents the number of seconds since the epoch, use the Epoch Converter… assuming you can’t just figure it out in your head. ;p Just copy the value where it says “The current Unix epoch time is …”

GET https://maps.googleapis.com/maps/api/timezone/json?location=41.4984174,-81.69372869999999&timestamp=1513992742

The results include the Time Zone ID and Name for the location you specified. Since I used a location in Cleveland OH, and daylight savings time ended in November, I get EST back.

1
2
3
4
5
6
7
{
    "dstOffset": 0,
    "rawOffset": -18000,
    "status": "OK",
    "timeZoneId": "America/New_York",
    "timeZoneName": "Eastern Standard Time"
}

Thoughts

I’m not sure why these calls didn’t require an API key, since I’m not sure how they can enforce limits.

Speaking of limits, the limits for a free API key are very generous, typically thousands of requests per day for each API - certainly enough for personal use or even something small for a team at work - so that’s nice.

Even though there are a lot of APIs, they seem to be very focused in purpose. It’s interesting though, since the other APIs I’ve looked at are usually few (or one) with lots of endpoints that do different things. By breaking things up, it’s probably easier to control access to one thing or another.

I’ll definitely be looking for opportunites to try these out on some other projects - maybe on the Raspberry Pi sometime. :)