pythonapisudsmindbody

How I can get all Clients with MindBody API python


I am trying to get all clients using MindBody API, I tried this,

from suds.client import Client
from Helper.ClientService import ClientServiceMethods

# Making a call
calls = ClientServiceMethods()
result = calls.GetAllClients()
client_dict = Client.dict(result)
clients = client_dict['Clients']
client_list = clients.Client # transferring clients into a python list

#printing the lenght of received clients list
print len(client_list)

the above code will work but the issue is that it will not pull of more than 27 client, that's it. from MindBody Docs the GettAllClients should get up to 1000 client, the limit for a call is 1000 which means i can get up to 1000, but the problem is that I am note able to get at least that 1000, I am only getting 27 clients.

Note: I am working with Demo Data, Sandbox which can anyone look them, I used the Sample code from their MindBody Python repository

I am working on getting all clients data through the api,these clients can viewed from here

Username:Siteowner | Password:apitest1234


Solution

  • for anyone who's having problems with this too, this will be a big help for you.

    when we make call GetClients, mindbody will send clients but it will represent them in form of pages so that 25 client was the first page if u want to get the next 25 client you would have to call the page indexed 2 and so on and so forth.

    in code this is how u would do this, using API Example code ClientService, do this inside the method GetClientsByString

    def GetClientsByString(self, searchStr):
            """Convenience method to find clients containing searchStr in their name or e-mail."""
            request = self.CreateBasicRequest("GetClientsRequest")
    
            # Since SearchText is just a string, we can assign it directly.
            request.SearchText = searchStr
            request.CurrentPageIndex = 1 # increase this number by one each time 
    
            return self.service.service.GetClients(request)