### Configure Ensembl REST API Setup Source: https://github.com/ensembl/ensembl-rest/wiki/REST-Installation-and-Development Run Makefile.PL after installing dependencies to confirm the setup. ```bash perl Makefile.PL ``` -------------------------------- ### Catalyst Server Startup Output Source: https://github.com/ensembl/ensembl-rest/wiki/REST-Installation-and-Development Example output when the Catalyst server starts, indicating the version and the address where it is accepting connections. ```text 2012/09/05 11:01:54 (0) Catalyst.pm 1184> EnsEMBL::REST powered by Catalyst 5.90015 HTTP::Server::PSGI: Accepting connections at http://0:3000/ ``` -------------------------------- ### Install Faidx XS Library Source: https://github.com/ensembl/ensembl-rest/wiki/REST-Installation-and-Development Clone the faidx_xs repository and install the library using its Makefile. ```bash git clone --branch master --depth 1 https://github.com/Ensembl/faidx_xs.git (cd faidx_xs && perl Makefile.PL && make && make install) ``` -------------------------------- ### Install Ensembl REST API from Git Source: https://github.com/ensembl/ensembl-rest/wiki/REST-Installation-and-Development Clone the ensembl-rest repository from GitHub to get the latest stable release. ```bash git clone https://github.com/Ensembl/ensembl-rest.git ``` -------------------------------- ### Install Tabix Library Source: https://github.com/ensembl/ensembl-rest/wiki/REST-Installation-and-Development Download, compile, and install the Tabix library and its Perl bindings. ```bash wget https://github.com/samtools/tabix/archive/master.tar.gz tar zxf master.tar.gz (cd tabix-master && make) (cd tabix-master/perl && perl Makefile.PL && make) ``` -------------------------------- ### Python Request Example Source: https://github.com/ensembl/ensembl-rest/wiki/Scripting:-Request-Variables This snippet shows how to make a GET request using the requests library in Python. It defines server and extension strings and prints the response. ```python import requests, sys server = "https://rest.ensembl.org" ext = "/lookup/id/ENSG00000157764?expand=1" r = requests.get(server+ext, headers={ "Accept" : "application/json"}) pprint (r) ``` -------------------------------- ### R Request Example Source: https://github.com/ensembl/ensembl-rest/wiki/Scripting:-Request-Variables This snippet demonstrates making a GET request in R using the httr and jsonlite libraries. It constructs the URL from server and extension strings and displays the response. ```r library(httr) library(jsonlite) server <- "https://rest.ensembl.org" ext <- "/lookup/id/ENSG00000157764?expand=1" r <- GET(paste(server, ext, sep = ""), accept("application/json")) r ``` -------------------------------- ### Install Catalyst Runtime and Devel with CPANMINUS Source: https://github.com/ensembl/ensembl-rest/wiki/REST-Installation-and-Development Use cpanm to install Catalyst dependencies if using local::lib. ```bash cpanm Catalyst::Runtime Catalyst::Devel ``` -------------------------------- ### Install Ensembl REST API Dependencies with cpanm Source: https://github.com/ensembl/ensembl-rest/wiki/REST-Installation-and-Development Navigate to the ensembl-rest directory and install local dependencies using cpanm. ```bash cd ensembl-rest cpanm --installdeps . ``` -------------------------------- ### VEP Plugin Configuration Example Source: https://github.com/ensembl/ensembl-rest/blob/release/116/t/test-genome-DBs/testdata/vep_plugin_config.txt Defines the configuration for a VEP plugin, including its key, parameters, availability, and enabled status. This example shows the RestTestPlugin configuration. ```perl my $VEP_PLUGIN_CONFIG = { "plugins" => [ # test { "key" => "RestTestPlugin", "params" => [ '@*' ], "available" => 1, "enabled" => 0, }, ] }; ``` -------------------------------- ### GET Request - Accept Header Source: https://github.com/ensembl/ensembl-rest/wiki/Output-formats Shows how to specify the desired output format for a GET request using the 'Accept' HTTP header, which is the generally recommended method. ```APIDOC ## GET /info/ping ### Description Requests information about the API's status, allowing specification of the output format via the 'Accept' HTTP header. ### Method GET ### Endpoint http://rest.ensembl.org/info/ping ### Parameters #### Headers - **Accept** (string) - Required - Specifies the desired output format, e.g., `application/json`. ### Request Example ```bash curl -H "Accept: application/json" \ http://rest.ensembl.org/info/ping ``` ``` -------------------------------- ### Build and Run the Client Source: https://github.com/ensembl/ensembl-rest/wiki/Example-Java-Client-with-Unirest After placing the client code in the correct directory, use Maven to build an executable JAR and then run it from the command line. ```bash mvn clean compile assembly:single java -jar target/EnsemblRestClient-1.0-SNAPSHOT-jar-with-dependencies.jar ``` -------------------------------- ### GET Request with Optional Parameter and Content-Type Source: https://github.com/ensembl/ensembl-rest/wiki/Getting-Started Example of a GET request to the lookup/id endpoint, specifying the content type as JSON. This ensures the response is formatted in JSON. ```bash $ curl 'https://rest.ensembl.org/lookup/id/ENSG00000165029?expand=1' -H 'Content-type:application/json' ``` -------------------------------- ### GET Request with Optional Parameter Source: https://github.com/ensembl/ensembl-rest/wiki/Getting-Started Example of a GET request to the lookup/id endpoint with an optional 'expand' parameter. Use this to retrieve detailed information about a gene, including its transcripts, translations, and exons. ```bash $ curl 'https://rest.ensembl.org/lookup/id/ENSG00000165029?expand=1' ``` -------------------------------- ### Compile and Run Java Client Source: https://github.com/ensembl/ensembl-rest/wiki/Example-Java-Client Instructions for compiling the Java client with its dependency and running the application. Ensure the json-smart JAR is available. ```bash javac -cp json-smart-1.2.jar RestClient.java java -cp .:json-smart1.2.jar RestClient ``` -------------------------------- ### Basic Initialization with initHighlightingOnLoad Source: https://github.com/ensembl/ensembl-rest/blob/release/116/root/static/js/highlight/README.md Include the stylesheet and script, then call initHighlightingOnLoad to automatically highlight code within
tags on page load.
```html
```
--------------------------------
### Perl Request Example
Source: https://github.com/ensembl/ensembl-rest/wiki/Scripting:-Request-Variables
This snippet illustrates how to make a GET request in Perl using HTTP::Tiny and JSON. It defines server and extension variables and prints the request result.
```perl
use HTTP::Tiny;
use JSON;
my $http = HTTP::Tiny->new();
my $server = "https://rest.ensembl.org";
my $ext = "/lookup/id/ENSG00000157764?expand=1";
my $headers = { 'Accept' => 'application/json' };
my $r = $http->get($server.$ext, {headers => $headers});
print $r;
```
--------------------------------
### Configure Test Databases for Ensembl REST
Source: https://github.com/ensembl/ensembl-rest/wiki/REST-Installation-and-Development
Copy the example test database configuration file and edit it to set appropriate connection settings for running the test server.
```bash
cd ensembl-rest
cp t/MultiTestDB.conf.example t/MultiTestDB.conf
$EDITOR t/MultiTestDB.conf
```
--------------------------------
### GET Request - Content-Type Parameter
Source: https://github.com/ensembl/ensembl-rest/wiki/Output-formats
Illustrates specifying the output format for a GET request by appending it as a 'content-type' query parameter.
```APIDOC
## GET /info/ping
### Description
Requests information about the API's status, allowing specification of the output format via the 'content-type' query parameter.
### Method
GET
### Endpoint
http://rest.ensembl.org/info/ping
### Parameters
#### Query Parameters
- **content-type** (string) - Required - Specifies the desired output format, e.g., `application/json`.
### Request Example
```bash
curl http://rest.ensembl.org/info/ping?content-type=application/json
```
```
--------------------------------
### Download and Install Ensembl API from Tarball
Source: https://github.com/ensembl/ensembl-rest/wiki/REST-Installation-and-Development
Fetch the Ensembl API from the stable branch tarball and unpack it.
```bash
wget ftp://ftp.ensembl.org/pub/ensembl-api.tar.gz
tar zxvf ensembl-api.tar.gz
```
--------------------------------
### Specify JSON Output via Content-Type Parameter (GET)
Source: https://github.com/ensembl/ensembl-rest/wiki/Output-formats
Use the 'content-type' URL parameter to request JSON output for a GET request.
```bash
curl http://rest.ensembl.org/info/ping?content-type=application/json
```
--------------------------------
### Custom Initialization with highlightBlock and jQuery
Source: https://github.com/ensembl/ensembl-rest/blob/release/116/root/static/js/highlight/README.md
Iterate over code blocks using jQuery and apply highlighting individually with hljs.highlightBlock for more control over initialization.
```javascript
$(document).ready(function() {
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
})
```
--------------------------------
### Specify JSON Output via Content-Type Header (GET)
Source: https://github.com/ensembl/ensembl-rest/wiki/Output-formats
Use the 'Content-Type' HTTP header to request JSON output for a GET request.
```bash
curl -H "Content-Type: application/json" \
http://rest.ensembl.org/info/ping
```