Official JavaScript SDK for 1ClickImpact - Easily integrate impact actions into your applications
npm install makeimpact
# or
yarn add makeimpact
# or
pnpm add makeimpactYou'll need an API key to use this SDK. You can get your API key from the 1ClickImpact Account API Keys page.
import { OneClickImpact, Environment } from "makeimpact";
// Initialize the SDK with your API key (production environment by default)
const sdk = new OneClickImpact("your_api_key");
// Create environmental impact with just a few lines of code
await sdk.plantTree({ amount: 1 });
await sdk.cleanOcean({ amount: 5 });
await sdk.captureCarbon({ amount: 2 });
await sdk.restoreCoral({ amount: 20 });Help combat deforestation and climate change by planting trees.
// Plant a single tree
await sdk.plantTree({ amount: 1 });
// Plant trees with a specific category
await sdk.plantTree({ amount: 10, category: "food" });
// Plant trees with customer tracking
await sdk.plantTree({
amount: 5,
customerEmail: "customer@example.com",
customerName: "John Doe",
});Remove plastic waste from our oceans to protect marine life.
// Clean 5 pounds of ocean plastic
await sdk.cleanOcean({ amount: 5 });
// Clean ocean plastic with customer tracking
await sdk.cleanOcean({
amount: 10,
customerEmail: "customer@example.com",
customerName: "John Doe",
});Reduce greenhouse gas emissions by capturing carbon.
// Capture 2 pounds of carbon
await sdk.captureCarbon({ amount: 2 });
// Capture carbon with customer tracking
await sdk.captureCarbon({
amount: 5,
customerEmail: "customer@example.com",
customerName: "John Doe",
});Support any cause through direct monetary donations.
// Donate $1.00 (amount in cents)
await sdk.donateMoney({ amount: 100 });
// Donate to a specific cause category
await sdk.donateMoney({ amount: 500, category: "veterans" }); // $5.00
// Donate with customer tracking
await sdk.donateMoney({
amount: 500, // $5.00
category: "climate",
customerEmail: "customer@example.com",
customerName: "John Doe",
});Note: To set up a custom cause for donations, please contact 1ClickImpact directly. All causes must be vetted and approved to ensure they meet their standards for transparency and impact.
Rebuild damaged coral reefs by funding the restoration of coral fragments.
// Restore 20 coral fragments
await sdk.restoreCoral({ amount: 20 });
// Restore coral with customer tracking
await sdk.restoreCoral({
amount: 50,
customerEmail: "customer@example.com",
customerName: "John Doe",
});Every impact action (plantTree, cleanOcean, captureCarbon, donateMoney, restoreCoral) accepts an optional metadata object of string key-value pairs. Use it to store your own identifiers alongside the impact.
// Attach metadata to any impact action
await sdk.plantTree({
amount: 5,
metadata: {
orderId: "ORD-1024",
source: "checkout",
},
});Note:
metadataallows up to 20 key-value pairs. Keys can be at most 40 characters and values at most 500 characters. The reserved keys"gift"and"widgetID"cannot be used.
Cancel and reverse a previously created impact. This is designed for refund flows and is idempotent — calling it again for the same impact returns the same result without double-reversing your aggregates (the response message will read "impact was already cancelled").
Use the userID and timeUTC from the original impact response (or from getRecords() / getCustomerRecords()) to identify the impact to cancel.
// Cancel a previously created impact
const cancellation = await sdk.cancelImpact({
userID: "U1234",
timeUTC: "2025-03-12T15:22:14.753Z",
reason: "order refunded",
});
console.log(cancellation.message);
console.log(`Cancelled on: ${cancellation.cancelledOn}`);Retrieve impact records with optional filtering.
// Get all records
const records = await sdk.getRecords();
// Filter records by type
// filterBy accepts: "tree_planted", "waste_removed", "carbon_captured", "coral_restored", "money_donated"
const treeRecords = await sdk.getRecords({
filterBy: "tree_planted",
});
// Filter for coral restoration records
const coralRecords = await sdk.getRecords({
filterBy: "coral_restored",
});
// Filter records by date range
const recentRecords = await sdk.getRecords({
startDate: "2023-01-01",
endDate: "2023-12-31",
});
// Pagination
const paginatedRecords = await sdk.getRecords({
cursor: "<cursor_from_previous_response>",
limit: 10,
});Retrieve records for specific customers.
// Get records for a specific customer
const customerRecords = await sdk.getCustomerRecords({
customerEmail: "customer@example.com",
});
// Filter customer records by type
const customerTreeRecords = await sdk.getCustomerRecords({
customerEmail: "customer@example.com",
filterBy: "tree_planted",
});Retrieve customer information.
// Get all customers (default limit is 10)
const customers = await sdk.getCustomers();
// Get customers with filtering and pagination
const filteredCustomers = await sdk.getCustomers({
customerEmail: "example@email.com", // Optional: Filter by email
limit: 50, // Optional: Limit results (1-1000)
cursor: "<cursor_from_previous_response>", // Optional: For pagination
});Track the complete lifecycle and current status of a specific impact. Get real-time tracking information including project location with maps, assigned agents, completion status, impact documentation, and live session details.
// Create an impact and track it
const plantResponse = await sdk.plantTree({ amount: 1 });
// Track the impact using the userID and timeUTC from the response
const trackingInfo = await sdk.track({
userID: plantResponse.userID,
timeUTC: plantResponse.timeUTC,
});
console.log(`Tracking ID: ${trackingInfo.trackingID}`);
console.log(`Impact Initiated: ${trackingInfo.impactInitiated}`);
// Check impact details
if (trackingInfo.treePlanted) {
console.log(`Trees planted: ${trackingInfo.treePlanted}`);
}
// Check project information (when available)
if (trackingInfo.projectID) {
console.log(`Project ID: ${trackingInfo.projectID}`);
}
if (trackingInfo.assignedAgent) {
console.log(`Assigned Agent: ${trackingInfo.assignedAgent}`);
}
if (trackingInfo.projectLocation) {
console.log(`Project Location: ${trackingInfo.projectLocation}`);
}
if (trackingInfo.locationMap) {
console.log(`View Map: ${trackingInfo.locationMap}`);
}
// Check completion status
if (trackingInfo.impactCompleted) {
console.log(`Impact Completed: ${trackingInfo.impactCompleted}`);
}
// Check for impact videos or live sessions
if (trackingInfo.impactVideo) {
console.log(`Impact Video: ${trackingInfo.impactVideo}`);
}
if (trackingInfo.liveSessionDate) {
console.log(`Live Session: ${trackingInfo.liveSessionDate}`);
}You can also track impacts from historical records:
// Get records and track a specific impact
const records = await sdk.getRecords({ limit: 1 });
if (records.userRecords.length > 0) {
const record = records.userRecords[0];
const trackingInfo = await sdk.track({
userID: record.userID,
timeUTC: record.timeUTC,
});
console.log("Tracking Info:", trackingInfo);
}Track Response Fields:
trackingID: Unique identifier for this impact (format:userID-timeUTC)impactInitiated: UTC timestamp when the impact was createdtreePlanted,wasteRemoved,carbonCaptured,coralRestored,moneyDonated: Impact metrics (optional)category: Impact category (e.g., "food" for food-bearing trees)donationAvailable: When the donation became available for the projectdonationSent: When the donation was sent to the non-profitassignedAgent: Name of the agent or organization executing the impactprojectLocation: Detailed description of project location and partnerslocationMap: Google Maps embed URL for the project locationimpactCompleted: When the impact was completeddonationCategory: Type of impact funded (for donations)certificate: Certificate URL for the impact (only in production)impactVideo: URL to video recording or live sessionliveSessionDate: Scheduled live session timestampprojectID: ID of the project assigned to this impact (when available)isTestTransaction: Whether this was a test transactionisBonusImpact: Whether this was a bonus impact from subscription planscancelledOn: When the impact was cancelled (present only for cancelled impacts)cancellationReason: Reason provided when the impact was cancelled (optional)
Retrieve available environmental impact projects.
// Get all projects
const projects = await sdk.getProjects();
// Filter by impact type
const treeProjects = await sdk.getProjects({ type: "trees" });
const oceanProjects = await sdk.getProjects({ type: "ocean" });
const carbonProjects = await sdk.getProjects({ type: "carbon" });
// Get projects in a specific language
const germanProjects = await sdk.getProjects({ locale: "de" });
projects.projects.forEach((project) => {
console.log(`${project.projectID}: ${project.name} (${project.location})`);
});Retrieve full details for a specific project.
const project = await sdk.getProjectById("PROJECT_ID");
console.log(`Name: ${project.name}`);
console.log(`Type: ${project.type}`);
console.log(`Location: ${project.location}`);
console.log(`Organization: ${project.organization}`);
console.log(`Available: ${project.available}`);
// SDG alignments
project.sdgs.forEach((sdg) => {
console.log(`SDG ${sdg.number}: ${sdg.title}`);
});
// Get project in a specific language
const project_es = await sdk.getProjectById("PROJECT_ID", { locale: "es" });Project Fields:
projectID: Unique project identifiername: Project nametype: Impact type ("trees","ocean", or"carbon")location: Project location namedescription: Short project descriptionabout: Detailed project informationcountryCode: ISO country codeorganization: Executing organization namesdgs: Array of UN Sustainable Development Goals this project aligns withimageUrls: Array of project image URLslatitude,longitude: Project coordinatesavailable: Whether the project is currently active
Get aggregated impact statistics with breakdown between your organization's direct impact and customer impact.
// Get overall impact statistics for your organization
const impact = await sdk.getImpact();
console.log(`Total trees planted: ${impact.treePlanted}`);
console.log(`Total ocean waste removed: ${impact.wasteRemoved} lbs`);
console.log(`Total carbon captured: ${impact.carbonCaptured} lbs`);
console.log(`Total coral restored: ${impact.coralRestored} fragments`);
console.log(`Total money donated: $${impact.moneyDonated / 100}`);
// View breakdown by impact source
console.log("\nYour organization's direct impact:");
console.log(`Trees: ${impact.userImpact.treePlanted}`);
console.log(`Ocean waste: ${impact.userImpact.wasteRemoved} lbs`);
console.log(`Carbon: ${impact.userImpact.carbonCaptured} lbs`);
console.log(`Coral: ${impact.userImpact.coralRestored} fragments`);
console.log(`Donations: $${impact.userImpact.moneyDonated / 100}`);
console.log("\nCustomer impact:");
console.log(`Trees: ${impact.customerImpact.treePlanted}`);
console.log(`Ocean waste: ${impact.customerImpact.wasteRemoved} lbs`);
console.log(`Carbon: ${impact.customerImpact.carbonCaptured} lbs`);
console.log(`Coral: ${impact.customerImpact.coralRestored} fragments`);
console.log(`Donations: $${impact.customerImpact.moneyDonated / 100}`);Retrieve a time-series of your daily impact data to track progress and analyze patterns over time.
// Get all daily impact data
const dailyImpact = await sdk.getDailyImpact();
console.log(`User ID: ${dailyImpact.userID}`);
console.log(`Total days with impact: ${dailyImpact.dailyImpact.length}`);
// Display daily impact records
dailyImpact.dailyImpact.forEach((record) => {
console.log(`\nDate: ${record.date}`);
console.log(`Trees planted: ${record.treePlanted}`);
console.log(`Ocean waste removed: ${record.wasteRemoved} lbs`);
console.log(`Carbon captured: ${record.carbonCaptured} lbs`);
console.log(`Coral restored: ${record.coralRestored} fragments`);
console.log(`Money donated: $${record.moneyDonated / 100}`);
});
// Filter by date range
const filteredImpact = await sdk.getDailyImpact({
startDate: "2025-01-01",
endDate: "2025-12-31",
});Verify your API key and get account information.
// Verify API key and get account information
const accountInfo = await sdk.whoAmI();The SDK supports two environments:
- Production (default): Uses the live API at
https://api.1clickimpact.com - Sandbox: Uses the testing API at
https://sandbox.1clickimpact.com
To use the sandbox environment for testing:
import { OneClickImpact, Environment } from "makeimpact";
// Initialize with sandbox environment
const sdk = new OneClickImpact("your_test_api_key", Environment.SANDBOX);MIT