mneedham91 / pypardot4 Goto Github PK
View Code? Open in Web Editor NEWPyPardot is a wrapper for Version 4 of the Pardot API, written in Python.
License: MIT License
PyPardot is a wrapper for Version 4 of the Pardot API, written in Python.
License: MIT License
This method fails
Compatibility for version 3 of the Pardot API was allowed in most recent commit (also now live on PyPi). However I have not tested it (maybe in poor form but the change left everything intact for version 4). I also not have added documentation to the wiki.
As per pardot documentation, "In the Spring '21 and later releases of the Pardot API, authentication with the API key / user key will not be supported".
How does pypardot4 is going to me impacted with this?
Hi,
I have a requirement to fetch the Visitor page view objects by using key "visitor_page_view_id" from visitor activity object. Seems that we don't have a direct API object to fetch visitor page view objects.
Can you please help me in finding the right object to fetch visitor page view objects.
Thank you.
Regards,
Surendhar
This method fails
I have created a campaign within pardot. I pass the campaign id through to the send_to_email()
function, which sends the email. But when I check the campaign in the web page, it doesn't show any history/data of the email being sent.
from pypardot.client import PardotAPI
class HandlePardotEmails():
def __init__(self):
self.dev_email = '[email protected]'
self.pw = 'some_pass'
self.api_key = 'some_key'
self.p = PardotAPI(
email=self.dev_email,
password=self.pw,
user_key=self.api_key
)
self.p.authenticate()
def pardot_emails(self, user_email, raw_email, f_name, l_name, full_name, sub, camp_id):
self.user_email = user_email
self.raw_email = raw_email
self.f_name = f_name
self.l_name = l_name
self.full_name = full_name
self.sub = sub
#send email
self.prospect = self.p.prospects.create(email=self.user_email,
first_name = self.f_name,
last_name = self.l_name)
self.user_info = self.prospect['prospect']
self.camp_id = camp_id#self.user_info['campaign_id']
self.email_content = str(self.raw_email)
self.p.emails.send_to_email(campaign_id=self.camp_id,
prospect_email=self.user_email,
name=self.full_name, subject=self.sub,
from_email='[email protected]',
from_name='Marketing - Campaign',
text_content='%%unsubscribe%%',
html_content=self.email_content)
And I call it like so;
par.pardot_emails(row['Email'], formatted_template, row['FirstName'], row['Surname'], row['FullName'], 'Subject', 55859)
I have looked at the code for the query method in both prospects.py
and tagobjects.py
and it has the following structure to ensure that a consistent list representation of the records returned is returned from the query. I agree this is a very good idea.
However, it appears to be misinterpreting the meaning of the total_results
key in the result
and consequently does not operate as I think it was intended:
# Ensure result['tagObject'] is a list, no matter what.
result = response.get('result')
if result['total_results'] == 0:
result['tagObject'] = []
elif result['total_results'] == 1:
result['tagObject'] = [result['tagObject']]
return result
This is treating the value associated with total_results
as if it represented the length of the response. However, from my experiments, this only holds true for when the results are less than the maximum page size of 200. My documentation describes total_results
as:
Contains the number of tagObjects selected by this query. If this value is higher than 200, then several query requests may be necessary to retrieve all of the matched tagObjects
My interpretation is that it is passing along how many total records are associated with the query, even though there may only be up to 200 of those records included in any actual query. This allows the calling code to continue querying the data at various offsets to collect the full results.
The code correctly identifies that there are three conditions of data being returned, but incorrectly believes that the indicator for those conditions is the total_results
value. This is only true for queries that result in less than 201 records.
I have 201 tag objects currently in our Pardot instance. When I query them the first time, I get total_results
of 201, telling me how many there are and than a list of 200 records associated with the tagObject
key in a list. When I query again, but with an offset of 200 (since the first 200 have offsets 0-199), the total_results
value is still 201 (because that is indeed how many records are associated with the query, independent of offset), and now there is only one record returned associated with tagObject
and it is not in a list. If I do the same query again, but this time with a very high offset, way past the number of records I can get, I still get a total_results
value of 201, but now there is not even a tagObject
key in the results. So, I suggest, the fix for this code looks like this:
# Ensure result['tagObject'] is a list, no matter what.
result = response.get('result')
if 'tagObject' not in result:
result['tagObject'] = []
elif len(result['tagObject']) == 1:
result['tagObject'] = [result['tagObject']]
return result
I have not tested this code, but I believe it will perform the correct actions to normalize the value associated with the tagObject
to always be present and be associated with a list. Of course, this would have to be adapted to each of the classes (prospects, tags, ...).
Hello,
I am using your api wrapper (thank you by the way) and I am trying to make queries for the prospects object with output=full flag as described in the documentation here:
http://developer.pardot.com/kb/api-version-4/prospects/#using-prospects
I am trying to see if there is additional data fields and user activity that might be available.
Additionally, do you happen to know if there is a way to query the forms objects and get the actual form submission data rather than downloading it via back end?
Please advise
Thank you for your time,
MZ
Hello,
Love this api. Thank you.
Question, will this api be supported for the upcoming Pardot User Migration: https://help.salesforce.com/articleView?id=000353870&type=1&mode=1&language=en_US&utm_source=techcomms&utm_medium=email&utm_campaign=eol
Is there support for Salesforce OATH?
thank you,
Sample code set:
from pypardot.client import PardotAPI
p = PardotAPI(
email='[email protected]',
password='password',
user_key='userkey'
)
p.authenticate()
p.prospects.batchUpdate(prospects=[{"id":"100", "field":"value"}, {"id":"101", "filed":"value"}])
Error:
pypardot.errors.PardotAPIError: Error #71: Input needs to be valid JSON or XML
Let me know the json format.
Using PyPardot version 4 to pull emails and activities (click, open, send ect.)
Looking for an example of pulling all emails and their activities.
33 of 87 methods remain untested. See Testing wiki page for list of methods as well as documentation as to whether a method is successfully tested, unsuccessfully tested, or untested.
This method fails
Hi Team,
Pardot updated their authentication requirement and prevent the usage of GET.
https://github.com/mneedham91/PyPardot4/blob/master/pypardot/client.py
Could you update the authentication function in order to use POST request instead?
More info: http://developer.pardot.com/#authentication
Kind regards
David
Trying this:
p.visits.query_by_prospect_ids(
prospect_ids=prospect,
sort_by='created_at',
sort_order='ascending',
output='bulk')
returns this:
File "/usr/local/lib/python3.6/site-packages/pypardot/objects/visits.py", line 51, in query_by_prospect_ids
if result['total_results'] == 0:
KeyError: 'total_results'
As per Pardot's documentation, this option "returns basic data for an object (does not provide total object count). Used for querying large amounts of data."
If the option output='bulk'
is entered, the code should not rely in the return of the key total_results
, because it won't be there.
This method fails
Hey, I am trying to use p.prospects.query(fields=[a_list_of_field_names])
to pull only a subset of fields from the prospects table. However, the method only returns 2 columns no matter how long my list is. The returned columns will always be id
and whatever field that is the last element in the list. Am I not passing the parameters correctly? Thank you!
How do I send an email? Does the email account need to be added before hand? I have been looking at this documentation. But cannot figure it out.
The function read_by_email
is not working for the users
. I have tested with various different emails that are correct by they all return;
PardotAPIError: Error #11: Invalid user email address
I have connected properly as I am able to access lists and send emails. But just this line of code always fails;
def get_user_id(self):
print(self.p.users.read_by_email("[email protected]"))
This method fails. It appears parameters are unexpected.
dynamicContent,
campaign,
prospectAccount
lifecyclehistories
so far I found output='bulk' does not work for these endpoints. I installed the package using pypi, is github version here ahead of Pypi package?
This method fails
Prospect query throws an AttributeError when it attempts to get the results from the response object...
PyPardot4/pypardot/objects/prospects.py
Line 21 in 5b26b87
...because the client has set it to the status code (e.g. integer) when it expects a json string:
Line 146 in 5b26b87
This method fails
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.