SOLVED

Get all leads via rest api

Go to solution
vijayp
Level 1

Get all leads via rest api

Can we use lead changes api (activities/leadchanges.json ) to get all leads created(by passing field as lead id). Is there any limit on the timestamp we can pass to the api to get all the leads created after that date?

1 ACCEPTED SOLUTION

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor

Re: Get all leads via rest api

For your particular task, i.e., initial export of all the leads - you can use the smart list/static list membership (i.e., create a SL/List with all people in it) as the filter in the bulk export endpoint instead of the createdAt filter. Another option would be to simply CSV export the leads from the Marketo GUI from a SL that has all the people in it, but that can certainly take much longer time to process before you can export the file than via the bulk export API, the processing time depends on your DB size. 

 

Also, with the non-bulk endpoints you'd be limited to a max of 300 records per API call. That would result in too many API calls to the Marketo if you're db size is large and an effort to automate the process of calling the endpoint until the moreResult flag is returned as true in the reponse (clearly, manually calling the REST API with the nextpage token until all the records are exported is not a viable option).

 

Best,
Darshil

View solution in original post

3 REPLIES 3
Darshil_Shah1
Level 10 - Community Advisor

Re: Get all leads via rest api

The leadchanges API endpoint returns the person created info and the change data value activities for the fields and leadids passed in the query parameterv since the date time used to create the pagination token. The API returns a max of 300 CDV records (you can change that by setting the batchSize property in the paramter). FWIW, there's probably no limit on how back you could go for creating the pagination token, but instead you'd limited to how far back the CDV activities in Marketo are perisisted before they get purged. Also, IMO if you're just looking for an endpoint to get leads from your DB then you may use the query leads/bulk extract API endpoints instead of leadchanges API.

 

Best,
Darshil
vijayp
Level 1

Re: Get all leads via rest api

Thanks @Darshil_Shah1  for your response. How can I check what's the limit after which CDV activities are purged? I want to get all leads initially from my marketo instance but neither the get leads endpoint nor the bulk leads end point suffices my requirement. The get leads endpoint has a threshold of 1000 records after which it throws error. The bulk endpoint expects me to pass filter. The best filter that I can use is created date but it also has  limit of just 1 month.

If I get the exhaustive list of leads initially, I can use the changes api to get new leads daily. But the problem is with the first initial operation. Please suggest.

Darshil_Shah1
Level 10 - Community Advisor

Re: Get all leads via rest api

For your particular task, i.e., initial export of all the leads - you can use the smart list/static list membership (i.e., create a SL/List with all people in it) as the filter in the bulk export endpoint instead of the createdAt filter. Another option would be to simply CSV export the leads from the Marketo GUI from a SL that has all the people in it, but that can certainly take much longer time to process before you can export the file than via the bulk export API, the processing time depends on your DB size. 

 

Also, with the non-bulk endpoints you'd be limited to a max of 300 records per API call. That would result in too many API calls to the Marketo if you're db size is large and an effort to automate the process of calling the endpoint until the moreResult flag is returned as true in the reponse (clearly, manually calling the REST API with the nextpage token until all the records are exported is not a viable option).

 

Best,
Darshil