Earth2 API Wrapper
A powerful, open-source library for Node.js and Python to interact with the Earth2 API.
Node.js Support
Full TypeScript support for robust, type-safe development in the Node.js ecosystem.
npm install earth2-api-wrapper
Python Support
A simple and intuitive Python client, perfect for scripting, data analysis, and backend services.
pip install earth2-api-wrapper
Powerful CLI
Access Earth2 data directly from your terminal. Perfect for quick lookups and automation.
# Node.js CLI
e2 trending
e2 property <property-id>
e2 user <user-id>
# Python CLI
e2-py trending
e2-py property <property-id>
e2-py user <user-id>
Usage & Examples
import { Earth2Client } from 'earth2-api-wrapper';
// For public endpoints
const client = new Earth2Client();
// For authenticated endpoints
const clientWithAuth = new Earth2Client({
cookieJar: process.env.E2_COOKIE,
csrfToken: process.env.E2_CSRF,
});
async function getTrending() {
const trendingPlaces = await client.getTrendingPlaces();
console.log(trendingPlaces.data);
}
getTrending();
Authentication
For endpoints that require authentication (e.g., fetching your favorites or profile-specific data), you must provide your own credentials. The wrapper does not handle logging in for you.
You need to get your
It is highly recommended to store these as environment variables (E2_COOKIE
and E2_CSRF
) and not hardcode them in your scripts for security reasons.
How to get your credentials:
- Log in to the official Earth2 website.
- Open your browser's Developer Tools (usually by pressing F12 or right-clicking and selecting "Inspect").
- Go to the "Network" tab.
- Find and click on any recent API request (e.g., a request to r.earth2.io or app.earth2.io).
- In the "Headers" tab for that request, scroll down to "Request Headers".
- Find the cookie header. Copy the entire string value. This is your E2_COOKIE.
- Find the x-csrf-token header. Copy its value. This is your E2_CSRF.
This is an unofficial, community-driven project and is not affiliated with Earth2.
Contribute or report issues on the GitHub repository. GitHub repository.