66 lines
1.1 KiB
Markdown
66 lines
1.1 KiB
Markdown
# Wren API Tutorial (Node.js)
|
|
|
|
This example demonstrates how to use the Wren API to:
|
|
1. Fetch available offset projects
|
|
2. Create a carbon offset order
|
|
|
|
## Setup
|
|
|
|
1. Install dependencies:
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
2. Create a `.env` file with your Wren API token:
|
|
```
|
|
WREN_API_TOKEN=your-token-here
|
|
```
|
|
|
|
3. Run the example:
|
|
```bash
|
|
npm start
|
|
```
|
|
|
|
## API Documentation
|
|
|
|
For full API documentation, visit: https://wren.co/api
|
|
|
|
## Features
|
|
|
|
- Environment variable configuration
|
|
- Error handling
|
|
- Project listing
|
|
- Order creation
|
|
- Response parsing
|
|
|
|
## Sample Output
|
|
|
|
```
|
|
Fetching available offset projects...
|
|
Found 3 projects:
|
|
|
|
- Direct Air Carbon Capture (Iceland)
|
|
Price: $250/ton
|
|
Type: Direct Air Capture
|
|
|
|
- Coastal Mangrove Restoration (Indonesia)
|
|
Price: $150/ton
|
|
Type: Nature-Based
|
|
|
|
- Ocean Carbon Removal (Global Oceans)
|
|
Price: $200/ton
|
|
Type: Ocean-Based
|
|
|
|
Creating offset order for 1 ton of CO2...
|
|
|
|
Order created successfully!
|
|
------------------------
|
|
Order ID: ord_123abc
|
|
Amount: $200
|
|
Status: completed
|
|
Portfolio: Standard Portfolio
|
|
|
|
Portfolio projects:
|
|
- Direct Air Carbon Capture
|
|
- Coastal Mangrove Restoration
|
|
``` |