(0 reviews)

Download Plan

The FCC has enhanced the API to make data extraction simpler and more efficient. This new feature is called the “DownloadPlan”. You no longer need to specify offsets/limits. You now have the ability to customize your query with all the necessary parameters to extract data, as needed. Sample API Calls:

Example API call:[yourkey].&

Download plan for this API call:[yourkey].&

Other examples:

  "filings": [],
  "aggregations": {
    "download_plan": {
      "buckets": [
          "key_as_string": "[gte]2017-04-27T13:20:00.000Z[lt]2017-04-29T19:31:00.000Z",
          "doc_count": 9995,
          "key": 1493299200000,
          "suggested_api_call": [
          "key_as_string": "[gte]2017-04-29T19:31:00.000Z[lt]2017-05-02T00:10:00.000Z",
          "doc_count": 9971,
          "key": 1493494260000,
          "suggested_api_call": [

Python Script Example:

# ------------------------------------------------------------------
# export of FCC filings using a download plan
# example usage for proceeding 17-108
# Usage:
# python {APIKey}
# ------------------------------------------------------------------
import json
import requests
import sys

APIUrl = ""

try:  #check for  api key
    api_key = sys.argv[1]
except (ValueError, IndexError):
    raise ValueError("API key is not supplied  ")

APIKey = "&api_key="+api_key
#customize the query
url=APIUrl +'filings?'+'&type=downloadplan'+ APIKey
print url
response = requests.get(url)
parsed = response.json()

#get download plan in json
filename = 'downloadplan.json'
with open('downloadplan.txt', 'w') as outfile:
    json.dump(parsed, outfile)

#for each bucket iterate over list of suggested api calls.
for doc in parsed['aggregations']['download_plan']['buckets']:
    file_slice = str(doc['key'])
    #print(json.dumps(doc, indent=4,sort_keys=True))
    if doc['suggested_api_call']:
        for api_call in doc['suggested_api_call']:
            file_slice_key = str(doc['key'])+str(count)+'.txt'
            print '--> ' + api_call_key
            slice_req = requests.get(api_call_key, stream=True)
            with open(file_slice_key, 'wb') as fd:
               for chunk in slice_req.iter_content(chunk_size=128):
                   if chunk:

# End While

# Save  the  file