Note: The audio version doesn't include code or commands. Those parts of the post can be seen in the text version.
An api can be accessed in different ways, via your browser or your command line, but the easiest way is by using an api wrapper. While api access points may change over time, using an api wrapper will ensure the way you call the api always remains the same in your code.
Today we're excited to announce the immediate availability of a new Securitytrails api wrapper, and this time it's written in php, one of the most popular programming languages powering a big part of the Internet. This wrapper was written by Arjit Chaudary, one of the new technical writers who has recently joined the Securitytrails team.
Supported functions
Note: most of these functions require only 1 parameter.
At the time of this writing, this php wrapper supports 17 functions; we'll list the main ones here:
getdomain
The getdomain api call is used to return current data about the domain queried. For example, the getdomain api call returns how many domains are bound to the same IP address as well.
getsubdomain
The getsubdomain api call is used to return all subdomains which are found to be associated with a domain.
getdomainwhois
The getdomainwhois api call is used to return the domain Whois details, such as domain owner, registry date, expiry date, etc.
getassociateddomains
The getassociateddomains api call is used to return any associated domains with the domain looked up.
get dns history
The get dns history api call is used to return historical dns data about a domain being queried.
1. domain — The domain you are looking up
2. record_type — The record type being looked up; this can be a, aaaa, mx, ns, soa or txt
getwhoishistory
The getwhoishistory api call is used to return historical Whois information about a domain being queried.
getcompanydetails
The getcompanydetails api call is used to return information about a company via its domain.
Other functions
There are many other functions such as:
checkping.
checkusage.
getdomaintags.
getcompanyassociatedips.
getipneighbors.
getipwhois.
getipuseragents.
getsslcertificatesPages.
getsslcertificatesStream.
getfirehosecertificatetransparency.
Get full insight into all of these extra functions by visiting the official Github docs.
Getting started
Let's see what the required steps are to get this api wrapper working on your php applications.
Generate an api key
To use the php api wrapper, you first need a Securitytrails api key. This can be obtained from your Securitytrails account at
Head over to the api Keys option on the left menu:
Once on the api Keys page, you can copy your api key by clicking on the copy button:
Installation
Installing the Securitytrails api php Wrapper is super easy; all you need to do is clone the git repository or simply download the file securitytrails.php and include it in your projects to use it right away.
In most use cases, it is recommended to download the api wrapper via Git, as this allows you to easily update the wrapper (when there are any updates to it) by running a simple git pull command.
In our example, we'll download the api wrapper by using Git.
Run the commands listed in the order below. This will download the Securitytrails api php Wrapper into your current folder:
In this folder, you'll find the api wrapper named securitytrails.php, which can now be included in your existing project.
How can I use it?
Here, we'll try the getdomain api call which returns current data about the given hostname and more.
Create a file called test.php with the following code:
Replace your api key here with the api key token obtained from your account in the previous step (do not remove the double quotes).
Once that's done, head over to your website and visit the page test.php which we created above, and you'll see the following output
Other usage examples
Finding domain W...