Domai.nr
Monday, August 12, 2013
The domai.nr service is a handy way to find domains that make nice short URLs like debu.gs, nick.is, and craftstud.io.
I had a need awhile back to access this web service from a script and query a bunch of domains all at the same time, so I thought it would be nice to have a wrapper in Factor.
The domai.nr service has a JSON API for performing searches, that we can build URLs for:
: domainr-url ( query -- url )
URL" https://domai.nr/api/json/search"
swap "q" set-query-param ;
Each result has these fields that are returned:
TUPLE: result domain host path subdomain availability
register_url ;
It is pretty simple to map a JSON request to these result
tuples:
: domainr ( query -- data )
domainr-url http-get nip json> "results" of
[ result from-slots ] map ;
Finally, we can perform a query and print the output nicely showing which domains or URLs are available:
: domainr. ( query -- )
domainr [
[ subdomain>> ] [ path>> ] [ availability>> ] tri
"%s%s - %s\n" printf
] each ;
Running this query for “factorcode” looks like:
IN: scratchpad "factorcode" domainr.
factorcode.com - available
factorcode.net - available
factorcode.org - taken
factorcode.co - available
factor.co/de - taken
factorcode.io - available
factorco.de - available
factorc.de - available
fac.to/rcode - available
f.actor/code - unavailable
f.ac/torcode - unavailable
fctrc.de - available
fctr.cd/e - available
fc.tr/cde - unavailable
Well, if we wanted to make our URL something like factorco.de we could, but I’m not sure that’s worth it. Still, a neat way to look for interesting URLs and available on my GitHub.