Warning
The XML-RPC API is deprecated, and will be removed on July 1, 2023.
Please use the REST API instead.
Contact support if you need help with migration, or need the feature enabled on a transitional basis.
Events¶
The APIs for the event system should be familiar if you've used ActionKit's database APIs. The main event-specific changes and additions are:
- We'll send email when you use the API cancel someone's event signup, or change their role between host and attendee. You can disable this with suppress_email=True.
- We'll do extra internal bookkeeping after some database updates. For example, creating an EventSignup can also create an EventSignupAction, and event addresses are geocoded before saving.
- We provide some extra search methods like advanced_search() and public_search().
These APIs are low-level -- as close to direct database access as we can manage -- and they might or might not be the right way to do your particular extensions. Also consider:
- Using the act() API. In particular, use act() if you want the normal "thanks" messages to be sent when someone signs up for or creates an event.
- Customizing event pages and emails through the templateset editor.
- Embedding event search/signup/creation forms on your own site. (Host and attendee tools aren't embeddable.)
- Getting reports with SQL, either on client-db or through the reporting system in the admin.
Finally, if none of these customizations or the API work for your application, it might not be a good fit for our event system. Feel free to contact us to talk about it.
Managing Events¶
Before this code works, you'll need to create an event campaign and the corresponding event creation/signup pages through the admin.
e = actionkit.Event.create(dict(
campaign_id=1,
title=u'Test event',
venue=u'Home',
address1=u'3026 harper',
zip=u'94703',
starts_at=datetime.datetime(2099, 12, 31, 23, 59, 59),
max_attendees=50L,
creator_id=1L,
public_description=u'beep'
))
The user whose ID you pass in creator_id is automatically signed up as a host (but isn't sent an email).
By default, events are created already confirmed and approved, and starts_at and title are set to the campaign's defaults. Addresses are normalized and geocoded.
create() doesn't send a thanks message to the host -- use the act() API if you want that.
Not all of the normal event validation applies, so be careful.
You can also update an event's location, time, etc. Updating an event's status to 'cancelled' or 'deleted' will also notify all of the users that the event is cancelled. Use suppress_email=True to stop the email notifications.
# Update settings (or event time, address, etc.)
actionkit.Event.update(dict(
id=123,
is_private=True
))
# Cancel event, sending email
actionkit.Event.update(dict(
id=123,
status='cancelled'
))
The main columns to know about are:
- campaign_id (required)
- creator_id (required; user ID of creator)
- address1
- address2
- city
- state
- zip
- plus4
- country
- title
- max_attendees
- venue
- public_description
- directions
- note_to_attendees
Other columns are:
- id
- region
- postal
- created_at
- updated_at
- longitude
- latitude
- starts_at
- ends_at
- status
- host_is_confirmed
- is_private
- is_approved
- attendee_count
- phone ("event contact phone")
- notes
Managing Signups¶
You can create a signup with a user ID, akid, or email.
attendee = actionkit.EventSignup.create(dict(
user_id=123,
event_id=1
))
attendee2 = actionkit.EventSignup.create(dict(
akid='1.2.abCde',
event_id=1
))
attendee3 = actionkit.EventSignup.create(dict(
email='moose@wawd.com',
event_id=1
))
Adding signups this way doesn't send a thanks email. To do that, use act:
signup = actionkit.act({
'event_id': 1,
'page': 'fun_attend',
'akid': '.2.abCde',
'event_signup_ground_rules': '1',
})
You can also use a user ID or email. Notice that you need to 'act' on an 'attend' page, and need to signal agreement with the ground rules.
The API can also cancel users' signups and change hosts to attendees and vice versa; you do it by updating a signup's status or role fields. Unless you pass suppress_email=True, these will email the user a notification:
# Cancel user's signup
actionkit.EventSignup.update(dict(
user_id=123,
event_id=123,
status='deleted'
))
# Promote an existing attendee to host
actionkit.EventSignup.update(dict(
user_id=123,
event_id=123,
role='host'
))
Public Search¶
To get HTML for search results to integrate into your own page, you don't need the API. Just retrieve results directly from your ActionKit instance's website:
/event/[CAMPAIGN_NAME]/search_results/?akid=&distance=50&limit=10&zip=[ZIP]
To get the same info in the form of objects from the API, use public_search():
event_info = actionkit.Event.public_search(dict(
campaign=1,
zip='94704',
radius=50
))
public_search() doesn't do anything that advanced_search() can't, but it may be simpler to use: it automatically limits to non-private events that are open for signup (not full, deleted, or in the past) and doesn't return extra fields.
Advanced Search¶
Event.advanced_search lets your application use the advanced-search functionality from the event campaign admin.
By default, results include cancelled events, events in the past, etc. So, for a public-facing search page, you may want to use Event.public_search(), or use the for_signup option below.
There's just one required parameter:
- campaign -- campaign ID (required
Other options filter down the results:
- for_signup -- True to limit to open, confirmed, future, non-full events. To hide private events as well, also include privacy='public' in your criteria.
- zip + radius -- for proximity searches
- event_id -- to retrieve a single event
- q -- search for text in event titles, host's description fields, and notes from the event admin
- status -- one of:
- "open" -- not cancelled, has confirmation/approval
- "unconfirmed" -- needs email confirmation by host
- "unapproved" -- needs approval by administrator
- "cancelled" -- cancelled (or deleted by administrator)
- privacy -- "public" or "private"
- states -- a comma-separated string of US state abbreviations
- before / after -- limit events by date (e.g., 2010-01-01 10:00:00)
- future_only -- True to limit to future events
- filter -- filter events by other attributes; uses similar syntax to the regular search() API.
- exclude -- exclude events by other attributes
A few options control ordering and what info's returned about each event:
- extra_fields -- optional list of strings specifying what extra info you want returned about the event. The default is ["host_user_ids", "attendee_user_ids"]. To get full host/attendee user records and not just IDs, you can pass ["hosts","attendees"]. To get no extra fields and make responses slightly smaller, you can pass an empty list ([]).
- order_by -- column used for sorting
- reverse -- True to reverse order of results
Campaign Info¶
There are a couple of barebones methods to retrieve info and statistics about a campaign:
campaign = ak.EventCampaign.get(dict(id=1))
stats = ak.EventCampaign.stats(dict(id=1))
The campaign object includes the info entered on the "Campaign settings" page in the admin. The stats object includes counts of signups in a few categories (active signups (broken down into active hosts and active attendees), cancelled/deleted) and events in various categories (open, cancelled, etc.) as well as the path to the "browse events" page in the admin for each category.