This library is a fluent style API client for Pardot's API (version 3 and 4).
From February 1, 2021 Pardot is removing the ability to authenticate to the Pardot API using your Pardot username, password, and userkey (Salesforce EOL Notice). This means that versions of this library prior to 3.0.0 will cease to be able to authenticate to the Pardot Api.
Everyone is encouraged to update the library to version 3.0.0 or newer and switch to using Salesforce SSO authentication prior to February 1, 2021. To support Salesforce SSO authentication required backwards compatibility breaking changes to be made to this library, so please read the 2.x.x to 3.0.0 Migration Guide which details the changes required to upgrade.
Note While most of Pardot's API is supported by this library, if there is a feature/end point that you need that is not yet implemented, please read the How to Contribute section, or Create an issue requesting it.
Note Use this library at your own risk! Currently there are no known issues, but as an unofficial library, there are no guarantees.
This client library is released on Maven Central. Add a new dependency to your project's POM file:
<dependency>
<groupId>com.darksci</groupId>
<artifactId>pardot-api-client</artifactId>
<version>4.0.0</version>
</dependency>
Example Code using Salesforce SSO Authentication:
/*
* Create a new configuration object with your Salesforce SSO credentials.
*
* This configuration also allows you to define some optional details on your connection,
* such as using an outbound proxy (authenticated or not).
*/
final ConfigurationBuilder configuration = Configuration.newBuilder()
// This configures the client using the 'password' authentication flow.
.withSsoLogin(
"YourSalesforceUsername",
"YourSalesforcePassword",
"YourConnectedAppClientId",
"YourConnectedAppClientSecret",
"YourPardotBusinessUnitId"
);
/*
* Alternatively, if you want to use the authorization_code authentication flow,
* you can configure the client using a previously acquired refresh_token:
*/
Configuration.newBuilder()
// This configures the client using the 'authorization_code' authentication flow.
.withSsoRefreshTokenLogin(
"PreviousAcquiredRefreshTokenHere",
"YourConnectedAppClientId",
"YourConnectedAppClientSecret",
"YourPardotBusinessUnitId"
);
/*
* Optionally you can explicitly select which API version to use. If none is explicitly selected
* the library will default to version 3, but the library will automatically upgrade to version
* 4 if required to do so.
*/
configuration.withApiVersion3();
/* Or */
configuration.withApiVersion4();
/*
* Create an instance of PardotClient, passing your configuration.
*/
final PardotClient client = new PardotClient(configuration);
/*
* The client will automatically authenticate when you make your first request, no need to
* explicitly login.
*
* Lets create a simple Account request, and execute it.
*/
final AccountReadRequest accountReadRequest = new AccountReadRequest();
final Account account = client.accountRead(accountReadRequest);
/*
* Or lets do a more complex Campaign search.
*/
final CampaignQueryRequest campaignQueryRequest = new CampaignQueryRequest()
.withUpdatedAfter(DateParameter.last7Days())
.withIdLessThan(1234L)
.withSortById()
.withSortOrderDescending();
final CampaignQueryResponse.Result campaignQueryResponse = client.campaignQuery(campaignQueryRequest);
/*
* And when you're done, call close on PardotClient.
*/
client.close();
Or Using the Try-With-Resources Pattern:
/*
* Since PardotClient implements Autoclosable, you can also use the try-with-resources pattern.
*/
try (final PardotClient client = new PardotClient(configuration)) {
// Use client instance as needed
client.accountRead(new AccountReadRequest());
// client.close() is automatically called at the end of the try {} block.
}
Official Documentation: Authentication
- Authenticating with Pardot's API using your Salesforce SSO Username, Password, and Connected Application details. See Example.
- Authenticating with Pardot's API using a Salesforce SSO refresh_token and Connected Application details. See Example.
- Authenticating with Pardot's API using Salesforce SSO against Test / Sandbox orgs. See Example.
- Legacy authentication using your Pardot Username, Password, and User Token. See Example.
Official Documentation: Accounts
- Read
Official Documentation: Campaigns
- Create
- Query
- Read
- Update
Official Documentation: Custom Fields
- Create
- Query
- Read
- Update
Official Documentation: Custom Redirects
- Query
- Read
Official Documentation: Dynamic Content
- Query
- Read
Official Documentation: Emails
- Read
- Sending List Emails
- Sending One to One Emails
- Stats
Official Documentation: Email Clicks
- Query
Official Documentation: Email Templates
- List One to One templates
- Read
Official Documentation: Forms
- Create
- Delete
- Query
- Read
- Update
Official Documentation: Lists
- Create
- Query
- Read
- Update
Official Documentation: ListMemberships
- Create
- Query
- Read
- Update
Official Documentation: Opportunities
- Create
- Delete
- Query
- Read
- Undelete
- Update
Official Documentation: Prospects
- Assign
- Create - Does not support multiple values for record-multiple fields.
- Delete
- Query
- Read
- Unassign
- Update - Does not support multiple values for record-multiple fields.
- Upsert - Does not support multiple values for record-multiple fields.
Official Documentation: Tags
- Query
- Read
Official Documentation: TagObjects
- Query
- Read
Official Documentation: Users
- Abilities of current API User
- Query
- Read
Official Documentation: Visitors
- Assign
- Query
- Read
Official Documentation: VisitorActivities
- Query
- Read
Official Documentation: Visits
- Query
- Read
Want to help implement the missing API end points? Fork the repository, write some code, and submit a PR to the project!
Implementing new API requests really only requires implementing the two following interfaces, along with minimal glue code.
The Request interface can typically be implemented by extending either BaseRequest or BaseQueryRequest. This defines the end point that the request will hit, along with what parameters will be passed along with it.
The ResponseParser interface defines how to take the API's response and convert it back into user friendly Plain Old Java Objects (POJOs).
Steps for performing a release:
- Update release version:
mvn versions:set -DnewVersion=X.Y.Z
- Validate and then commit version:
mvn versions:commit
- Update CHANGELOG and README files.
- Merge to master.
- Deploy to Maven Central:
mvn clean deploy -P release
- Create release on Github project, uploading JAR artifacts.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.