{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "chem-bla-ics",
  "description": "Chemblaics (pronounced chem-bla-ics) is the science that uses open science and computers to solve problems in chemistry, biochemistry and related fields.",
  "home_page_url": "https://chem-bla-ics.linkedchemistry.info/",
  "feed_url": "https://chem-bla-ics.linkedchemistry.info/2013/10/30/programming-in-life-sciences-9-apis-and.json",
  "icon": "https://chem-bla-ics.linkedchemistry.info/assets/images/chem-bla-ics_logo.png",
  "language": "en",
  "authors": [
    {
      "name": "Egon Willighagen",
      "url": "https://orcid.org/0000-0001-7542-0286",
      "_orcid": "0000-0001-7542-0286"
    }
  ],
  "items": [

    {
      "id": "https://doi.org/10.59350/7skws-4f170",
      "url": "https://chem-bla-ics.linkedchemistry.info/2013/10/30/programming-in-life-sciences-9-apis-and.html",
      "title": "Programming in the Life Sciences #9: APIs and Web Services",
      "content_html": "<p>Continuing on the <a href=\"http://chem-bla-ics.blogspot.nl/2013/10/exercise-what-variable-type-would-you.html\">theory</a>\n<a href=\"http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-8-coding.html\">covered</a> in this course,\nthis part will talk about <a href=\"https://en.wikipedia.org/wiki/Application_programming_interface\">application programming interfaces</a>\n(APIs) and <a href=\"https://en.wikipedia.org/wiki/Web_service\">web services</a>.</p>\n\n<h2 id=\"application-programming-interfaces\">Application Programming Interfaces</h2>\n\n<p>APIs define how programs can be used by other programs. An API defines how methods are called and what feedback\nyou can expect. It basically is the combination of documentation and the program itself. But, unlike any piece\nof software, an API is aimed at users, rather than use in the same program. The API is how you communicate\nbetween programs.</p>\n\n<p>Now, in this course we will see two key types of APIs. The first are the APIs provided by the libraries that we\nuse. For example, we already indicated that we will be using at least the following two libraries,\n<a href=\"http://chem-bla-ics.blogspot.nl/2013/10/programming-in-life-sciences-8-coding.html\">ops.js and d3.js</a>.\nThese libraries are a collection of functional bits (e.g. classes and methods). For example, ops.js\ndefines an API which wraps closely the <a href=\"https://dev.openphacts.org/docs\">Open PHACTS Linked Data API</a>\n(LDA) itself. The API requires as to do a few things: 1. create a wrapper for the LDA; 2. define a\ncall back function; 3. invoke the actual</p>\n\n<div class=\"language-javascript highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nx\">call</span><span class=\"p\">.</span><span class=\"kd\">var</span> <span class=\"nx\">searcher</span> <span class=\"o\">=</span> <span class=\"k\">new</span> <span class=\"nx\">Openphacts</span><span class=\"p\">.</span><span class=\"nc\">ConceptWikiSearch</span><span class=\"p\">(</span>\n  <span class=\"dl\">\"</span><span class=\"s2\">https://beta.openphacts.org</span><span class=\"dl\">\"</span><span class=\"p\">,</span> <span class=\"nx\">appID</span><span class=\"p\">,</span> <span class=\"nx\">appKey</span>\n<span class=\"p\">);</span>  \n<span class=\"kd\">var</span> <span class=\"nx\">callback</span><span class=\"o\">=</span><span class=\"kd\">function</span><span class=\"p\">(</span><span class=\"nx\">success</span><span class=\"p\">,</span> <span class=\"nx\">status</span><span class=\"p\">,</span> <span class=\"nx\">response</span><span class=\"p\">){</span>  \n    <span class=\"nx\">searcher</span><span class=\"p\">.</span><span class=\"nf\">parseResponse</span><span class=\"p\">(</span><span class=\"nx\">response</span><span class=\"p\">);</span>\n<span class=\"p\">};</span>  \n<span class=\"nx\">searcher</span><span class=\"p\">.</span><span class=\"nf\">findCompounds</span><span class=\"p\">(</span><span class=\"dl\">'</span><span class=\"s1\">Aspirin</span><span class=\"dl\">'</span><span class=\"p\">,</span> <span class=\"dl\">'</span><span class=\"s1\">20</span><span class=\"dl\">'</span><span class=\"p\">,</span> <span class=\"dl\">'</span><span class=\"s1\">4</span><span class=\"dl\">'</span><span class=\"p\">,</span> <span class=\"nx\">callback</span><span class=\"p\">);</span>\n</code></pre></div></div>\n\n<h2 id=\"web-services\">Web Services</h2>\n\n<p>Web services are a special kind of APIs: they expose an API over the web. That imposes some features of\nthese APIs: first, they are based on a web transport layer, commonly\n<a href=\"https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol\">HTTP</a>, but\n<a href=\"https://en.wikipedia.org/wiki/Xmpp\">XMPP</a> is possible too. HTTP is used by your web browser too. Secondly,\nthe web server needs a common communication language to serialize the method call. Here, two key standards\nare used, <a href=\"https://en.wikipedia.org/wiki/XML\">XML</a> and <a href=\"https://en.wikipedia.org/wiki/JSON\">JSON</a>.\nWe will cover these in more detail later. For now, it suffices to think of these as\nenvelopes in which are message is sent. Now, another aspect standardized is how to call the web services.\nFor that, <a href=\"https://en.wikipedia.org/wiki/SOAP\">SOAP</a> and <a href=\"https://en.wikipedia.org/wiki/REST\">REST</a> are\nthe most important standards for the life sciences (though I still think\n<a href=\"http://www.biomedcentral.com/1471-2105/10/279\">Wagener’s XMPP approach</a> is still\nworthwhile checking out!). SOAP and REST use XML and JSON are underlying serialization format.</p>\n\n<p>So, web services are theoretically complex. For this course, most of it is hidden by the client library that will take care of the HTTP and SOAP/REST layers. The students who wish to use Java instead of JavaScript, will face the problem that you first need to find a Java client library for the LDA. There is this library, but that needs exploring for use with the latest Open PHACTS LDA. Higher stakes, higher rewards.</p>\n\n<h2 id=\"take-home-message\">Take home message</h2>\n\n<p>Practically, you do not need to know much of the technologies behind web services, just like you do not need to know machine instructions CPUs follow to run your program. But, it is important to have seen these terms. You will run into them, and need enough context to know where and how to find answers to the questions that you will have.</p>\n\n<p>There is one exception: JavaScript Object Notation, JSON. That is the format in which the data is returned by the service, and you will have to handle that. JSON will be the topic of the next post.</p>\n\n<h4>References</h4>\n<div class=\"csl-bib-body\">\n    <div class=\"csl-entry\">Wagener, J., Spjuth, O., Willighagen, E. L., &#38; Wikberg, J. E. (2009). XMPP for cloud computing in bioinformatics supporting discovery and invocation of asynchronous web services. <i>BMC Bioinformatics</i>, <i>10</i>(1). https://doi.org/10.1186/1471-2105-10-279 <a href=\"https://doi.org/10.1186/1471-2105-10-279\">CrossRef</a> <a href=\"https://qlever.scholia.wiki/doi/10.1186/1471-2105-10-279\">Scholia</a></div>\n  </div>",
      "summary": "Continuing on the theory covered in this course, this part will talk about application programming interfaces (APIs) and web services.",
      
      "date_published": "2013-10-30T00:00:00+00:00",
      "date_modified": "2025-02-16T00:00:00+00:00",
      "tags": ["pra3006"],
      "_references": [
        
          
          
            { "url": "https://doi.org/10.1186/1471-2105-10-279", "doi": "10.1186/1471-2105-10-279"
             }
            
          
        ],
      
      
      
      
      
      
        "authors": [ { "name": "Egon Willighagen", "url": "https://orcid.org/0000-0001-7542-0286" } ]
      
    }

  ]
}
