Skip to content

Make an impact with a single API call — plant trees, clean oceans, capture CO₂, and donate to global causes.

Notifications You must be signed in to change notification settings

1ClickImpact/makeimpact-js

Repository files navigation

🌱 MakeImpact

npm version License: MIT TypeScript

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: "customer@example.com",
  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: "customer@example.com",
  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: "customer@example.com",
  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: "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.

📊 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: "customer@example.com",
});

// Filter customer records by type
const customerTreeRecords = await sdk.getCustomerRecords({
  customerEmail: "customer@example.com",
  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: "example@email.com", // 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.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 created
  • treePlanted, wasteRemoved, carbonCaptured, moneyDonated: Impact metrics (optional)
  • category: Impact category (e.g., "food" for food-bearing trees)
  • donationAvailable: When the donation became available for the project
  • donationSent: When the donation was sent to the non-profit
  • assignedAgent: Name of the agent or organization executing the impact
  • projectLocation: Detailed description of project location and partners
  • locationMap: Google Maps embed URL for the project location
  • impactCompleted: When the impact was completed
  • donationCategory: Type of impact funded (for donations)
  • impactVideo: URL to video recording or live session
  • liveSessionDate: Scheduled live session timestamp
  • isTestTransaction: Whether this was a test transaction
  • isBonusImpact: Whether this was a bonus impact from subscription plans

Get Impact

Get aggregated impact statistics.

// Get overall impact statistics for your organization
const impact = await sdk.getImpact();

console.log(`Trees planted: ${impact.treePlanted}`);
console.log(`Ocean waste removed: ${impact.wasteRemoved} lbs`);
console.log(`Carbon captured: ${impact.carbonCaptured} lbs`);
console.log(`Money donated: $${impact.moneyDonated / 100}`);

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