pythonjsonfreebase

Can't access mqlread API


I am trying to access the mqlread API from Freebase but am getting a "Not Found" 404:

api_key = open("freebaseApiKey").read()
mqlread_url = 'https://www.googleapis.com/freebase/v1/mqlread'
mql_query = '[{"mid": null,"name": null, "type": "/location/statistical_region","limit": 100}]'
cursor = ""

topicService_url = 'https://www.googleapis.com/freebase/v1/topic'
params = {
  'key': api_key,
  'filter': '/location/statistical_region',
  'limit': 0
}

for i in xrange(1000):
    mql_url = mqlread_url + '?query=' + mql_query + "&cursor=" + cursor
    print mql_url
    statisticalRegionsResult = json.loads(urllib.urlopen(mql_url).read())
    ....

Obviously when I run my python file I get:

https://www.googleapis.com/freebase/v1/mqlread?query=[{"mid": null,"name": null, "type": "/location/statistical_region","limit": 100}]&cursor=
Traceback (most recent call last):
  File "[Filepath]...FreeBaseDownload.py", line 37, in <module>
    statisticalRegionsResult = json.loads(urllib.urlopen(mql_url).read())
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/json/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/json/decoder.py", line 319, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/json/decoder.py", line 338, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

What am I doing wrong with the API? I've read things about mqlread being deprecated, what is the parallel for my quest to get all statistical regions (the mids) in Freebase?


Solution

  • It was deprecated over a year ago. It was finally shut down May 2.

    https://groups.google.com/forum/#!topic/freebase-discuss/WEnyO8f7xOQ

    The only source for this information now is the Freebase data dump.

    https://developers.google.com/freebase/#freebase-rdf-dumps