Hello. I've been recently trying to programatically convert a bunch of UniProt IDs to gene names.
I found the UniProt API, which should do the job, something in the lines of:

    import urllib,urllib2
    
    url = 'http://www.uniprot.org/uploadlists/'
    
    params = {
    'from':'ACC',
    'to':'P_REFSEQ_AC',
    'format':'tab',
    'query':'P13368 P20806 Q9UM73 P97793 Q17192'
    }
    
    data = urllib.urlencode(params)
    request = urllib2.Request(url, data)
    contact = "" # Please set your email address here to help us debug in case of problems.
    request.add_header('User-Agent', 'Python %s' % contact)
    response = urllib2.urlopen(request)
    page = response.read(200000)

The problem is, this returns whole website. Is it possible to only obtain a e.g. JSON where a list of mappings and corresponding information would be present (e.g. species too).

Thank you.
You can use requests like 

   http://www.uniprot.org/uniprot/?query=accession:P13368&format=tab&columns=genes

to access only the gene names. However, the delimiting is a bit odd to parse in this case. i.e. some entries are linked to more than one gene. And genes often have more than one name and its hard to figure whats what in this output.

You can either parse this out of the different file formats or use our [sparql][1] endpoint to just ask the preferred gene names 
directly.

    BASE <http://purl.uniprot.org/uniprot/> 
    PREFIX skos:<http://www.w3.org/2004/02/skos/core#> 
    PREFIX up:<http://purl.uniprot.org/core/> 
    PREFIX taxon:<http://purl.uniprot.org/taxonomy/> 
    SELECT ?protein ?preferredGeneName 
    WHERE
    {
        VALUES ?protein {<P13368> <P20806> <Q9UM73> <P97793> <Q17192>}
    	?protein a up:Protein ; 
                 up:encodedBy/skos:prefLabel ?preferredGeneName .
    }

You can use the download links for this to get the information back as json/xml or csv as you wish and by editing the UniProt accessions in the query you can retrieve all entries you want.

  [1]: http://sparql.uniprot.org/