Unofficial Earth2 API wrapper library and CLI tools for Node.js/TypeScript and Python. This library provides read-only access to Earth2's public APIs for market data, leaderboards, property information, and more.
Note: This is an unofficial wrapper and is not affiliated with Earth2. It only includes read-only operations and excludes any automation for raiding, dispensing, charging, jewel management, or civilian operations.
- 🌍 Comprehensive API Coverage: Access to all major Earth2 public endpoints
- 🔧 Dual Language Support: Both Node.js/TypeScript and Python implementations
- 🖥️ CLI Tools: Command-line interfaces for both platforms
- 📊 Market Data: Search marketplace, get trending places, calculate floor prices
- 🏆 Leaderboards: Access player, country, and player-country leaderboards
- 🏠 Property Information: Get detailed property and resource data
- 👤 User Data: Fetch public user information and profiles
- 🎮 Avatar Sales: Track recent avatar skin sales
- 🔐 Authentication Support: Optional cookie/CSRF token authentication for private data (
⚠️ No 2FA/TOTP support) - 🛡️ Built-in Safeguards: Comprehensive rate limiting and abuse prevention to protect Earth2's bandwidth
- 📈 Usage Monitoring: Real-time statistics and efficiency tracking
- 💾 Smart Caching: Intelligent response caching to reduce API load
This wrapper does not support Two-Factor Authentication (2FA) or TOTP. The authentication methods only work with accounts that use basic email/password authentication. If your Earth2 account has 2FA enabled:
- ❌
e2 logincommand will fail - ❌ Programmatic
authenticate()method will fail - ✅ Manual cookie extraction still works (see Authentication section)
- ✅ All public endpoints work without authentication
This wrapper only provides read-only access to Earth2's APIs. It excludes any automation for:
- Raiding, dispensing, charging
- Jewel management
- Civilian operations
- Any game mechanics that could affect gameplay
- Landing metrics and trending places
- Property details by ID
- Public user information
- Market (requires authentication)
- Leaderboard (requires authentication)
- Resource data for properties (requires authentication)
- Territory release winners (requires authentication)
- Leaderboards (players, countries, player countries) (requires authentication)
- Marketplace search with advanced filtering (requires authentication)
- Market floor price discovery (requires authentication)
- Avatar sales data (requires authentication)
Direct from GitHub (Recommended):
# Install directly from GitHub
npm install https://github.com/EugeneBoondock/earth2_api_wrapper.git#main:node
# Or with Bun
bun install https://github.com/EugeneBoondock/earth2_api_wrapper.git#main:node
# For global CLI access
npm install -g https://github.com/EugeneBoondock/earth2_api_wrapper.git#main:nodeFrom npm (Now Available!):
# Install from npm
npm install earth2-api-wrapper
# Or with Bun
bun install earth2-api-wrapper
# Or install globally for CLI access
npm install -g earth2-api-wrapperDirect from GitHub (Recommended):
# Install directly from GitHub
pip install git+https://github.com/EugeneBoondock/earth2_api_wrapper.git#subdirectory=pythonFrom PyPI (Now Available!):
# Install from PyPI
pip install earth2-api-wrapperFor development:
git clone https://github.com/EugeneBoondock/earth2_api_wrapper.git
cd earth2_api_wrapper/python
pip install -e .import { Earth2Client } from 'earth2-api-wrapper';
const client = new Earth2Client();
// Get trending places
const trending = await client.getTrendingPlaces();
console.log(trending.data);
// Search marketplace
const market = await client.searchMarket({
country: 'AU',
landfieldTier: 1,
tileCount: '5-50',
page: 1,
items: 100
});
console.log(market.items);
// Get property details
const property = await client.getProperty('property-uuid-here');
console.log(property);from earth2_api_wrapper import Earth2Client
client = Earth2Client()
# Get trending places
trending = client.get_trending_places()
print(trending['data'])
# Search marketplace
market = client.search_market(
country='AU',
landfieldTier='1',
tileCount='5-50',
page=1,
items=100
)
print(market['items'])
# Get property details
property_data = client.get_property('property-uuid-here')
print(property_data)Both Node.js and Python versions include CLI tools with built-in safeguards.
# Authentication (OAuth flow)
e2 login --email your@email.com --password yourpassword
e2 check-session # Verify session is still valid
# Data commands with beautiful formatted output
e2 trending # 🌍 Trending places in a nice table
e2 market --country AU # 🏪 Marketplace search with formatting
e2 leaderboard --type players # 🏆 Leaderboards with colors
# Raw JSON output (for scripts/automation)
e2 trending --json
e2 market --country AU --json
# Rate limiting and monitoring commands
e2 stats # 📊 Show usage statistics and efficiency
e2 clear-cache # 🗑️ Clear response cache
e2 set-cache-ttl 600000 # ⏱️ Set cache TTL (milliseconds)
# Other commands
e2 property <uuid>
e2 resources <uuid>
e2 avatar-sales
e2 user <user-id>
e2 my-favorites # Requires auth# Authentication (OAuth flow)
e2 login --email your@email.com --password yourpassword
e2 check-session # Verify session is still valid
# Data commands with beautiful formatted output
e2 trending # 🌍 Trending places in a nice table
e2 market --country AU # 🏪 Marketplace search with formatting
e2 leaderboard --type players # 🏆 Leaderboards with colors
# Raw JSON output (for scripts/automation)
e2 trending --json
e2 market --country AU --json
# Rate limiting and monitoring commands
e2 stats # 📊 Show usage statistics and efficiency
e2 clear-cache # 🗑️ Clear response cache
e2 set-cache-ttl 600 # ⏱️ Set cache TTL (seconds)
# Other commands
e2 property <uuid>
e2 resources <uuid>
e2 avatar-sales
e2 user <user-id>
e2 my-favorites # Requires authNote: The CLI now features beautiful formatted tables, colors, and emojis for better readability. Use the
--jsonflag on any command to get raw JSON output for scripting purposes.
The wrapper provides multiple ways to authenticate with Earth2 for accessing private endpoints like favorites.
⚠️ Important Limitation: This wrapper currently does NOT support TOTP/2FA authentication. It only supports basic email/password authentication. If your Earth2 account has Two-Factor Authentication (2FA) or TOTP enabled, the authentication will fail. You'll need to either:
- Temporarily disable 2FA on your Earth2 account (not recommended for security)
- Use manual cookie extraction (Method 3 below)
- Use the wrapper only for public endpoints that don't require authentication
The wrapper handles Earth2's complex Kinde OAuth authentication flow automatically for accounts without 2FA:
# Interactive login with OAuth flow
e2 login --email your@email.com --password yourpassword
# Or using environment variables
export E2_EMAIL="your@email.com"
export E2_PASSWORD="yourpassword"
e2 loginThe login process will:
- Navigate through Earth2's OAuth redirects
- Handle the Kinde authentication flow
- Extract and store session cookies
- Validate the session
After successful login, you can use authenticated endpoints:
e2 my-favorites
e2 check-session # Verify your session is still validThe wrapper automatically handles the complex OAuth flow programmatically for accounts without 2FA:
import { Earth2Client } from 'earth2-api-wrapper';
const client = new Earth2Client();
// Perform OAuth authentication
const result = await client.authenticate('your@email.com', 'yourpassword');
if (result.success) {
console.log('✓ OAuth authentication successful!');
// Check session validity
const sessionCheck = await client.checkSessionValidity();
if (sessionCheck.isValid) {
// Now you can use authenticated endpoints
const favorites = await client.getMyFavorites();
}
} else {
console.error('✗ OAuth authentication failed:', result.message);
}from earth2_api_wrapper import Earth2Client
client = Earth2Client()
# Perform OAuth authentication
result = client.authenticate('your@email.com', 'yourpassword')
if result['success']:
print('✓ OAuth authentication successful!')
# Check session validity
session_check = client.check_session_validity()
if session_check['isValid']:
# Now you can use authenticated endpoints
favorites = client.get_my_favorites()
else:
print('✗ OAuth authentication failed:', result['message'])If you already have session cookies and CSRF tokens, or if your account has 2FA enabled:
export E2_COOKIE="your-cookie-string"
export E2_CSRF="your-csrf-token"// Node.js
const client = new Earth2Client({
cookieJar: 'your-cookie-string',
csrfToken: 'your-csrf-token'
});# Python
client = Earth2Client(
cookie_jar='your-cookie-string',
csrf_token='your-csrf-token'
)If your Earth2 account has 2FA/TOTP enabled, you'll need to manually extract cookies:
- Login to Earth2 manually in your browser with 2FA
- Open Developer Tools (F12)
- Go to Application/Storage tab → Cookies →
https://app.earth2.io - Copy relevant cookies (look for session-related cookies)
- Find CSRF token in:
- Network tab → any API request → Request Headers → look for
X-CSRF-TOKEN - Or in page source → search for
csrfortoken
- Network tab → any API request → Request Headers → look for
Example cookie extraction:
# Set environment variables with extracted values
export E2_COOKIE="session_id=abc123; auth_token=xyz789; other_cookies=..."
export E2_CSRF="your-csrf-token-here"
# Now use the CLI
e2 my-favoritesThis wrapper includes comprehensive safeguards to prevent abuse and protect Earth2's bandwidth:
- Per-endpoint limits: Different limits for different API categories
- Global rate limiting: 200 requests per minute maximum
- Burst protection: Max 10 requests per 10 seconds
- Exponential backoff: Automatic retry delays on errors
# Check your usage statistics
e2 statsExample output:
📊 API Usage Statistics
┌─────────────────┬─────────┐
│ Metric │ Value │
├─────────────────┼─────────┤
│ Total Requests │ 1,250 │
│ Blocked Requests│ 15 │
│ Current RPM │ 45 │
│ Cache Size │ 234 │
│ Efficiency │ 98.8% │
└─────────────────┴─────────┘
- 5-minute default TTL for GET requests
- Automatic cache management (max 1000 entries)
- Configurable cache duration
- Significant bandwidth reduction
// Node.js - Only for testing/development
const client = new Earth2Client({ respectRateLimits: false });# Python - Only for testing/development
client = Earth2Client(respect_rate_limits=False)// Node.js
const stats = client.getRateLimitStats();
client.clearCache();
client.setCacheTtl(600000); // 10 minutes# Python
stats = client.get_rate_limit_stats()
client.clear_cache()
client.set_cache_ttl(600) # 10 minutesFor detailed information about the safeguards, see SAFEGUARDS.md.
// Node.js
const floor = await client.getMarketFloor({
country: 'AU',
landfieldTier: '1',
tileClass: '1'
});
console.log(`Floor price: ${floor?.ppt} (source: ${floor?.source})`);# Python - Note: Python version uses general market search for floor discovery
market = client.search_market(country='AU', landfieldTier='1', items=1)
if market['items']:
print(f"Floor price: {market['items'][0]['ppt']}")// Node.js
const players = await client.getLeaderboardPlayers({
sort_by: 'tiles_count',
country: 'AU'
});
const countries = await client.getLeaderboardCountries({
sort_by: 'tiles_count'
});# Python
players = client.get_leaderboard('players', sort_by='tiles_count', country='AU')
countries = client.get_leaderboard('countries', sort_by='tiles_count')// Node.js
const users = await client.getUsers(['user-id-1', 'user-id-2']);# Python
users = client.get_users(['user-id-1', 'user-id-2'])With npm:
cd node
npm install
npm run build
npm test # If tests are availableWith Bun:
cd node
bun install
bun run build
bun test # If tests are availablecd python
pip install -e .
# Run CLI commands for testing
python -m earth2_api_wrapper.cli trending| Method | Node.js | Python | Description |
|---|---|---|---|
| Landing Metrics | getLandingMetrics() |
get_landing_metrics() |
Get landing page metrics |
| Trending Places | getTrendingPlaces() |
get_trending_places() |
Get trending locations |
| Territory Winners | getTerritoryReleaseWinners() |
get_territory_release_winners() |
Get territory release winners |
| Property Details | getProperty(id) |
get_property(id) |
Get property information |
| Market Search | searchMarket(query) |
search_market(**params) |
Search marketplace |
| Market Floor | getMarketFloor(params) |
N/A (use search_market) | Get minimum price per tile |
| Player Leaderboard | getLeaderboardPlayers(params) |
get_leaderboard('players', **params) |
Get player rankings |
| Country Leaderboard | getLeaderboardCountries(params) |
get_leaderboard('countries', **params) |
Get country rankings |
| Player Country LB | getLeaderboardPlayerCountries(params) |
get_leaderboard('player_countries', **params) |
Get player-country rankings |
| Resources | getResources(propertyId) |
get_resources(property_id) |
Get property resources |
| Avatar Sales | getAvatarSales() |
get_avatar_sales() |
Get avatar sales data |
| User Info | getUserInfo(userId) |
get_user_info(user_id) |
Get user information |
| Bulk Users | getUsers(userIds) |
get_users(user_ids) |
Get multiple users |
| My Favorites | getMyFavorites() |
get_my_favorites() |
Get user favorites (auth required) |
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This is an unofficial API wrapper and is not affiliated with Earth2. Use at your own risk.
Important limitations:
- Only provides read-only access to public APIs
- Does not include automation features for game mechanics
- Does NOT support 2FA/TOTP authentication - only basic email/password
- Authentication may fail if Earth2 changes their OAuth flow
Problem: e2 login fails or authenticate() method returns error
Common causes:
-
2FA/TOTP enabled: This wrapper does NOT support 2FA
- Solution: Use manual cookie extraction (Method 3 above)
-
Incorrect credentials: Double-check email and password
- Solution: Verify credentials by logging into Earth2 website manually
-
Earth2 OAuth changes: Earth2 may have updated their authentication flow
- Solution: Use manual cookie extraction as a workaround
Problem: "Rate limit exceeded" during authentication
Solution: The wrapper limits authentication attempts to prevent abuse. Wait a few minutes and try again.
Problem: API requests fail with 401/403 errors
Solution:
- Check if your session is still valid:
e2 check-session - Re-authenticate if needed
- For 2FA accounts, extract fresh cookies
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information about your problem
- Include code examples and error messages when applicable
- For authentication issues: Specify if your account has 2FA enabled
Made with ❤️ for the Earth2 community