Re: Factor

Factor: the language, the theory, and the practice.

Monday, August 12, 2013


The service is a handy way to find domains that make nice short URLs like,, and

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 service has a JSON API for performing searches, that we can build URLs for:

: domainr-url ( query -- url )
    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. - available - available - taken - available - taken - available - available - available - available - unavailable - unavailable - available - available - unavailable

Well, if we wanted to make our URL something like 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.