Creating a Serverless Meetup API Wrapper

Yesterday I was doing some research into serverless meetups when I encountered something that bugged me about the Meetup.com web site. Specifically, this:

I couldn’t search for meetups until I logged in. Now, don’t get me wrong, I’ve got a Meetup.com login, and I could have logged in in about 2 seconds, but this really bugged me. (As an aside, you can just go to https://www.meetup.com/find/events/ to skip being forced to log in.)

Even after logging in, I didn’t like that I had to explicitly tell the form to not care about distance in order to find groups across the country:

In this case, their defaults I think make sense. As an evangelist, I’m looking for meetups I can speak at (hey, by the way, I’d love to speak at yours!), so my use case is not the norm. But I was also a bit bugged by the fact that I couldn’t limit my searches to America.

Therefore — I decided to do what any good developer would do — spend 10x as much time writing my own solution versus just dealing with what was given to me!

I knew Meetup had an API and I blogged on it a few years ago (Using the Meetup API in Client-Side Applications), so I figured this would be a great example of how I could use serverless, and OpenWhisk in particular, to build my own API wrapper around their data to build my own tool.

For my wrapper, I decided to build an interface to their Find Groups end point. (By the way, since I complained a bit about their UI I want to point out one thing they do very nicely — not forcing me to login to read API docs!)

/* Note to self: I modified the code to return the full response so I could potentially do paging. I decided against that for now, but I'm keeping resolveWithFullResponse in for the time being. */ let options = { url:url, json:true, resolveWithFullResponse: true };

For the most part, this is simply building a URL based on arguments. I’m not doing any validation since the API will do that for me. I’m also not doing any pagination since in my testing, I got over 100 results. I couldn’t find docs on how many max results they would return and I did do a bit of “prep work” for adding support in the future, but for now, it will return at least 170 or so results in my testing.

Note that the action expects an argument for the key. I set that as a default action parameter so I don’t have to include it in my own calls.

The only real interesting part is the manipulation I do for “country”. While the Meetup API has a country argument, it seems to ignore it when you set the radius argument to global. So basically, I can’t say “Don’t care about distance from my home but keep it to America.” Therefore I do my own filtering on the results after fetching them.

This is a great example (imo) of where serverless wrappers can be so useful. I took an existing API and built my own to address the shortcomings (or at least my perceived shortcomings) of it.

Yeah, not necessarily the prettiest demo in the world, but it did give me a chance to finally try Flexbox. I have an idea for a nicer version I’m going to try to get out the door this week, but we’ll see. The JavaScript code behind this is relatively simple. It’s 99% DOM manipulation to be honest.