Searching Campaigns, Events and Signups

Below are some examples of common searches you may want to perform on campaigns, events and signups.

You can also consult the filtering documentation and the specific resource schema for more details on what and how to search.

High-level Search API

A high level event search is exposed as part of the event campaign's endpoint:

While not available to the general public, the API is available to logged-in moderators and staff with event permissions. Unlike other API endpoints that are only available via admin accounts, the search API primarily inlines related resources, instead of using references.

Filter Filter description Example
for_signup Events open for signup. for_signup=1
for_moderation Events awaiting approval. for_moderation=1
status Filter by event status. status=open, status=unconfirmed, status=unapproved, or status=flagged
moderation_status Events that have or haven't been moderated. moderation_status=unmoderated or moderation_status=moderated
event_id Event by id. event_id=<EVENT_ID>
future_only Only include future events. future_only=1
states Events taking place in comma-separated list of states. states=WA,ID,OR
zip, radius Find events by location zip=97214&radius=5
q Events matching a text string. q=harmonica
filter[] Filter by attribute of event or related object. filter[field__name]=shift&filter[field__value]=3
exclude[] Exclude by attribute of event or related object. exclude[creator__email]=host@example.com
order_by Order results by event attribute. order_by=confirmed_at
reverse Reverse order of results. reverse=1

JSONP

To enable use of the search outside of AK-hosted pages, JSONP is supported for the event search resource.

JSONP must be accompanied by a CSRF token, as event searches can return potentially sensitive information. For examples:

See Hosting Event Moderator Searches for details on adding this to your templates.

Low-level Search APIs

Get a campaign by its name or title

The campaign resource allows filtering on the "name" and "title" fields, but restricts the filtering operators to exact, starts with, and in a list matches.

Exact match:

Starts with:

In:

Get all events in a given campaign

You can get a list of events in a campaign like so:

This is also listed in the campaign resource under the "events" field:

GET /rest/v1/campaign/159/
{
        "allow_private": true,
        "created_at": "2017-01-10T00:36:16",
        "default_event_size": 50,
        "default_title": "",
        "eventcreatepages": [
          "/rest/v1/eventcreatepage/20279/"
        ],
        "events": "/rest/v1/event/?campaign=159",
        "eventsignuppages": [
          "/rest/v1/eventsignuppage/20280/"
        ],
        "hidden": false,
        "id": 159,
        "max_event_size": null,
        "name": "house-parties",
        "public_create_page": true,
        "public_search_page": true,
        "require_email_confirmation": true,
        "require_staff_approval": true,
        "resource_uri": "/rest/v1/campaign/159/",
        "show_address1": false,
        "show_attendee_count": false,
        "show_city": true,
        "show_directions": false,
        "show_public_description": true,
        "show_state": true,
        "show_title": true,
        "show_venue": true,
        "show_zip": true,
        "starts_at": "2017-04-01T12:00:00",
        "title": "House Parties",
        "updated_at": "2017-02-02T18:44:36",
        "use_start_date": true,
        "use_start_time": true,
        "use_title": true
}

Get only public events in a given campaign

For this situation, you simply combine the events in a campaign search with another field, in this case, "is_private":

You can use the same format to filter on other allowed fields, like "status", "is_approved" and "host_is_confirmed", too.

Get only future events in a given campaign

This search uses the "gt" filter method, specified as one of the standard field lookups in the Django documentation.

Assuming today is 9/30/17, and the campaign in question has an ID of 158, then a future event search looks like this:

Get all signups in a campaign

The eventsignup resource allows filtering by the "event" field in an "ALL WITH RELATIONS" manner, which means that you can then further filter by any fields allowed in the event resource. In this case, we would then ask for the campaign like so:

Get all signups for a given event

You can get all signups for an event through the eventsignup resource like so:

Or, signups are also included in the event resource under the "signups" field:

GET /rest/v1/event/300/

{
        "address1": "100 MLK Blvd",
        "address2": "",
        "attendee_count": 3,
        "campaign": "/rest/v1/campaign/159/",
        "city": "Burke",
        "confirmed_at": null,
"approved_at": null,
        "country": "United States",
        "created_at": "2017-03-27T21:59:45",
        "creator": "/rest/v1/user/2082925/",
        "directions": "",
        "ends_at": null,
        "ends_at_utc": null,
        "fields": [],
        "host_is_confirmed": true,
        "id": 300,
        "is_approved": true,
        "is_private": false,
        "latitude": 38.7901,
        "longitude": -77.2807,
        "max_attendees": 50,
        "note_to_attendees": "",
        "notes": "",
        "phone": "",
        "plus4": "",
        "postal": "",
        "public_description": "the best",
        "region": "",
        "resource_uri": "/rest/v1/event/300/",
        "signups": [
          "/rest/v1/eventsignup/467/",
          "/rest/v1/eventsignup/475/",
          "/rest/v1/eventsignup/476/",
          "/rest/v1/eventsignup/477/"
        ],
        "starts_at": "2017-04-15T18:00:00",
        "starts_at_utc": "2017-04-15T22:00:00",
        "state": "Virginia",
        "status": "active",
        "title": "My House Party",
        "updated_at": "2017-04-05T00:25:29",
        "venue": "My House",
        "zip": "22015"
}