eventbrite-sdk-python icon indicating copy to clipboard operation
eventbrite-sdk-python copied to clipboard

Pagination improvements

Open xxv opened this issue 9 years ago • 8 comments

The underlying REST API supports paging, but it is masked in a few places by overly-strict function signatures.

When a function gets called from the AccessMethodsMixin collection, the page=1 keyword argument gets passed along to the REST request. However some of the functions defined in the Eventbrite class (such as get_event_attendees) mask the auto-generated functions and don't have the page keyword argument, so there's no way to get to the second page.

It would also be nice to have a helper utility to automatically retrieve the pages.

xxv avatar Apr 05 '15 16:04 xxv

Was asked about this in IRC over the weekend. Need to either document pagination or make it easier to do.

pydanny avatar May 11 '15 20:05 pydanny

Yes, this functionality is critical! Without it, the scripts I have are worthless, really. It took me forever to track down how to specify the page number, so I'll share here the python function that can call a specific page of attendees.

#define as variables YOUREVENTID and YOURAUTHTOKEN
def get_page(pn):  #pn is page number
    pn=str(pn)
    response = requests.get(
        "https://www.eventbriteapi.com/v3/events/"+YOUREVENTID+"/attendees/?page="+pn+"&token="+YOURAUTHTOKEN, 
        verify = True, 
    )   
    return response.json()

caljess599 avatar Jan 13 '16 07:01 caljess599

This should be high priority to fix. I might be able to send a PR later, but what I did for now was to subclass Eventbrite and implement a get_all_event_attendees function that cycles through the pagination. This has poor guarantees for completeness, but it's better than completely missing out on any page > 1

class MyEventbrite(Eventbrite):
    def get_event_attendees(self, event_id, status=None,
                            changed_since=None, page=1):
        """
        Returns a paginated response with a key of attendees, containing a
        list of attendee.

        GET /events/:id/attendees/
        """
        data = {}
        if status:  # TODO - check the types of valid status
            data['status'] = status
        if changed_since:
            data['changed_since'] = changed_since
        data['page'] = page
        return self.get("/events/{0}/attendees/".format(event_id), data=data)

    def get_all_event_attendees(self, event_id, status=None,
                                changed_since=None):
        """
        Returns a full list of attendees.

        TODO: figure out how to use the 'continuation' field properly
        """
        page = 1
        attendees = []
        while True:
            r = self.get_event_attendees(event_id, status,
                                         changed_since, page=page)
            attendees.extend(r['attendees'])
            if r['pagination']['page_count'] <= page:
                break
            page += 1
        return attendees

yhager avatar May 19 '17 18:05 yhager

Is there still no pagination support?

NoahCardoza avatar May 10 '18 18:05 NoahCardoza

This is still unresolved. I don't see a way to use the API to get a second page or use a continuation value, especially for get_event_attendees, which won't take arbitrary keyword arguments and doesn't have arguments defined for pages/continuation.

cmaimone avatar Oct 31 '18 19:10 cmaimone

Ran into the same problem. I use get instead of get_event_attendees:

e.g.

    data = {'page': page}
    response = eventbrite.get(attendees_path, data)

sidcarter avatar Jan 12 '19 20:01 sidcarter

This has been resolved and is well documented on the Eventbrite website

larkinds avatar Mar 31 '23 14:03 larkinds

@larkinds it's easy with the rest api, but the python API doesn't expose it.

herronelou avatar Sep 07 '23 23:09 herronelou