Giter Site home page Giter Site logo

taishi8117 / canopi-js Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 257 KB

Canopi Climate API client library for JavaScript

Home Page: https://www.canopi.cash/api-docs

TypeScript 100.00%
nodejs javascript typescript npm api climate carbon-footprint carbon-emissions api-client

canopi-js's Introduction

Canopi Climate API client for TypeScript

An API client for Canopi Climate API.

Installation

npm install canopi-climate

Example

const canopi = require('canopi-climate');
const moment = require('moment');

const API_KEY = process.env.CANOPI_API_KEY;

const {
    Client
} = canopi;
const client = new Client({
    apiKey: API_KEY,
});

const projects = await client.getProjects();
console.log('Canopi portfolio projects:')
console.log(projects);

const crypto_footprint = await client.calculateCryptoAverageEmissions(
    'BTC',
    0.75,
    moment().subtract(1, 'year').toDate(),
    moment().toDate(),
);
console.log('Footprint of holding 0.75 BTC for a year:')
console.log(crypto_footprint)

const txn_footprints = await client.calculateTransactionEmissions([{
    amount: {
        value: 120.50,
        currency: 'USD',
    },
    reference: 'Test transaction',
    timestamp: moment().toDate(),
    // airlines
    plaid_category_code: "22001000",
    note: "Flight ticket",
    name: "United Airlines",
    merchant_name: "United Airlines",
}]);
console.log("Footprint of a financial transaction:")
console.log(txn_footprints['footprints'][0]);

const stats = await client.getMyStats();
console.log('My stats:')
console.log(stats);

const orders = await client.listOrders();
console.log('My orders:');
console.log(orders);

canopi-js's People

Contributors

taishi8117 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.