import json import requests url = 'https://opendata.resas-portal.go.jp/api/v1/cities?prefCode=1' KEY = 'QTPchshTtS5JGmrEw0ELladqSbGwnKxh5KVqmZvU' query = {'X-API-KEY': KEY} r = requests.get(url, headers=query) d = json.loads(r._content.decode('utf-8')) x=d['result'] for x1 in x: y1=x1['cityCode'] v1=x1['cityName'] print(v1)