Building a Machine-Readable List of WordPress Events

In #hosting-community, it was brought up that several hosts are interested in collecting data of local WordCamps and WordPress Meetups to promote attendance to customers. With many events happening around the world, the first task is to build a reliable source of data. The most important WordPress-related events are collected in two places: WordCamp Central and Meetup. Both sites have APIs to retrieve these lists.

WordCamp Central Events

The WordCamp Central API does not require an API key, so no setup is required. To pull the last 100 modified WordCamp events use the following request:

[user@localhost]$ curl -g 'https://central.wordcamp.org/wp-json/posts?type=wordcamp&filter[posts_per_page]=100'

The response is formatted as JSON. If filter[posts_per_page] isn’t added, you’ll get only the default amount of results (8, at the time of writing this). To get a more readable output, you can use jq and less on Linux/MacOS (you may need to install jq using your package manager):

[user@localhost]$ curl -g 'https://central.wordcamp.org/wp-json/posts?type=wordcamp&filter[posts_per_page]=100' | jq '.' | less

The top level element is a list. Each element in the list is an object with key/value pairs. The post_meta element is a list that contains objects for metadata including location, Twitter hashtag, start and end date (in epoch format), and other useful details of approved WordCamps. The location does not follow a strict format and is usually “city, country” or “city, state” if in the United States, but some WordCamps follow a slightly different format, and the Community Team has suggested an effort to standardize format and normalize the previous values. A good next step is to connect with the Community team to see if the Hosting team can help out here, since that will make it so that the country retrieved will always be accurate.

Meetup Events

The other source of events is on Meetup Their API requires a developer key, which can be created for free. To get a JSON formatted object of all scheduled WordPress Meetups, use:

[user@localhost]$ curl -g "https://api.meetup.com/2/events?member_id=72560962&key=$KEY&sign=true"

Be sure to change $KEY in the URL to your API key or it will not work. Again, you can use jq and less to parse the JSON:

[user@localhost]$ curl -g "https://api.meetup.com/2/events?member_id=72560962&key=$KEY&sign=true" | jq '.' | less

The member_id value 72560962 is the id for the WordPress Foundation Meetup account, and by specifying this, the API returns all WordPress official events, rather than the events for a single Meetup group.

The JSON that the Meetup API returns has a different schema than the WordCamp Central API JSON responses. For Meetup, the top level entity is an object, and the main key to look at is results. This contains a list of objects, and each object represents a WordPress Meetup. Each Meetup has a lot of metadata associated with it. Some important ones to know about are time, which is in epoch format * 1000, venue, which is an object with information about the venue, name, which is the name of the WordPress Meetup, and event_url, which is the website for the event. The venue‘s localized_country_name and city keys can be used together to replicate the WordCamp API’s location object.

Bringing it All Together

To get the full list of WordCamps and Meetups, a script is needed to pull from both sources and combine them into one list. An example script can be found on GitHub to see how a host might retrieve the data and combine the two sources. There is also an Official WordPress Events plugin, which creates this page, that can be used.

#promoting-wordcamps