connecting to DKAN API and/or CORS

The Asian Development Bank has sets of statistics available online as JSON data .

I would like to play around with this information in a manner similar to Torben Jansen, but I haven’t figured out the API connection. The DKAN API documentation overwhelm me.

I have experimented with this and that pattern for API connections, but to no avail. Most of the approaches I’ve found on how to connect hit up against CORS errors on these ADB-hosted URL that are linked through the web UI hosted JSON files.

Please help me to get connected and help with a quick guide to how to ask some simple questions of the data :pray:

How can you tell that the data is available as JSON? I don’t see a link anywhere.

Also, which of the datasets are you interested in? And what is preventing you from importing the CSV?

It looks like the ADB doesn’t serve CORS headers, but you can use a CORS proxy like this:

metadata = fetch('https://cors-anywhere.herokuapp.com/https://data.adb.org/api/3/action/package_show?id=08c793eb-acd6-4840-9172-139907cbd784').then(res => res.json())

As far as I can tell, they only serve metadata following the DKAN API. To do interesting stuff with the data, you’ll probably want to fetch the CSV files, e.g. with d3.csv:

d3 = require('d3@5')
basic_stats = d3.csv('https://cors-anywhere.herokuapp.com/https://data.adb.org/sites/default/files/basic-statistics-2019_1.csv')
1 Like

@mootari, here’s where the the JSON data is linked:

… just under the link ADB introduces the link to the DKAN API.

@bgchen - thank you. it’s unfortunate that the API does not allow one to better interface with ADB data :frowning: grabbing out all these individual csv files is rough.

Nope, sadly that’s just the document index in JSON form. :slight_smile:

grabbing out all these individual csv files is rough.

One thing that could help a tiny bit is to get a list of csv URLs from the metadata and fetch from those so that you don’t have to manually dig up the links. But this might not save that much time since it looks like the metadata URLs they provide only refer to a few resources each.

1 Like

Thanks again @mootari and @bgchen. Just to follow up, CSV totally did the trick:

Unfortunately ADB’s general project data csv file excludes some information used in their project search interface, such as information about which projects have gender components :(. I’ll see if I can find this information in another csv and then tie it in. Also still struggling with some basic regional maps, but I’ll keep plugging away and will raise questions where I get stuck.

You too both have been, and continue to be, amazingly patient and caring. Thank you!

1 Like