Last Updated: February 25, 2016
·
480
· sankosk

An easy and simple coderwall api for python2

I was bored and I coded a simple api code using profile API with python for enjoy myself a bit.

import urllib, json


class Coderwall:

    def __init__(self, username, data=""):
        self.username = username
        self.url = "http://coderwall.com/"
        self.parseData(data)

    def getData(self):
        try:
            f = urllib.urlopen("%s%s.json" % (self.url, self.username))
            return f.read()

        except:
            return {"ERROR":"Error getting data"}

    def parseData(self, data=""):
        jsonData = json.loads(self.getData())
        if data == "":
            for i in jsonData:
                print "%s: %s" % (i, jsonData[i])
        else:
            if data in jsonData:
                print "%s: %s" % (data, jsonData[data])
            else:
                print "Invalid argument"
"""
Keep it simple st***d

Usage:
Coderwall('username') -> extract all data from username's profile
Coderwall('username', 'name') or Coderwall('username', 'username'), location, etc -> take an argument to show
"""

output examples:

from coderwall import Coderwall

Coderwall('sankosk')

username: sankosk
name: Esteban Montes
endorsements: 0
accounts: {u'github': u'sankosk'}
location: Asturias
team: None
badges: []

Coderwall('sankosk','location')

location: Asturias

Coderwall('sankosk','name')

name: Esteban Montes

maybe someone ever need it :)