New SecurityTrails API integration with R programming language
Reading time: 5 minutesSince our beginning, we always believed that a good API service was fundamental to offer the best possible solution for developers and entrepreneurs.
Integrating the SecurityTrails toolkit is pretty easy, and that's why in such a short time we've seen many [SDKs and integrations][integrations] working in production with different programming languages, such as NodeJS, Python or Ruby.
Today we are excited to show you a new API integration, this time with the R programming language by Bob Rudis from Rapid7, that is already available over Github at Github.com/hrbrmstr/securitytrails.
For all those who don't know it, R is a free programming language specialized in statistical computing and graphics processing. It's a GNU-based project mostly used inside the data mining, statistical computing, and data scientists community.
This new integration offers a set of quick tools to query the SecurityTrails API, and get valuable information about domains, DNS, hostnames, and IP addresses in one single place.
Supported methods
As the integration is based in our API, the supported query methods are the ones we provide in our API endpoints.
The available methods mostly take 2 parameters, one of them should be the API. If you have any doubts when you are going to test it, just type in the empty method, and it'll tell you which parameters are supported.
You will be able to perform the following actions:
- st_assoc_domains: Find associated domains
- st_dns_history: DNS history by record type
- st_domain: Get Domain information
- st_domain_search: Search Domain (Filter strings)
- st_explore_ips: Explore IPs
- st_ping: Test Access To the SecurityTrails API
- st_subdomains: List Subdomains
- st_tags: List Tags
- st_whois: Get WHOIS
- st_whois_history: WHOIS history by domain
- trails_api_key: Get or set SECURITYTRAILS_API_KEY value
Installing the new integration
R is a multi-platform language that supports Linux, FreeBSD, Windows and MacOS operating systems.
This time we will be reviewing the installation process for the most popular Linux distributions.
Installing on Ubuntu/Debian based distros
If you are using Ubuntu (our testing environment was with 16.04 Xenial, but it should work in the latest version as well) follow this steps:
Add the R repo to your sources.list file:
sudo nano /etc/apt/sources.list
→ deb https://cloud.r-project.org/bin/linux/ubuntu xenial/
Add the apt-key, so you can pull from upper repo without problems:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
Then run a routine update and install the r-base package:
sudo apt-get update
sudo apt-get install r-base
Other required dependencies you may want to install to avoid any SSL based errors
sudo apt-get install libcurl4-openssl-dev libssl-dev
Installing on Fedora/CentOS
Unlike Ubuntu, the latest Fedora version already includes R in their base-repo, so you don't have any need to install 3rd party repositories.
Install the R package with yum or DNF, as you see below:
yum install -y R
This will install R along with all the needed dependencies.
To avoid SSL errors, some manual dependencies must be installed as well:
yum install libcurl-devel openssl-devel -y
Installing the SecurityTrails R library
This applies for both Ubuntu/Debian and Fedora/CentOS platforms:
Open a new terminal window
Type R
and this will take you to the R CLI. If you want to exit the CLI at any time, just type: q()
Now install some required packages from the R CLI:
install.packages("devtools")
It may ask you to choose the fastest mirror around your location, you should see something like this:

At this point, you should be ready to install the SecurityTrails R library
You can use either this:
devtools::install_git("[https://gitlab.com/hrbrmstr/securitytrails.git][11]")
Or this method:
devtools::install_github("hrbrmstr/securitytrails")
The output should be something like this:

Once the library installation has been done, you can load it by running:
library(securitytrails)
Check if it's loaded correcty, the version should be 0.1.0
packageVersion("securitytrails")
Expected output:
> library(securitytrails)
> packageVersion("securitytrails")
[1] '0.1.0'
>
All done, now you are ready to go.
Testing against our API
We tested this integration with google.com domain name by using the st_subdomains API endpoint, as you see below.
Inside the R CLI, type:
st_subdomains("www.google.com", "YOUR.API.KEY")
As you see below, you will get a response with all the Google.com subdomain names:

Or if you want to perform another query, for example against the Domain general information, you can do it by running this command:
st_domain("www.google.com", trails_key = "YOUR.API.KEY")

As you can see, querying the ST API from R is pretty easy, and allows you to integrate our DNS, IP and domain information database with your statistical research in no time.
Do you want to integrate your apps with the SecurityTrails API?
Don't lose any time, grab a free API account today and start writing your own integration with our powerful Domain, IP and DNS API.
If you need any additional information, or you are interested about getting custom solutions for data enrichment and intel gathering from our platform, we can build custom plans in no time, get in touch with us.
