Using REST Services

Comments Off on Using REST Services

A high-level introduction to using this technology.

Representational State Transfer (REST) is a software architecture and set of rules to allow easy communication between systems over the internet. It uses HTTP (or HTTPS) for this communication to talk to an internet address (specified by a Uniform Resource Identifier, URI) and was developed alongside this protocol. On one side there is a RESTful server providing data to anyone asking the right questions: GET, POST, PUT, DELETE along a specific term will send back data in a machine-readable format. The other side will often be a software / script that is collection data for a specific object. An example from our word of genomics could be: Find information for a specific gene, i.e. collect annotation (genomic location, expression data, disease links, etc.) from different databases using the common gene name.

A key concept is that the architecture is “stateless”, each query is independent of the previous one. This means that all queries more complex than a single check of a single object have to be constructed as part of a script that is checking the answers and constructing the next query based on these results. (This is in contract to the current artificial intelligence language models like ChatGPT, that “remember” the context of the “conversation” and you can build on previous answers.) For commercial products, there are often specific software libraries (APIs) to communicate with the provided REST server. This allows, e.g. the automation of specific tasks related to these products and the data they produce.

Results are usually provided in XML or JSON format. To test the basic idea or to test a specific server, the command-line tool curl can be used:

# verbose-print the data from this URL:
curl -v
# print response to a json file
curl -o out.json

For further testing and for developing quesry scripts, programs with a user interface might be more useful, examples are: Postman, Insomnia

Examples from our field of genomics: Alongside of other technologies like http (web) and Perl API access, the genome annotation system EnsEMBL has provided data via REST API Endpoints for a long time, allowing the automated retrieval of genetic information. Sequencing company Illumina Inc. makes use of REST, providing libraries e.g. for working with their products BaseSpace, Clarity LIMS and LRM. They also have a nice introduction to the REST concepts here.

Image by Gerd Altmann from Pixabay