In [8]:
import sys
import requests

q = 'indramayu'
r = requests.get('http://api.geonames.org/searchJSON',
    params={'q': q, 'username': 'ceefour'})
r


Out[8]:
<Response [200]>

In [9]:
data = r.json()
data


Out[9]:
{'geonames': [{'adminCode1': '30',
   'adminName1': 'West Java',
   'countryCode': 'ID',
   'countryId': '1643084',
   'countryName': 'Indonesia',
   'fcl': 'P',
   'fclName': 'city, village,...',
   'fcode': 'PPLA2',
   'fcodeName': 'seat of a second-order administrative division',
   'geonameId': 1643078,
   'lat': '-6.32639',
   'lng': '108.32',
   'name': 'Indramayu',
   'population': 123263,
   'toponymName': 'Indramayu'},
  {'adminCode1': '30',
   'adminName1': 'West Java',
   'countryCode': 'ID',
   'countryId': '1643084',
   'countryName': 'Indonesia',
   'fcl': 'A',
   'fclName': 'country, state, region,...',
   'fcode': 'ADM2',
   'fcodeName': 'second-order administrative division',
   'geonameId': 1643077,
   'lat': '-6.45',
   'lng': '108.16667',
   'name': 'Kabupaten Indramayu',
   'population': 1714184,
   'toponymName': 'Kabupaten Indramayu'},
  {'adminCode1': '30',
   'adminName1': 'West Java',
   'countryCode': 'ID',
   'countryId': '1643084',
   'countryName': 'Indonesia',
   'fcl': 'T',
   'fclName': 'mountain,hill,rock,... ',
   'fcode': 'PT',
   'fcodeName': 'point',
   'geonameId': 1643075,
   'lat': '-6.245',
   'lng': '108.29472',
   'name': 'Tanjung Indramayu',
   'population': 0,
   'toponymName': 'Tanjung Indramayu'},
  {'adminCode1': '30',
   'adminName1': 'West Java',
   'countryCode': 'ID',
   'countryId': '1643084',
   'countryName': 'Indonesia',
   'fcl': 'A',
   'fclName': 'country, state, region,...',
   'fcode': 'ADM3',
   'fcodeName': 'third-order administrative division',
   'geonameId': 6404422,
   'lat': '-6.30111',
   'lng': '108.34833',
   'name': 'Kecamatan Indramayu',
   'population': 0,
   'toponymName': 'Kecamatan Indramayu'},
  {'adminCode1': '00',
   'adminName1': '',
   'countryCode': 'ID',
   'countryId': '1643084',
   'countryName': 'Indonesia',
   'fcl': 'S',
   'fclName': 'spot, building, farm',
   'fcode': 'RSTP',
   'fcodeName': 'railroad stop',
   'geonameId': 1643076,
   'lat': '-6.31667',
   'lng': '108.31667',
   'name': 'Perhentian Indramayu',
   'population': 0,
   'toponymName': 'Perhentian Indramayu'},
  {'adminCode1': '30',
   'adminName1': 'West Java',
   'countryCode': 'ID',
   'countryId': '1643084',
   'countryName': 'Indonesia',
   'fcl': 'S',
   'fclName': 'spot, building, farm',
   'fcode': 'PS',
   'fcodeName': 'power station',
   'geonameId': 11612609,
   'lat': '-6.27451',
   'lng': '107.96825',
   'name': 'PLTU Indramayu',
   'population': 0,
   'toponymName': 'PLTU Indramayu'}],
 'totalResultsCount': 6}

In [10]:
print('%s places found for "%s"' % (len(data['geonames']), q))


6 places found for "indramayu"

In [13]:
for place in data['geonames']:
    print('%s (%s,%s)' % (place['toponymName'], place['lat'], place['lng']))


Indramayu (-6.32639,108.32)
Kabupaten Indramayu (-6.45,108.16667)
Tanjung Indramayu (-6.245,108.29472)
Kecamatan Indramayu (-6.30111,108.34833)
Perhentian Indramayu (-6.31667,108.31667)
PLTU Indramayu (-6.27451,107.96825)