The Python API Client is a module that encapsulates all the logic needed to make queries to the Meetup API. You can use this to get started quickly with the API, or write your own client. Download or clone the source from GitHub.
To use it, create an instance of the Meetup object with your API key as the constructor argument.
>>> import meetup_api_client as api >>> mu = api.Meetup('your_api_key')
Then, you can query the API directly by using one of the following methods:
>>> mu.get_topics(**params) >>> mu.get_cities(**params) >>> mu.get_members(**params) >>> mu.get_rsvps(**params) >>> mu.get_events(**params) >>> mu.get_groups(**params)
Call the method using keyword args containing the parameters of the query (identical to parameters described on the main documentation page). For example:
>>> events_res = apiobj.get_events(zip='11211')
The returned value will be an object of type API_Response. This object's property meta is a dictionary object containing all the metadata from the query results. The property results is a list containing objects of type Event, Group, City, Topic or Member (depending which query type was used). These objects support additional methods that will make API calls to get more information (taking the Meetup object as an argument to make the request). For example, here's how to grab a list of cities in NJ (ordered most members first, by default), identify the top city, and then get a list of upcoming events nearby:
>>> njcities = mu.get_cities(country='us', state='nj') requesting http://api.meetup.com/cities/?country=us&state=nj&key=your_api_key&format=json >>> njcities.results[0] New Brunswick 08901, us, NJ, with 2481 members >>> newbrunswick_events = njcities.results[0].get_events(mu) requesting http://api.meetup.com/events/?city=New+Brunswick&state=NJ&format=json&key=your_api_key&country=us >>> newbrunswick_events <meetup_api_client.API_Response object at 0x2b729f433610> >>> newbrunswick_events.results [Event 6986195 named Health & Wellness Professional Network (HWPN) of NJ May Meeting at Mon May 12 08:30:00 EDT 2008 (url: http://alternative.meetup.com/387/calendar/6986195), Event 6979165 named Family Friends, Inc. (playgroups and more) Meeting at Mon May 12 10:00:00 EDT 2008 (url: http://moms.meetup.com/2521/calendar/6979165)]
The Javascript API Client allows you to make queries to the Meetup API from your client-side applications. It works similar to the Python client as described above. To use it, include the source code for the client on your page. In addition, you will need the jQuery library which is used to handle the AJAX requests. Then create an instance of the client, substituting your API key where appropriate:
api = new MeetupApiClient('your_key_here');
Then, you can make the following api calls:
api.get_groups(params, callback) api.get_events(params,callback) api.get_members(params,callback) api.get_rsvps(params,callback) api.get_topics(params,callback) api.get_photos(params,callback) api.get_cities(params,callback)
For each of these functions, params is an associative array where each key/value pair represents a parameter to the api call.
The argument callback is a function that you supply to be called after the query is completed, which should accept one argument (the result set of the query). In this function, you can then process the results any way you like - the result set is a JSON object where the meta property can be accessed to read metadata, and the results property contains a list of the actual result rows.
Examples:
api = new MeetupApiClient(key) //create the API object function alert_total(json){ alert(json.meta.total_count) } api.get_groups({'topic':'moms'} , alert_total); // get a list of groups under the topic 'moms', and print how many api.get_cities({'country':'fr'}, alert_total); //get a list of cities in france, and print how many
If the API call results in an error, you can access the error type and description with the properties problem and description in the returned JSON objects.