I count myself as an amateur programmer. I do a little at work, occasionally, but it’s not the main thrust of my job, and so I’ve never felt I’ve crossed that line over into professional. The only money I’ve ever made from programming, I guess, would be in the form of the kind donations I occasionally receive to keep my web game, Words With Monsters running.
Still, I’m glad I’m skilled enough to identify a problem and usually fix it. I can’t overstate how your view of computing changes when you have the skills to make your own tools.
Here’s a problem I identified recently. My partner, Kateri, sells a lot of beautiful jewellery through her two Etsy stores: Leaves of Glass and Urban Legend. She also blogs about her work on a self-hosted WordPress blog which I help administer. We thought that given the huge size of the Etsy community, there would be an existing plug-in that would let you feature a specific Etsy item from within a blog post: but no. A little research revealed that all of the plugins on offer were far too grand for this purpose; they would display entire shop sections, essentially turning your blog into a online shop of it’s own.
So yesterday I sat down with the Etsy API documentation, and then the WordPress shortcode documentation, and wrote my first WordPress plugin, which I named Sparkletalk. Given a shop name and a listing ID in a standard WP shortcode, it pulls the items details and inserts a nicely formatted boxout about the item:
Thoughts and lessons
There are only two hard things in Computer Science: cache invalidation and naming things.
- The plugin doesn’t do any caching, because caching is hard to get right, and the API usage limits are pretty generous for the amount of calls I expect to be making. I’ll be keeping an eye on this, though.
- The Etsy API is pretty nice, with a really simple authentication method, and it returns JSON structures, which are really easy to work with.
- One quirk that I thought was a little odd is that you have to make a seperate call to get the images associated with a listing, they’re not included in the JSON returned when requesting the main listing details. This means each listing requires two API calls when really one would do.
- WordPress plugins and shortcodes are ridiculously easy to define.
The code is very specific for Kateri’s website and the way she formats Etsy listings, but if there’s any interest in a more flexible, generic version for use elsewhere, leave me a comment or send me a tweet and I’ll see what I can do 🙂