Kiva Tool – Realtime Lending Countries

*If tech talk bores you skip down to the charts.*
kiva chart

What’s Kiva? An awesome non-profit that uses crowdsourced microlending to alleviate poverty through economic empowerment: www.kiva.org

I’ve spent the last couple of days playing around with the Kiva API, and here’s what I’ve come up with.

Recent Activity & Generous Countries

Kiva provides access to the 100 most recent loan actions, but no further historical data on loan activities. As far as I could tell this is the only way to get timestamps of loan activity, so I built a scraper that checks recent loan activity every couple of minutes, then stores timestamps, origin geo data, and destination geo data.

Using my scrapes I have managed to build realtime charts of which countries are top lenders and top receivers. I also did a version of the graphs that are normalized by population, I think this gives an indication of which countries really dig the Kiva model.

Check it out: www.davidrs.com/SandBox/kiva/LocationCounts/

*This originally had an animated live timeline of loans, but it has been removed to save database space*

Wishlist

If I had another 6 hours to work on it what would I do?

  • Integrate animations so that you could watch the country ratios change over a 24 hour period.
  • Wait until I have more data, then cluster countries lending habits by time of day, weekday vs weekend etc.
  • If I had lots of time I would try to compare the local weather with loans that were made and see if good or bad weather corelates to lending behaviour.
  • …one more unrelated idea was to compare the word cloud of 400 funded projects and 400 projects that didn’t get funding and look for differences.

Tech Stuff

I used d3 for the graphing, pie and bar charts were easy. Getting the ‘wiggle’ stack working was hard, especially because some countries don’t have data points for certain points in time, so I need to pad the arrays so all of the time stamps in the array align and d3 will play nice.

PHP for all the server side scripting.

A Map

My first Kiva API project was a map. I used the php Kiva API wrapper, and created a map of all of the loans that my girlfriend and I have made:

Click to visit the map

Tech Challenges: Nothing too tricky, I noticed the php wrapper didn’t provide me with too much extra functionality apart from building the request strings for me. It uses curl, which didn’t really seem necessary for the simplicity of this api, so for my next project I just made my own string request builder and used php’s ‘get_file_contents’.

This was my first time using stamen maps, for style. They look very pretty, but the loading time can be killer.