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.
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
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.
This is built to run on Heroku. Here’s a pretty basic way of deploying to Heroku.
- Fork tlongren/personal-api on GitHub and make a local clone.
- Install the Heroku Toolbelt and login to Heroku with the command “heroku login“. Enter your username and password to login with the Heroku Toolbelt.
- 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.
- 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.
- 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.
Well, now what?
Work with Me
I'm available for hire and always taking new clients, big and small. Got a project or an idea you'd like to discuss? Startup plan but no developer to make it happen? Just get in touch, I'd love to see if I can help you out!
Leave some Feedback
Got a question or some updated information releavant to this post? Please, leave a comment! The comments are a great way to get help, I read them all and reply to nearly every comment. Let's talk. 😀
5 thoughts on “Host a Personal Data API on Heroku”
Did a personal api @ http://krrishd.github.io/krish.json. although it was static due to most the info I wanted on it being the same most of the time.
Cool! I’m using mostly static data too. I’ll be adding some data from other API’s and generating some dynamic numbers, such as ages.
Would love to be able to grab location of my nexus 4 to add as a dynamic data source.
I’ve been wanting to make my own personal API for ages. Planning on adding my data from Fitbit and Foursquare, so you can check out my health and location status.
You can event host it with Github Pages (free, no fuss) with a simple Jekyll implementation: https://github.com/ssaunier/personal-api
Bonus point: you get a nice YAML file for your personal info instead of a big string.
Great initiative! 🙂
That is a really great idea!
It never occurred to me, sadly. I’ve never really played around much with gh-pages. Having a YAML file would be much cleaner and easier for people to read. JSON isn’t especially easy to read, at least not like YAML.
I’m going to look into this. Pull request are welcome, too. 🙂