In [2]:
import requests 
#software list API for "python"
r = requests.get("http://usesthis.com/api/v1/software/python")
#view the generated url, response status, and content-type
print(r.url + '\nstatus:' + str(r.status_code) + '\ncontent-type:' + r.headers['content-type'])
http://usesthis.com/api/v1/software/python
status:200
content-type:application/json

In [4]:
import json
#get json text
j = json.loads(r.text)
print(j)
{'gear': {'description': 'An interpreted scripting language.', 'url': 'https://www.python.org/', 'name': 'Python', 'slug': 'python', 'interviews': [{'name': 'Vili Lehdonvirta', 'slug': 'vili.lehdonvirta'}, {'name': 'Bob Nystrom', 'slug': 'bob.nystrom'}, {'name': 'Judd Vinet', 'slug': 'judd.vinet'}, {'name': 'Catherine Mulbrandon', 'slug': 'catherine.mulbrandon'}, {'name': 'Sam Lavigne', 'slug': 'sam.lavigne'}, {'name': 'Brendan Gregg', 'slug': 'brendan.gregg'}, {'name': 'Amelia Greenhall', 'slug': 'amelia.greenhall'}, {'name': 'Clay Shirky', 'slug': 'clay.shirky'}, {'name': 'Gary Bernhardt', 'slug': 'gary.bernhardt'}, {'name': 'Matt Cutts', 'slug': 'matt.cutts'}, {'name': 'Thomas Marban', 'slug': 'thomas.marban'}, {'name': 'Adit Gupta', 'slug': 'adit.gupta'}, {'name': 'Ashe Dryden', 'slug': 'ashe.dryden'}, {'name': 'Paul Lamere', 'slug': 'paul.lamere'}, {'name': 'Matt Webb', 'slug': 'matt.webb'}, {'name': 'Jeffrey Ely', 'slug': 'jeffrey.ely'}, {'name': 'Daniel Lemire', 'slug': 'daniel.lemire'}, {'name': 'Daniel Jalkut', 'slug': 'daniel.jalkut'}, {'name': 'Jerry Belich', 'slug': 'jerry.belich'}, {'name': 'Mark Nottingham', 'slug': 'mark.nottingham'}, {'name': 'Lynn Root', 'slug': 'lynn.root'}, {'name': 'Brian Kernighan', 'slug': 'brian.kernighan'}, {'name': 'Samuel Arbesman', 'slug': 'samuel.arbesman'}, {'name': 'Peter Molfese', 'slug': 'peter.molfese'}, {'name': 'Micah Elizabeth Scott', 'slug': 'scanlime'}, {'name': 'Robin Camille Davis', 'slug': 'robin.davis'}, {'name': 'Tamas Kemenczy', 'slug': 'tamas.kemenczy'}, {'name': 'Neha Narula', 'slug': 'neha.narula'}, {'name': 'Chad Whitacre', 'slug': 'chad.whitacre'}, {'name': 'John Myles White', 'slug': 'john.myles.white'}, {'name': 'Kenneth Reitz', 'slug': 'kenneth.reitz'}, {'name': 'Ben Welsh', 'slug': 'ben.welsh'}, {'name': 'Bhautik Joshi', 'slug': 'bhautik.joshi'}, {'name': 'Jonathan Corbet', 'slug': 'jonathan.corbet'}, {'name': 'Benjamin Mako Hill', 'slug': 'benjamin.mako.hill'}, {'name': 'Max Shron', 'slug': 'max.shron'}, {'name': 'Divya Manian', 'slug': 'divya.manian'}, {'name': 'Daniel Robbins', 'slug': 'daniel.robbins'}, {'name': 'Adewale Oshineye', 'slug': 'adewale.oshineye'}, {'name': 'Hugo Liu', 'slug': 'hugo.liu'}, {'name': 'Liza Daly', 'slug': 'liza.daly'}, {'name': 'Matt Might', 'slug': 'matt.might'}, {'name': 'Douglas Rushkoff', 'slug': 'douglas.rushkoff'}, {'name': 'Zed Shaw', 'slug': 'zed.shaw'}, {'name': 'Drew Conway', 'slug': 'drew.conway'}, {'name': 'Chris Slowe', 'slug': 'chris.slowe'}, {'name': 'Meghan Newell', 'slug': 'meghan.newell'}, {'name': 'Amanda Wixted', 'slug': 'amanda.wixted'}, {'name': 'Rebekah Cox', 'slug': 'rebekah.cox'}, {'name': 'Hilary Mason', 'slug': 'hilary.mason'}, {'name': 'Jonathan Foote', 'slug': 'jonathan.foote'}, {'name': 'Jonathan Foote', 'slug': 'jonathan.foote'}, {'name': 'Josh Myer', 'slug': 'josh.myer'}, {'name': 'Josh Nimoy', 'slug': 'josh.nimoy'}, {'name': 'Jeff Lindsay', 'slug': 'jeff.lindsay'}, {'name': 'Stewart Smith', 'slug': 'stewart.smith'}, {'name': 'Laura Khalil', 'slug': 'laura.khalil'}, {'name': 'Blaise Aguera y Arcas', 'slug': 'blaise.aguera.y.arcas'}, {'name': 'Aaron Swartz', 'slug': 'aaron.swartz'}, {'name': 'MĂĄirĂ\xadn Duffy', 'slug': 'mairin.duffy'}, {'name': 'Joe Hewitt', 'slug': 'joe.hewitt'}, {'name': 'Anselm Hook', 'slug': 'anselm.hook'}]}}

In [61]:
#loop through interviews and store software titles in a list
software = []
#print('People that use python use:')
for i in j['gear']['interviews']:
    #print('\n' + i['name'])
    #do another request to the interview api to get each person's software
    r2 = requests.get("http://usesthis.com/api/v1/interviews/" + i['slug'])
    intvw = json.loads(r2.text)
    for s in intvw['interview']['gear']['software']:
        #print(s['name'], end=', ')
        software.append(s['name'])
from collections import Counter
counts = Counter(software)
#only get the items that are used by more than 4 people, and remove the python count since they all have it
#got this from here: http://stackoverflow.com/questions/4484690/how-to-filter-dictionary-in-python
counts_over4 = dict([(labels, values) for labels, values in counts.items() if values > 4 if labels != 'Python'])
#print(counts_over4)
In [64]:
#sort the list
from operator import itemgetter
#create a visual of the items that more than 2 people use
#got this from here: http://stackoverflow.com/questions/19198920/using-counter-in-python-to-build-histogram
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
labels, values = zip(*sorted(counts_over4.items(), key=itemgetter(1)))
indexes = np.arange(len(labels))
height = 0.25
plt.figure(num=1,figsize=(10,15))
plt.barh(indexes, values, height)
plt.yticks(indexes, labels, size='small')
plt.show()
In []: