{"_id":"5751d0524afe7e2d00152823","project":"55faf11ba62ba1170021a9a7","__v":0,"user":{"_id":"5613e4f8fdd08f2b00437620","username":"","name":"Emile Young"},"initVersion":{"_id":"55faf11ba62ba1170021a9aa","version":"1.0"},"createdAt":"2016-06-03T18:45:38.186Z","changelog":[],"body":"The Seven Bridges CGC Application Programming Interface (API) has allowed our users to automate, extend, and customize their analysis pipelines. We currently have more than 50 officially supported calls and some additional calls in the Advanced Access Program. We use a REST architecture with calls detailed in our [documentation](http://docs.cancergenomicscloud.org/v1.0/docs/the-cgc-api). An example (with a deactivated authentication token) of listing projects using cURL is shown below:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl  -s -H \\\"X-SBG-Auth-Token: 6282d5e2121d43e7900e9d52b15845e7\\\" -H \\\"content-type: application/json\\\" -X GET \\\"https://cgc-api.sbgenomics.com/v2/projects\\\"\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\nMany users, including Seven Bridges' own engineers, have developed wrappers for the API calls in Python, R, and bash. This allowed them to leverage scripting to complete a spectrum of analyses, ranging from batch processing of >5000 tasks to adapting complex processing workflows based on intermediate results. Today we are pleased to announce that Seven Bridges has created *official bindings* for the CGC API in **[Python](https://github.com/sbg/sevenbridges-python)** and **[R](https://github.com/sbg/sevenbridges-r)**. There are four key advantages of these bindings:\n\n\n1. It is easier to start using the CGC API, with a minimal onboarding curve\n2. The CGC API can be used via professionally _designed_ and _maintained_ software\n3. The bindings are available through the expected channels\n4. Seven Bridges can provide more thorough support for official bindings than bespoke wrappers created by each user\n\n\nHere we will focus on the Python bindings (the R bindings will have their own blog post soon).\n\n\nWhen using the CGC API, you should use an [authentication token](http://docs.cancergenomicscloud.org/docs/get-your-authentication-token) (available from the CGC), which encodes your credentials and permissions on the CGC. If you are issuing API calls from a script to make use of the Python or R bindings, you should, of course, avoid putting your authentication token into the code itself for security reasons. Instead, you can easily store your token for the CGC in a config file, .sbgrc which you should place in your home directory. Specify its contents as follows:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[cgc]\\nauth-token = d9334f30ac64422aa22a1f929e0c2dfd\\napi-url = https://cgc-api.sbgenomics.com/v2\",\n      \"language\": \"text\",\n      \"name\": \".sbgrc\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"success\",\n  \"body\": \"If you have multiple user accounts on the CGC, list your credentials for each in the config file.\",\n  \"title\": \"Storing multiple credentials\"\n}\n[/block]\nGetting started with the Python bindings is simple. First install the library using `pip`:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pip install sevenbridges-python\",\n      \"language\": \"shell\",\n      \"name\": \"Install the bindings\"\n    }\n  ]\n}\n[/block]\nThen use Python (either 2.6+ or 3) to create an object for your access credentials. The methods of this object will allow you to perform almost all CGC API calls. Here we again list all projects for the user:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"python\\nimport sevenbridges as sbg\\n\\n# User input: specify the platform you are using {cgc for the Cancer Genomics Cloud, sbg for the Seven Bridges Platform}\\nc = sbg.Config(profile='cgc')\\napi = sbg.Api(config=c)\\n\\n# list (up to) 50 projects\\nprojects = api.projects.query()\\n\\nprint( 'List of project ids and names:')\\nfor project in projects:\\n    print('%s \\\\t %s \\\\n' % (project.id, project.name))\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\nThe API language binding unleashes the full power of the CGC. Users can confidently build their own solutions as the method names are intuitively linked to functions. Additionally, these bindings reduce the frequency of errors because the syntax is more tightly controlled by the class definition. This will reduce failed API calls due to improper syntax, such as typos. We are supporting these new bindings through multiple avenues. First, the bindings are fully documented on [readthedocs](http://sevenbridges-python.readthedocs.io/en/latest/sevenbridges/). All source code is also available on [Github](https://github.com/sbg/sevenbridges-python). Finally, we have updated our repository of recipes (modular code snippets, designed to accomplish a single action) and tutorials (complete use-cases for the CGC) in order that the [main branch of the tutorials](https://github.com/sbg/okAPI/tree/master/Recipes/CGC) now uses the official Python wrapper. \n\nImportantly, in releasing the language bindings we have not changed the underlying API calls. So if you have your own wrappers and would like to keep using them, they will continue to work. Finally, we want to thank our users for their prior and continuing feedback. These bindings are the fruit of such feedback. Please keep reaching out to us at <a href=\"mailto:cgc@sbgenomics.com\" target=\"blank\">cgc@sbgenomics.com</a> so we can help you solve your problems even more efficiently.","slug":"announcing-the-release-of-seven-bridges-api-clients-in-r-and-python","title":"Announcing the release of Seven Bridges' API clients in R and Python"}

Announcing the release of Seven Bridges' API clients in R and Python


The Seven Bridges CGC Application Programming Interface (API) has allowed our users to automate, extend, and customize their analysis pipelines. We currently have more than 50 officially supported calls and some additional calls in the Advanced Access Program. We use a REST architecture with calls detailed in our [documentation](http://docs.cancergenomicscloud.org/v1.0/docs/the-cgc-api). An example (with a deactivated authentication token) of listing projects using cURL is shown below: [block:code] { "codes": [ { "code": "curl -s -H \"X-SBG-Auth-Token: 6282d5e2121d43e7900e9d52b15845e7\" -H \"content-type: application/json\" -X GET \"https://cgc-api.sbgenomics.com/v2/projects\"", "language": "curl" } ] } [/block] Many users, including Seven Bridges' own engineers, have developed wrappers for the API calls in Python, R, and bash. This allowed them to leverage scripting to complete a spectrum of analyses, ranging from batch processing of >5000 tasks to adapting complex processing workflows based on intermediate results. Today we are pleased to announce that Seven Bridges has created *official bindings* for the CGC API in **[Python](https://github.com/sbg/sevenbridges-python)** and **[R](https://github.com/sbg/sevenbridges-r)**. There are four key advantages of these bindings: 1. It is easier to start using the CGC API, with a minimal onboarding curve 2. The CGC API can be used via professionally _designed_ and _maintained_ software 3. The bindings are available through the expected channels 4. Seven Bridges can provide more thorough support for official bindings than bespoke wrappers created by each user Here we will focus on the Python bindings (the R bindings will have their own blog post soon). When using the CGC API, you should use an [authentication token](http://docs.cancergenomicscloud.org/docs/get-your-authentication-token) (available from the CGC), which encodes your credentials and permissions on the CGC. If you are issuing API calls from a script to make use of the Python or R bindings, you should, of course, avoid putting your authentication token into the code itself for security reasons. Instead, you can easily store your token for the CGC in a config file, .sbgrc which you should place in your home directory. Specify its contents as follows: [block:code] { "codes": [ { "code": "[cgc]\nauth-token = d9334f30ac64422aa22a1f929e0c2dfd\napi-url = https://cgc-api.sbgenomics.com/v2", "language": "text", "name": ".sbgrc" } ] } [/block] [block:callout] { "type": "success", "body": "If you have multiple user accounts on the CGC, list your credentials for each in the config file.", "title": "Storing multiple credentials" } [/block] Getting started with the Python bindings is simple. First install the library using `pip`: [block:code] { "codes": [ { "code": "pip install sevenbridges-python", "language": "shell", "name": "Install the bindings" } ] } [/block] Then use Python (either 2.6+ or 3) to create an object for your access credentials. The methods of this object will allow you to perform almost all CGC API calls. Here we again list all projects for the user: [block:code] { "codes": [ { "code": "python\nimport sevenbridges as sbg\n\n# User input: specify the platform you are using {cgc for the Cancer Genomics Cloud, sbg for the Seven Bridges Platform}\nc = sbg.Config(profile='cgc')\napi = sbg.Api(config=c)\n\n# list (up to) 50 projects\nprojects = api.projects.query()\n\nprint( 'List of project ids and names:')\nfor project in projects:\n print('%s \\t %s \\n' % (project.id, project.name))", "language": "python" } ] } [/block] The API language binding unleashes the full power of the CGC. Users can confidently build their own solutions as the method names are intuitively linked to functions. Additionally, these bindings reduce the frequency of errors because the syntax is more tightly controlled by the class definition. This will reduce failed API calls due to improper syntax, such as typos. We are supporting these new bindings through multiple avenues. First, the bindings are fully documented on [readthedocs](http://sevenbridges-python.readthedocs.io/en/latest/sevenbridges/). All source code is also available on [Github](https://github.com/sbg/sevenbridges-python). Finally, we have updated our repository of recipes (modular code snippets, designed to accomplish a single action) and tutorials (complete use-cases for the CGC) in order that the [main branch of the tutorials](https://github.com/sbg/okAPI/tree/master/Recipes/CGC) now uses the official Python wrapper. Importantly, in releasing the language bindings we have not changed the underlying API calls. So if you have your own wrappers and would like to keep using them, they will continue to work. Finally, we want to thank our users for their prior and continuing feedback. These bindings are the fruit of such feedback. Please keep reaching out to us at <a href="mailto:cgc@sbgenomics.com" target="blank">cgc@sbgenomics.com</a> so we can help you solve your problems even more efficiently.