Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination improvements #18

Open
xxv opened this issue Apr 5, 2015 · 8 comments
Open

Pagination improvements #18

xxv opened this issue Apr 5, 2015 · 8 comments

Comments

@xxv
Copy link

xxv commented Apr 5, 2015

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.

@pydanny
Copy link
Contributor

pydanny commented May 11, 2015

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

@pydanny pydanny changed the title support paging Pagination improvements May 11, 2015
@caljess599
Copy link

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()

@yhager
Copy link

yhager commented May 19, 2017

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

@NoahCardoza
Copy link

Is there still no pagination support?

@cmaimone
Copy link

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.

@sidcarter
Copy link

sidcarter commented Jan 12, 2019

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

e.g.

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

@larkinds
Copy link

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

@herronelou
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants