MIP Logo

Querying an API using Alteryx + Python – Pleiades API (Historical Places)

This post was originally published on The Data School blog between 2018 and July 2025, before our program was renamed to MIP’s Analytics Career Accelerator. References throughout this article to “The Data School” or “DS” all refer to what is now MIP’s Analytics Career Accelerator. The program, its people, and its commitment to launching outstanding analytics careers remain the same – just under a new name.

If you are having trouble viewing this article, please report it here. 

Why I chose this API

Unless you study the classics or are a big history buff like me, chances are you have never come across this API before. Quoting from their website: “Pleiades is a community-built gazetteer and graph of ancient places.”; which is a very valuable resource when looking to supplement shapefiles with reliable and accurate descriptors.

In my last blog, I wrote about the visualisation that I created to compare the sizes and spread of the Roman and Macedonian empires. To further improve the visualisation potential of this dataset and to access critical mapping information such as geo-coordinates more efficiently, an Alteryx workflow will be used to request data from the API, parse the result, transform and output in a structured format.

Querying the Pleiades API

Below is a screenshot of the output generated the Alteryx workflow that I built:

You can view my workflow in the screenshot below. Note that I did not use the download tool because I was not able to configure the tool to retrieve the data. Therefore, I chose the Python tool as the next best given that I am familiar with the Python syntax.

The Python Tool

The code below is a combination of the download tool, the JSON parser, and Crosstab. In the code snippet below, I used Pandas’ JSON parser, which often requires passing additional parameters for more complex JSON structures (e.g multi-layered/ nested). Pandas’ JSON parser also converts the JSON file into its native two-dimensional structure called a Pandas data frame. Incoming connections into the Python Tool only accept the Pandas data frame format.

Next Steps

Now that I have a workflow that can successfully query data from API and output in the correct format, the workflow is ready to be converted into a macro. Since the API only accepts queries for one location at a time, the macro input will accept a single location id or a list of location ids that a batch macro can loop through.

Share this post