Host a Personal Data API on Heroku

Josh Beckman makes some pretty cool stuff. One of my favorite creations of his is Stark Lines. He’s also got a pretty neat API on his site that allows others to query it to get information about him. It’s at http://www.bckmn.com/api. Some of Josh’s JSON is generated on the fly with data from other API’s, and is built with Node.js.

You can make a similar API for your website really easily with a little PHP and Heroku. I put the whole thing up on GitHub so you can contribute (programming language examples especially) or totally make it your own.

I wanted to make it really easy for anyone to setup. You could get it setup with nothing but a text editor. Hosting your Personal API on heroku is quite nice as it provides great speeds and relatively good uptimes. Plus, if you’re a git fan, git push heroku master feels really good, lol.

Do you use Heroku for anything?

View Results

Loading ... Loading ...

Of course, there’s always some concerns.

1. A Standard

Ideally, every “personal site” with an /api URL or api.* subdomain should contain the same info, or MOST of the info, probably just the basics like name, age, langues, and location (maybe). If their was a standard it’d be very easy to grab info about LOTS of people, which may or may not be such a good idea. And that leads nicely to my next point

2. Privacy

There’s obviously some things you don’t want public, like your address and probably phone number. If you do implement a personal API like this, I suggest you modify the array to suit your needs. It’s extremely easy to edit, all it requires is a text editor, like Sublime Text. If there was a “Standard” personal API like mentioned above, it’s be very easy for attackers to just hit every website at /api or /api.php and pull down all the data.

Enough with concerns, gimme more

The benefits are pretty endless, especially depending on what kind of info your API provides. For example, people can fetch my name, employer, age, blogs, sites I run, generic family information and various other things. Authentication would be a good idea, too. You could provide relatively harmless info, like name and age, to the general public, but could require an API key to get even more JSON. That way, you could give friends and family access to more information.

Run It!

This is built to run on Heroku. Here’s a pretty basic way of deploying to Heroku.

  1. Fork tlongren/personal-api on GitHub and make a local clone.
  2. Install the Heroku Toolbelt and login to Heroku with the command “heroku login“. Enter your username and password to login with the Heroku Toolbelt.
  3. Create a new app on Heroku either through the web interface, or with the command “heroku create“. If you do it with the command line the app name will be shown to you, see here.
  4. Open a terminal and go into the folder that you cloned your fork into and run the command “heroku git:remote -a heroku-app-name“. That will add a remote named “heroku” to your local clone.
  5. Now, while still in your local clone folder, run “git push heroku master” to push your app to Heroku. If your app is named “heroku-app-name”, you can access your app at http://heroku-app-name.herokuapp.com.

And that’s all there is to getting setup with Heroku, a total of 5 steps, with just 4 simple commands.

See the GitHub repository for more info.

See any issues or have any concerns? Leave a comment below or at Hacker News.

Advertisements