makeimpact
v1.3.0
Published
Official JavaScript SDK for 1ClickImpact
Maintainers
Readme
🌱 MakeImpact
Official JavaScript SDK for 1ClickImpact - Easily integrate impact actions into your applications
📦 Installation
npm install makeimpact
# or
yarn add makeimpact
# or
pnpm add makeimpact🚀 Getting Started
You'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 });🌍 Environmental Impact Actions
🌳 Plant Trees
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: "[email protected]",
customerName: "John Doe",
});🌊 Clean Ocean Plastic
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: "[email protected]",
customerName: "John Doe",
});♻️ Capture Carbon
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: "[email protected]",
customerName: "John Doe",
});💰 Donate Money
Support any cause through direct monetary donations.
// Donate $1.00 (amount in cents)
await sdk.donateMoney({ amount: 100 });
// Donate with customer tracking
await sdk.donateMoney({
amount: 500, // $5.00
customerEmail: "[email protected]",
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.
📊 Data Access & Reporting
Get Records
Retrieve impact records with optional filtering.
// Get all records
const records = await sdk.getRecords();
// Filter records by type
const treeRecords = await sdk.getRecords({
filterBy: "tree_planted",
});
// 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,
});Get Customer Records
Retrieve records for specific customers.
// Get records for a specific customer
const customerRecords = await sdk.getCustomerRecords({
customerEmail: "[email protected]",
});
// Filter customer records by type
const customerTreeRecords = await sdk.getCustomerRecords({
customerEmail: "[email protected]",
filterBy: "tree_planted",
});Get Customers
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: "[email protected]", // Optional: Filter by email
limit: 50, // Optional: Limit results (1-1000)
cursor: "<cursor_from_previous_response>", // Optional: For pagination
});🔍 Track Impact
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,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 plans
Get Projects
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})`);
});Get Project by ID
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 Impact
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 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(`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(`Donations: $${impact.customerImpact.moneyDonated / 100}`);Get Daily Impact
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(`Money donated: $${record.moneyDonated / 100}`);
});
// Filter by date range
const filteredImpact = await sdk.getDailyImpact({
startDate: "2025-01-01",
endDate: "2025-12-31",
});Who Am I
Verify your API key and get account information.
// Verify API key and get account information
const accountInfo = await sdk.whoAmI();⚙️ Configuration
Environments
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);🔗 Additional Resources
📄 License
MIT
