Data API Getting started – Sample Code
This section provides quick-start guides for the Data API. Sometimes this API might be referred to as Query Tool (or QT) API because it provides access to the data that can be accessed through the Query Tool – Trackers, Spending Guides and Black Books.
Integrating with IDC’s Data API (version 3) allows you to programmatically fetch IDC data via RESTful endpoints. Below are the basic steps to start using the API:
- Obtain API Credentials: Setting up API Access if you haven’t already –
Setting up API Access . - Make Your First API Call: Using your API key, you can test connectivity by calling a simple endpoint. For example, you can list the data exports available to you. Use the base URL https://www.idctracker.com/api/v3 (for production) and include your API key in the request header as x-api-key. For instance:
bash
curl -H “x-api-key: [Your API Key]” -H “Accept: application/json” https://www.idctracker.com/api/v3/exports
This GET /api/v3/exports request will return a JSON array of available data exports (for all the IDC products in your subscription). Each entry contains metadata like the product version ID, product name, an export ID, timestamp, status, and a list of file downloads with URLs and filenames. - Download Data Files: Parse the JSON response to find the download URLs for the data files you need. Each export entry includes one or more file objects with a url field. These URLs are pre-authenticated API endpoints to download the actual data file. To download a file, you can use another curl command (or your HTTP client of choice) with the same x-api-key header. For example:
bash
curl -H “x-api-key: [Your API Key]” -H “Accept: application/zip” \ -o datafile.csv.gz “https://www.idctracker.com/api/v3/exports/1234/files/1”
This will retrieve the file (in this case, a GZIP-compressed CSV) and save it locally as datafile.csv.gz. Repeat for each file you need (or automate this in a script). Note: The first row of each CSV file contains column headers. The files are delivered compressed in .gz format; after download, you should decompress them to access the CSV content. Large products can result in large CSVs (hundreds of MB to several GB when uncompressed). - Automation: The above steps can be scripted. A common approach is to write a script (in Python, Bash, etc.) that runs periodically (e.g. hourly or daily) to check for new exports and download any new files. In the Basic Integration section, we provide more guidance and pseudo-code for such a script. By automating, you ensure your local data stays in sync with IDC’s latest releases.
That’s it! With your API key and these endpoints, you have the essentials to start pulling data. The API is RESTful and uses standard HTTP verbs and response codes. Next, you can explore more advanced usage like filtering data on the fly (Advanced Integration) or handling errors and versioning – see the
section for details.