BioPortal REST services

From NCBO Wiki
(Redirected from NCBO REST services)
Jump to: navigation, search

The list below documents the NCBO Web services. For questions on how to use these Web services or to request features, contact Support.

The prefix for all production service URLs in the table below is rest.bioontology.org/

  • Note: All NCBO Web services will be required to contain the parameter "apikey=YourApiKey" starting June 2011. The parameter will be added to all Web service calls for the April 27, 2011 release but will not be required until June 2011. To obtain an API key, login to BioPortal and go to "Account" where your API key will be displayed. The addition of the API key replaces the use of the email parameter.
  • Note for Application Developers: Application developers will also need to include the apikey parameter on all NCBO Web service calls. This allows us to track usage of our system at the level of an application. To obtain an API key, login to BioPortal and go to "Account" where your API key will be displayed. The addition of the API key replaces the use of the email parameter.
  • Note: Signatures for BioPortal services have changed in BioPortal 2.0.4 release on January 13th, 2009. This page has the new service URLs.

Contents

  • 1 Overview - Using NCBO Technology in Your Project
  • 2 Sample Code Cookbook
  • 3 BioPortal Announce Mailing List
  • 4 Service Output Formats
  • 5 Services to access ontologies and ontology versions
    • 5.1 List all the latest version of ontologies
    • 5.2 Get a specific ontology based on a version id
    • 5.3 Download an ontology file
    • 5.4 Download the latest ontology file
    • 5.5 Get all versions of an ontology from a virtual ontology id
    • 5.6 Get latest version of an ontology id
    • 5.7 Get Metrics for an ontology version
    • 5.8 Get all the namespace prefixes for an ontology version
    • 5.9 List all ontology categories
    • 5.10 List all ontology groups
  • 6 Services to access ontology views and ontology view versions
    • 6.1 Download a specific ontology view based on the ontology view version id
    • 6.2 Get all view versions of a virtual view
    • 6.3 List the latest version of all Views
    • 6.4 Get all versions of views from a virtual ontology id
  • 7 Search services
    • 7.1 Search BioPortal
  • 8 Term services
    • 8.1 Get term, including its properties, subclasses, and superclasses
    • 8.2 Get all root terms for an ontology version id
    • 8.3 Get a path between a term and the root
    • 8.4 Get all terms using the specific ontology version id
    • 8.5 Get all terms using the virtual ontology id
    • 8.6 Changes to the Get all terms service
  • 9 View Extraction Service
  • 10 Property Services
    • 10.1 Get all available ontology properties using the specific ontology version id
  • 11 Instance Services
    • 11.1 Get all direct instances for a given term
    • 11.2 Get an instance and its property/value pairs
  • 12 Hierarchy Services
    • 12.1 Get paths to root/leaves from a concept in the latest version of a given ontology
  • 13 Bio2RDF Dump Service
  • 14 Annotator Service
  • 15 Ontology Recommender
  • 16 Resource Index Service
  • 17 RDF Term Service
  • 18 RDF Download Service
  • 19 Notes Service (Term Proposals and Comments)
  • 20 Mapping Service
  • 21 XML Schema Definitions for the REST services

Overview - Using NCBO Technology in Your Project

See Using NCBO Technology in your Project for general information and widgets available for use.

Sample Code Cookbook

  • Examples of using the Web services in sample code can be found here
    • Sample code is located within the NCBO Gforge repository and can be checked out via anonymous SVN access
  • Code examples for the Annotator and Resource Index are located on the pages documenting these Web services
  • Code examples for the ontology web services, developed in FlexViz, is available at: https://bmir-gforge.stanford.edu/gf/project/flexviz/frs/?action=index. To see the code in action, visit the Test User Interface that has been set-up using the FlexViz code.

BioPortal Announce Mailing List

To receive notices of new BioPortal releases, changes to web services, or planned downtime subscribe to the bioportal-annouce list.

Service Output Formats

JSON output scheduled for mid-December release Currently, BioPortal services allow for two output formats: XML (default) and JSON (currently works only for ontology and concept services).

  • XML: no special parameters required. This is the default REST services output format. It assumes the media type as application/xml.
  • JSON: requires an "Accept" request-header with the following value: application/json.

If both application/xml and application/json media types are present in the Accept header, the output format will be determined based on the higher "q" parameter indicating a relative quality factor of each media type. For more info, please refer to: www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

NOTE: JSON output is currently not available for Annotator Service.

Services to access ontologies and ontology versions

List all the latest version of ontologies

  • Description: Return a list of ontologies in BioPortal. To get information on Ontology Views, use the "List the latest version of all Views" Web service call.
  • Signature: ./ontologies?apikey={YourAPIKey}
  • Example: rest.bioontology.org/bioportal/ontologies?apikey=YourAPIKey
    • NOTE: The element <id> contains the value for the ontology version identifier.

Get a specific ontology based on a version id

  • Signature: ./ontologies/{ontology version id}?apikey={YourAPIKey}
  • Example: rest.bioontology.org/bioportal/ontologies/39002?apikey=YourAPIKey

Download an ontology file

  • Description: Download the file (.obo, .owl) corresponding to the given ontology version id.
  • Signature: ./ontologies/download/{ontology version id}?email={email_address}
  • Example: rest.bioontology.org/bioportal/ontologies/download/39002?apikey=YourAPIKey
  • Note: File downloads can include zip archives. Where multiple files are included in the archive, BioPortal uses the following algorithm to determine the primary file: 1) look for a file named the same as the archive with a different extension (IE .owl instead of .zip) and 2) if no similarly-named file exists, use the first file in the list when sorted alphabetically.

Download the latest ontology file

  • Description: Download the file (.obo, .owl) corresponding to the given virtual ontology id.
  • Signature: ./virtual/download/{ontology id}?email={email_address}
  • Example: rest.bioontology.org/bioportal/virtual/download/1090?apikey=YourAPIKey

Get all versions of an ontology from a virtual ontology id

  • Signature: ./ontologies/versions/{ontology id}?apikey={YourAPIKey}
  • Example: rest.bioontology.org/bioportal/ontologies/versions/1104?apikey=YourAPIKey
  • Note: File downloads can include zip archives. Where multiple files are included in the archive, BioPortal uses the following algorithm to determine the primary file: 1) look for a file named the same as the archive with a different extension (IE .owl instead of .zip) and 2) if no similarly-named file exists, use the first file in the list when sorted alphabetically.

Get latest version of an ontology id

  • Signature: ./virtual/ontology/{ontology_id}?apikey={YourAPIKey}
  • Example: rest.bioontology.org/bioportal/virtual/ontology/1104?apikey=YourAPIKey

Get Metrics for an ontology version

  • Signature: ./ontologies/metrics/{ontology version id}?apikey=YourAPIKey
  • Example: rest.bioontology.org/bioportal/ontologies/metrics/40133?apikey=YourAPIKey
  • More documentation: www.bioontology.org/wiki/index.php/Ontology_Metrics

Get all the namespace prefixes for an ontology version

  • Signature: ./ontologies/namespaces/{ontology version id}?apikey=YourAPIKey
  • Example: rest.bioontology.org/bioportal/ontologies/namespaces/44450?apikey=YourAPIKey

List all ontology categories

  • Signature: ./categories?apikey=YourAPIKey
  • Example: rest.bioontology.org/bioportal/categories?apikey=YourAPIKey

List all ontology groups

  • Signature: ./groups?apikey=YourAPIKey
  • Example: rest.bioontology.org/bioportal/groups?apikey=YourAPIKey

Services to access ontology views and ontology view versions

Since all the views on ontologies are ontologies themselves all the services that work on ontologies do work for ontology views also with the same signature.

Download a specific ontology view based on the ontology view version id

  • Signature: ./ontologies/download/{ontology version id}?apikey={YourAPIKey}
  • Example: rest.bioontology.org/bioportal/ontologies/download/43072?apikey=YourAPIKey
  • Note: File downloads can include zip archives. Where multiple files are included in the archive, BioPortal uses the following algorithm to determine the primary file: 1) look for a file named the same as the archive with a different extension (IE .owl instead of .zip) and 2) if no similarly-named file exists, use the first file in the list when sorted alphabetically.

Get all view versions of a virtual view

  • Signature: ./ontologies/versions/{ontology id}?apikey={YourAPIKey}
  • Example: rest.bioontology.org/bioportal/ontologies/versions/2070?apikey=YourAPIKey


However, there are a few Web services that are distinct for views.

List the latest version of all Views

  • Signature: ./views?apikey={YourAPIKey}
  • Example: rest.bioontology.org/bioportal/views?apikey=YourAPIKey

Get all versions of views from a virtual ontology id

  • Description: Returns all versions of views defined on the latest version a virtual ontology, grouped by virtual view ids.
  • Signature: ./views/versions/{ontology id}?apikey={YourAPIKey}
  • Example: rest.bioontology.org/bioportal/views/versions/1104?apikey=YourAPIKey

Search services

Search BioPortal

  • Signature: ./search/?query={uri-encoded query}[&{optional args}]&apikey={YourAPIKey}
  • Deprecated Signature: ./search/{query}[?{optional args}]&apikey={YourAPIKey}
  • Example: rest.bioontology.org/bioportal/search/?query=Gene&apikey=YourAPIKey
  • Boolean Search Options:
    • () parentheses allow to enclose multiple terms joined by OR
      • Example: "(foo bar)" will expand to "foo* OR bar*"
    • - the minus sign preceding a term indicates NOT
      • Example: "foo bar -baz" will expand to "foo* AND bar* AND NOT baz*"
    • No prefix means MUST (required).
  • Optional Arguments:
    • >
    • isexactmatch=[1/0] – match the entire concept name (default: 0)
    • includeproperties=[1/0] – include attributes in the search (default: 0 and includes the preferred name, term identifier, and synonym properties)
    • pagesize=<pagesize> - the number of results to display in a single request (default: all)
    • pagenum=<pagenum> - the page number to display (pages are calculated using <total results>/<pagesize>) (default: 1)
    • maxnumhits=<maxnumhits> - the maximum number of top matching results to return (default: 1000)
    • subtreerootconceptid=<uri-encoded conceptid> - narrow the search to concepts residing in a sub-tree, where the "subtreerootconceptid" is the root node. This feature requires a SINGLE <ontologyid> passed in using the "onotlogyids" parameter.
    • objecttypes=<class,individual,property> - limits the results returned to these types, multitple types can be included in the parameter, e.g. class,individual.
    • includedefinitions={true} - if a search result is a hit for a term, adding this parameter will include the definition in the search result xml. Note: Including the definition results in a slight performance hit.
  • Description:

The search attempts to match both partial and exact queries, giving more weight to exact matches. In single-word searches, the wildcard character (*) is automatically appended to the end of the word. For example, searching for "lun" would return all concepts whose name contains a word that begins with "lun" (i.e. "Lung", "Murine Lunate Bone", "Base of the Lung", etc).

In phrase searches (multiple words), the wildcard character is appended to the end of each word. For example, searching for "cut mela" would return all concepts whose name contains a word starting with "cut", followed by any word that begins with "mela" (i.e. "Cutaneous Melanoma", "Metastatic Non-Cutaneous Melanoma", "Cutaneous Melanoma Clinical TNM Finding", etc).

  • Field Values
    • The '<recordType></recordType>' entries can be: PREFERRED_NAME = "apreferredname", CONCEPT_ID = "bconceptid", SYNONYM = "csynonym", and PROPERTY = "dproperty".
    • The '<objectType></objectType>' entries are concept types, which can be: "class", "property", or "individual".
  • Example: rest.bioontology.org/bioportal/search/?query=Gene&ontologyids=1032&isexactmatch=1&apikey=YourAPIKey
  • Sample Output:
<?xml version="1.0" encoding="UTF-8"?>
<success>
  <accessedResource>/bioportal/search/</accessedResource>
  <accessDate>2012-07-06 10:31:44.413 PDT</accessDate>
  <data>
    <page>
      <pageNum>1</pageNum>
      <numPages>1</numPages>
      <pageSize>2</pageSize>
      <numResultsPage>2</numResultsPage>
      <numResultsTotal>2</numResultsTotal>
      <contents class="org.ncbo.stanford.bean.search.SearchResultListBean">
        <searchResultList>
          <searchBean>
            <ontologyVersionId>47638</ontologyVersionId>
            <ontologyId>1032</ontologyId>
            <ontologyDisplayLabel>NCI Thesaurus</ontologyDisplayLabel>
            <recordType>apreferredname</recordType>
            <objectType>class</objectType>
            <conceptId>ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#Gene</conceptId>
            <conceptIdShort>Gene</conceptIdShort>
            <preferredName>Gene</preferredName>
            <contents>Gene</contents>
            <isObsolete>0</isObsolete>
          </searchBean>
          <searchBean>
            <ontologyVersionId>47638</ontologyVersionId>
            <ontologyId>1032</ontologyId>
            <ontologyDisplayLabel>NCI Thesaurus</ontologyDisplayLabel>
            <recordType>csynonym</recordType>
            <objectType>class</objectType>
            <conceptId>ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#Gene_Object</conceptId>
            <conceptIdShort>Gene_Object</conceptIdShort>
            <preferredName>Gene Object</preferredName>
            <contents>Gene</contents>
            <isObsolete>1</isObsolete>
          </searchBean>
        </searchResultList>
        <ontologyHitList>
          <ontologyHitBean>
            <ontologyVersionId>47638</ontologyVersionId>
            <ontologyId>1032</ontologyId>
            <ontologyDisplayLabel>NCI Thesaurus</ontologyDisplayLabel>
            <numHits>2</numHits>
          </ontologyHitBean>
        </ontologyHitList>
        <numHitsTotal>3</numHitsTotal>
      </contents>
    </page>
  </data>
</success>

Term services

(formerly referred to as Concept services)

Get term, including its properties, subclasses, and superclasses

  • Signature: ./concepts/{ontology version id}/{concept id}?apikey={YourAPIKey}
  • Alt Signature: ./concepts/{ontology version id}?conceptid={uri-encoded concept id}&apikey={YourAPIKey}
  • Virtual Signature (always uses most recent version of the ontology): ./virtual/ontology/{ontology id}/{concept id}&apikey={YourAPIKey}
  • Alt Virtual Signature (always uses most recent version of the ontology): ./virtual/ontology/{ontology id}?conceptid={uri-encoded concept id}
    • To ensure that the Web service works within your application, use the Alt signature as some ontologies may contain terms where the concept id is a URI.
  • Optional arguments:
    • light=[1/0] - when set to 1, returns the "light" version of XML with only a basic info for the concept and its immediate children
    • norelations=[1/0] - when set to 1, returns only the requested term information (id, label, fullid, type, synonyms, definitions) without the "relations" map. This is useful when you need to quickly retrieve just the base information about a term.
    • maxnumchildren - an integer that sets threshold on the number of children in the SubClass relation for a term. If a term contains more children than the "maxnumchildren", the SubClass relation returns an empty list. The ChildCount relation still contains the correct number of children.

Examples using Alt Signature

  • rest.bioontology.org/bioportal/concepts/44103?conceptid=O80-O84.9&apikey=YourAPIKey
  • rest.bioontology.org/bioportal/concepts/44450?conceptid=BRO:Software&apikey=YourAPIKey

Examples using Alt Virtual Signature

  • rest.bioontology.org/bioportal/virtual/ontology/1516?conceptid=O80-O84.9&apikey=YourAPIKey
  • rest.bioontology.org/bioportal/virtual/ontology/1104?conceptid=BRO:Software&apikey=YourAPIKey


  • Sample Output:
<?xml version="1.0" encoding="UTF-8"?>
<success>
  <accessedResource>/bioportal/concepts/44103</accessedResource>
  <accessDate>2010-12-08 16:57:43.763 PST</accessDate>
  <data>
    <classBean>
      <id>O80-O84.9</id>
      <fullId>purl.bioontology.org/ontology/ICD10/O80-O84.9</fullId>

      <label>Delivery</label>
      <type>Class</type>
      <relations>
        <entry>
          <string>SubClass</string>
          <list>
            <classBean>

              <id>O84</id>
              <fullId>purl.bioontology.org/ontology/ICD10/O84</fullId>
              <label>Multiple delivery</label>
              <type>Class</type>
              <relations>
                <entry>
                  <string>ChildCount</string>

                  <int>5</int>
                </entry>
              </relations>
            </classBean>
            <classBean>
              <id>O83</id>
              <fullId>purl.bioontology.org/ontology/ICD10/O83</fullId>

              <label>Other assisted single delivery</label>
              <type>Class</type>
              <relations>
                <entry>
                  <string>ChildCount</string>
                  <int>7</int>
                </entry>

              </relations>
            </classBean>
            <classBean>
              <id>O82</id>
              <fullId>purl.bioontology.org/ontology/ICD10/O82</fullId>
              <label>Single delivery by caesarean section</label>
              <type>Class</type>

              <relations>
                <entry>
                  <string>ChildCount</string>
                  <int>5</int>
                </entry>
              </relations>
            </classBean>
            <classBean>

              <id>O81</id>
              <fullId>purl.bioontology.org/ontology/ICD10/O81</fullId>
              <label>Single delivery by forceps and vacuum extractor</label>
              <type>Class</type>
              <relations>
                <entry>
                  <string>ChildCount</string>

                  <int>6</int>
                </entry>
              </relations>
            </classBean>
            <classBean>
              <id>O80</id>
              <fullId>purl.bioontology.org/ontology/ICD10/O80</fullId>

              <label>Single spontaneous delivery</label>
              <type>Class</type>
              <relations>
                <entry>
                  <string>ChildCount</string>
                  <int>4</int>
                </entry>

              </relations>
            </classBean>
          </list>
        </entry>
        <entry>
          <string>PAR</string>
          <list>
            <classBean>

              <id>O00-O99.9</id>
              <fullId>purl.bioontology.org/ontology/ICD10/O00-O99.9</fullId>
              <label>Pregnancy, childbirth and the puerperium</label>
              <type>Class</type>
              <relations>
                <entry>
                  <string>ChildCount</string>

                  <int>8</int>
                </entry>
              </relations>
            </classBean>
          </list>
        </entry>
        <entry>
          <string>ChildCount</string>

          <int>5</int>
        </entry>
        <entry>
          <string>Semantic_Type</string>
          <list>
            <string>Therapeutic or Preventive Procedure</string>
          </list>

        </entry>
        <entry>
          <string>TUI</string>
          <list>
            <string>T061</string>
          </list>
        </entry>
        <entry>

          <string>UMLS_CUI</string>
          <list>
            <string>C0011209</string>
          </list>
        </entry>
        <entry>
          <string>SuperClass</string>

          <list>
            <classBean>
              <id>O00-O99.9</id>
              <fullId>purl.bioontology.org/ontology/ICD10/O00-O99.9</fullId>
              <label>Pregnancy, childbirth and the puerperium</label>
              <type>Class</type>
              <relations>

                <entry>
                  <string>ChildCount</string>
                  <int>8</int>
                </entry>
              </relations>
            </classBean>
          </list>
        </entry>

      </relations>
    </classBean>
  </data>
</success>

Get all root terms for an ontology version id

  • Signature: ./concepts/{ontology version id}/root?apikey={YourAPIKey}
  • Example: rest.bioontology.org/bioportal/concepts/39002/root?apikey=YourAPIKey

Get a path between a term and the root

  • Signature: ./path/{ontology_version_id}/?source={concept1_id}&target=root&apikey=YourAPIKey
  • Example: rest.bioontology.org/bioportal/path/42838/?source=Transitional_Epithelium&target=root&apikey=YourAPIKey
  • Note: If there is no path between the specified term and the set of nodes designated as "roots" then this method just returns the root node. Note that "root" here is defined as a set of classes which have been designated as "roots". It is not defined as a node which as no parents.
  • Note: This service only returns a single path between a term and the root. There is a service that returns all paths from a term to the root for most ontologies. Alternatively, all paths can be calculated by recursively calling the term service.

Get all terms using the specific ontology version id

NOTE: 'Get all terms' service has changed. The new signature and examples are reflected below. See #Changes_to_the_Get_all_terms_service for more information.

  • Signature: ./concepts/{ontology version id}/all?pagesize={pagesize}&pagenum={pagenum}&apikey={YourAPIKey}
  • Examples:
    • rest.bioontology.org/bioportal/concepts/40644/all?pagesize=50&pagenum=1&apikey=YourAPIKey
    • rest.bioontology.org/bioportal/concepts/42431/all?pagesize=50&pagenum=500&apikey=YourAPIKey
  • Arguments:
    • pagesize: An integer limiting how many results will be returned on a single page (a 'page' is equivalent to a single call to the REST service)
    • pagenum: An integer indicating which page of results to return.
    • maxnumchildren: An integer that sets threshold on the number of children in the SubClass relation for a term. If a term contains more children than the "maxnumchildren", the SubClass relation returns an empty list. The ChildCount relation still contains the correct number of children.

Get all terms using the virtual ontology id

NOTE: 'Get all terms' service has changed. The new signature and examples are reflected below. See #Changes_to_the_Get_all_terms_service for more information.

  • Signature: ./virtual/ontology/{ontology id}/all?pagesize={pagesize}&pagenum={pagenum}&apikey={YourAPIKey}
  • Example: rest.bioontology.org/bioportal/virtual/ontology/1104/all?&pagesize=50&pagenum=1&apikey=YourAPIKey
  • Arguments:
    • pagesize: An integer limiting how many results will be returned on a single page (a 'page' is equivalent to a single call to the REST service)
    • pagenum: An integer indicating which page of results to return.
    • maxnumchildren: An integer that sets threshold on the number of children in the SubClass relation for a term. If a term contains more children than the "maxnumchildren", the SubClass relation returns an empty list. The ChildCount relation still contains the correct number of children.

Changes to the Get all terms service

Starting in BioPortal 2.3.1 (released March 15, 2010), the 'Get all terms' service has changed to support speedier and more complete term retrieval. To support this, several changes to the response XML and service signature are being made. Please see the following notes to update your existing applications to support these changes.

  • Examples: A preview of the new service can be seen on the NCBO staging site:
    • rest.bioontology.org/bioportal/concepts/40644/all?pagesize=50&pagenum=1
    • rest.bioontology.org/bioportal/concepts/42431/all?pagesize=50&pagenum=500
  • Signature
    • New parameters: Previously, offset and limit were used to control pagination of results. These parameters have been replaced as follows:
      • pagesize: An integer limiting how many results will be returned on a single page (a 'page' is equivalent to a single call to the REST service)
      • pagenum: An integer indicating which page of results to return.
      • maxnumchildren: An integer that sets threshold on the number of children in the SubClass relation for a term. If a term contains more children than the "maxnumchildren", the SubClass relation returns an empty list. The ChildCount relation still contains the correct number of children.
  • Response: The structure of the new 'Get all terms' response XML has been brought into line with other BioPortal REST term services. In addition, to assist in paging through result sets, 'page' metadata is provided. A list of classBeans is provided in the classBeanResultList element, which includes each classes' set of relations (examples of relations include SuperClass, SubClass, and rdfs:label). Please see the example below for a full demonstration of the new response.

View Extraction Service

  • This web service can be used to extract a subtree from an ontology. See View Extraction for usage details.

Property Services

Get all available ontology properties using the specific ontology version id

  • Signature: ./ontologies/properties/{ontlogyVersionId}?apikey={YourAPIKey}
  • Example: rest.bioontology.org/bioportal/ontologies/properties/38801?apikey=YourAPIKey
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.