While working on personal projects, I often need to include a LICENSE file which is usually Open Source.
But to do that, I have to search the net, download the file and save . All of this takes too much time and needs me to move away from the keyboard and the Terminal.
Hence I thought of making an API so that I can use tools like
wget to save the licenses quickly on the Terminal.
I have used Lumen PHP micro-framework to define the routes and set the API endpoints.
I really like working with Lumen because it is very fast and lightweight. It is made specially for making APIs for REST based web services.
Now to get the Licenses, I used a PHP library called Simple HTML DOM Parser to scrape the Licences from a reliable source.
The Licenses are scraped from choosealicense.org and served as either plain text or HTML.
The whole project is hosted on Heroku.
The API Documentation provides ids for various Licences which can be accessed as follows:
Also you can choose to get a HTML or plaintext(default) output.
Thus , for example to download the GNU GPL License, navigate to the project directly and type this in the terminal :
wget openlicensesapi.herokuapp.com/2 -O LICENSE
It was a good experience hosting on heroku, this was the first time.
I use this API in the inipy project too.