Announcing the IDlayr CLI

As a developer-first and API-first company, we prioritise tools that will make you, the developer, successful. Today we’re excited to announce the IDlayr CLI: built on top of our public APIs, open sourced, and your go-to developer tool when building on the IDlayr platform.
Why a CLI?
Many of us spend a lot of time in the terminal, so a CLI enables you to work from where you already are. IDEs such as Visual Studio Code and Android Studio come with in-built terminals. But having a CLI also allows us to build integrations into existing development workflows, via scripts, outside of the IDE. For example, Xcode behaviours or integration into CI/CD workflows.
Using Oclif & Open Source
The IDlayr CLI is built upon the excellent oclif open CLI framework by Heroku. Oclif provides a foundation for CLI functionality such as subcommands, command arguments and flags, plugin support and lots of utilities that enable us to focus on features instead of building our own CLI framework.
If you’d like to see how we’ve used Oclif the IDlayr CLI is on GitHub. Within the GitHub repo you’ll find two branches:
- `main` for the latest stable release
- `canary` if you’d like to try out the latest features
We’d love to hear what you think so please ask questions, share ideas and raise PRs on the IDlayr/cli repo.
Install and Setup the IDlayr CLI
For the moment the only installation option is via NPM so you’ll need Node.js installed.
With Node.js installed you install the IDlayr CLI as follows:
Or, if you prefer Yarn:
To try out the latest features use `@tru_id/cli@canary`.
With the `tru` command installed, setup the CLI with the credentials you’ll find within the IDlayr console.
`eu` is the region where your account data is stored and, at the time of this blog post, is the only region we have available (more coming soon).
You can now query the credit you have available using:
And the output will be similar to:
Creating a IDlayr Project
Projects are configuration containers within the IDlayr platform and you’ll normally have a one-to-one mapping of a IDlayr project to an application that you are developing (though you may also create a project per environment: `dev`, `staging` and `prod`). A key piece of configuration are the project `credentials` which contain a `client_id` and `client_secret` that you use to authenticate interactions with the IDlayr APIs.
You create projects using the CLI:
And you’ll see output such as:
The `tru.json` file contains your project configuration including the project credentials. Don’t check this into source control!
With a project created you can `cd my_awesome_project` so the CLI can read the `tru.json` file from the `cwd` and you have everything you need to fully utilise the IDlayr CLI.
Trying the IDlayr APIs
CLIs normally focus on platform management functionality, such as creating and managing projects, but we decided to also add commands to let you try out our products from the terminal. Of course, you can also try these out programmatically too.
SIMCheck
SIMCheck is an API that queries when the SIM card associated with a phone number last changed:
With the output being similar to the following, which prompts for the phone number to be checked:
The `no_sim_change` value indicates that the SIM card hasn’t changed within the last seven (7) days, and `last_sim_change_at` specifies the last change date (when I changed my mobile phone provider from giffgaff UK to EE UK).
PhoneCheck
PhoneCheck verifies that a phone number is associated with a SIM card within the mobile device. This is achieved via IDlayr’s integration with MNOs (Mobile Network Operators) around the world. For a more in-depth look at how this works, check out the PhoneCheck integration guide. Of course, you can also try this out via our CLI:
The output of this command prompts for a phone number and also displays a QR code to scan on a mobile device. It also provides instructions to disable WiFi on the device, as part of the PhoneCheck workflow is to make a web request over the device’s mobile data connection.
QR codes in the terminal. Pretty cool, huh!
As well as creating resources you can also query existing ones:
You can also try out `tru phonechecks:list` with flags such as `–search` to add query conditions the API request, `–filter` to filter a result from the API, and `–output` to change the output format e.g. `–output json`.
SubscriberCheck
The CLI also supports SubscriberCheck, which runs a PhoneCheck but also includes a SIMCheck within the result. We’ll leave trying that out to you, but here’s the creation command that runs through the QR code workflow:
What Else Can the CLI Do?
Two other commands worth highlighting are `oauth2` and `coverage`.
OAuth2
Our APIs use OAuth2 credentials and access tokens for authentication. But we know that sometimes you just want access to an access token without having to concatenate a project `client_id` and `client_secret`, Base 64 encode that value, make a request to the `/token` endpoint to create an access token, and then eventually getting to use it. So, the `oauth2` command makes it a bit easier to create an access token when you’re just trying things out.
Note: Running the following command from a directory that contains a `tru.json` project configuration file will use the credentials for the project. If you run the command without a `tru.json` in the `cwd` you’ll use the credentials you supplied in the `tru setup:credentials` command.
Then you just need to copy the access token and use it:
You can also assign the output to a variable and use it either in a mobile client or to try things out via cURL:
Coverage
Coverage provides two endpoints and is thus a “topic” with two commands in the CLI.
`coverage:country {country_code}` allows you to query if the IDlayr platform has coverage for a given country. You can use either a phone number country code prefix:
Or a two-letter alpha country code:
`coverage:reach` also performs a IDlayr platform coverage query but based on the IP address (IPv4 or IPv6) of the device:
Try out the CLI and let us know what you think
In this post we’ve covered a number of the main commands but there’s more that the CLI offers. Either install the IDlayr CLI (`npm install -g @tru_id/cli`) and `tru –help` to find out more, or take a look at the CLI Reference docs to see what else is possible.
We believe the IDlayr CLI offers a good first developer experience of our platform. But we’d love to know what you think via [email protected].
If you haven’t already, signup for a IDlayr account, follow @theidlayr on X and join our mission to reimagine mobile authentication.