😻 😻 😻 The Fattest Cat You Can Adopt 😻 😻 😻 From Github Repos to Clay Microservices — Making Code Accessible to Non-Coders

Nicolae Rusan
Clay
Published in
3 min readMar 2, 2017
Mr.Mom, 15 lbs, 6oz, not a Female.

I spent a few minutes making a microservice in Clay that wraps the awesome Github Repo written by Lexi Ross which crawls websites of pet adoption websites in SF to find the fattest cat you can adopt . Here’s the resulting microservice, just hit “Run Function” and get back the URL and info of the fattest cat: 😺 https://clay.run/services/nicoslepicos/fattest-cat-info

I saw Lexi’s repo this morning and loved the concept, she took a moment to make a heart-warming and lovely piece of code :). The thing is, that as a Github repo hosting a shell script, that functionality is only accessible to a very small group of people: coders who know how to open up a terminal, install her NPM repo in Node, and run the shell script. That’s not a lot of people.

In a few minutes, I was able to take her Github repo, and wrap it into a microservice that generated a webpage interface to her code, and also exposed it as an API. All of a sudden someone not familiar with code could go to this webpage and try out that functionality. Interestingly, because it’s now an API instead of a package, you could call this function in any language using a simple POST call or one of our pre-generated clients for invoking the functionality. Right now we only have the Node client listed there, but more are on the way. First install the NPM client

npm install --save clay-client

Then it’s as easy as:

Clay = require(‘clay-client’)

Clay.run('nicoslepicos/fattest-cat-info', {})
.then((result) => {

// Do what you want with returned result
console.log(result);

})
.catch((error) => {

console.log(error);

});

Let’s take it one step further. I decided that I actually wanted a microservice that would not only return the cat, but would actually give me a screenshot of the webpage too. I combined the Fattest Cat microservice, with a Screenshot Microservice I had already written to produce this combo service that finds the URL of the fattest cat and then takes a screenshot of it, here’s the result (TAKES A SECOND TO RUN AS IT SPINS UP A HEADLESS BROWSER AND DOES A FAIR AMOUNT OF CRAWLING — Cache coming soon :) ): https://clay.run/services/nicoslepicos/fattest-cat-screenshot. Again, all this took a few minutes because I had the building blocks!

Github was a big deal in the world of software development, because it was a leap forward in how engineers could collaborate with one another. But, at the end of the day, Github is still just Dropbox for your code, with great functionality for helping you merge files together & manage versioning around your source code. Code on Github though is just a bunch of files: it’s dead, static text. Our vision is that with Clay, every piece of code is a usable microservice that makes that code instantly usable as an API in any language, and also easily incorporated into web interfaces that allow non-coders to use the functionality that was created too! WOOO HOOO.

We’d love to have you try using one of the functions that’s already been created: https://clay.run/public/services in your own code, or build your own function and see how easy it is to get a microservice up and running!

--

--

Nicolae Rusan
Clay
Editor for

Product focused entrepreneur based in Brooklyn. Co-Founder @ Clay / Previously Co-Founder @ Frame