Some progress on the API: JSON endpoints

Some weeks ago we stated that we are working on implementing the Distributed Annotation System into openSNP. And I’m sorry that I’ll have to announce that we are not finished with this yet. We just underestimated the amount of time it would take to finish this. But to make up for this we just released some JSON (JavaScript Object Notation) endpoints which you can use to get data out of openSNP. JSON can be easily parsed using software and is already widely used, especially in web applications. For a start we added JSON support for the user-index, for genotypes at single SNPs and for all phenotypes of a given user and I’ll briefly discuss how you can access the different JSON endpoints.

Let’s start with the user-index, which can easily be accessed at http://opensnp.org/users.json. This includes the complete list of all openSNP-users and their names, their unique user-IDs and all the genotyping-files (with the unique genotype-IDs and the download-links). We hope that this makes an ideal entry-point if you are looking for genotyping-files and the user-IDs to further query the openSNP-database.

If you want to get genotypes of single or multiple users for a given SNP you can use the JSON endpoint at http://opensnp.org/snps/json/$snpname/$userid.json. Just replace $snpname by the Rs-ID you are interested in and $userid by the unique ID of the user you are interested in. For example: http://opensnp.org/snps/json/rs9939609/1.json gives you my genotype at Rs9939609. If you are interested in the genotypes of multiple users you can concatenate this into a single query by either using commas to provide multiple User-IDs (for example http://opensnp.org/snps/json/rs9939609/1,6,8.json) or by giving a range of user-IDs (for example http://opensnp.org/snps/json/rs9939609/1-8.json).

Similarly you can access all phenotypic information of a given user by using http://opensnp.org/phenotypes/json/$userid.json. Again: Just replace $userid by the unique ID of the user you are interested in. For example http://opensnp.org/phenotypes/json/1.json gives you all the phenotypic information I have entered about myself so far. Concatenating multiple users into one query works just as for the SNP/User-combinations by using commas (http://opensnp.org/phenotypes/json/1,6,8.json) or ranges (http://opensnp.org/phenotypes/json/1-8.json). In any case: If you request data of users or user/SNP-combinations that don’t exist the JSON-hash you will get back includes the key “error”, just like this.

This are all the options you can supply by using our JSON-endpoints right now. There are no API-keys and no rate limits. We will just see how it turns out and if any limiting of the access will be necessary in the future. We hope that this will allow more easily reusing the openSNP-data and you maybe have already some nice ideas for remixes/browser plugins/younameit. If you have any requests, which kind of JSON-endpoints you need or would like us to add, just let us know. We are currently experimenting with this JSON-stuff and are open for any critique, comments, ideas etc. If you want to help us to implement further features into openSNP: Please do so, we are open for everybody who wants to participate and want to invite you to do so. The source code is freely available and there is a Google Group/mailinglist where we discuss bug-fixing, new features etc. So you might want to join us there.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: