MyGene.info API supports SSL now, so works in your https webapp

by Chunlei Wu

You requested, and we implemented. Now you can use MyGene.info API via both http and https protocols (read more about http vs https).

One of popular use cases for MyGene.info API is to make gene queries from the web applications directly via AJAX calls. Developers don't need to maintain their own gene annotation database to handle these queries. Gene annotation data served from MyGene.info API are public, usually you don't need to encrypt them when making an API call. However, if you have a SSL-enabled web application (i.e., URL starts with https:// instead of http://) and try to make AJAX call from this app to uncrypted MyGene.info API, you will hit a mixed content error. Moden browsers will just block the access to any uncrypted request.

With the support of SSL, now you can switch the URL of your MyGene.info query to use https instead. That way, all the traffic between MyGene.info and the client are encrypted and user browsers will be happy, without popping up an error.

Here are examples of both http and https requests:

  • Regular http request without encryption:
GET http://mygene.info/v2/query?q=symbol:cdk2&species=human

HTTP/1.1 200 OK
Content-Length: 183
Content-Type: application/json; charset=UTF-8

{
    "hits": [
        {
            "_id": "1017", 
            "_score": 89.21377, 
            "entrezgene": 1017, 
            "name": "cyclin-dependent kinase 2", 
            "symbol": "CDK2", 
            "taxid": 9606
        }
    ], 
    "max_score": 89.21377, 
    "took": 6, 
    "total": 1
}

  • https request with encryption:
GET https://mygene.info/v2/query?q=symbol:cdk2&species=human

HTTP/1.1 200 OK
Content-Length: 183
Content-Type: application/json; charset=UTF-8

{
    "hits": [
        {
            "_id": "1017", 
            "_score": 89.21377, 
            "entrezgene": 1017, 
            "name": "cyclin-dependent kinase 2", 
            "symbol": "CDK2", 
            "taxid": 9606
        }
    ], 
    "max_score": 89.21377, 
    "took": 6, 
    "total": 1
}

Have fun!