Generate realistic user data with accurate geographic information
Project description
Fake User Generator with Realistic Locations
A Python package that generates realistic user data with accurate geographic information for testing location-based searches and applications.
Purpose
This application automatically fetches random users and enriches them with realistic location information by:
- Realistic Country Codes: Uses proper ISO 2-alpha country codes (GB, US, DE, etc.)
- Accurate Coordinates: Provides real latitude/longitude coordinates from actual cities
- Proper Timezones: Assigns correct timezone offsets for each location (356 timezones supported)
- Population Data: Includes city population information for realistic testing
- Smart Caching: Automatically downloads and caches data to avoid repeated downloads
Perfect for testing location search functionality, timezone handling, and geographic data processing in applications.
Quick Start
Installation
pip install fakeuser
Generate Users
# Generate 100 users with realistic locations
fakeuser 100
# Save to a file
fakeuser 500 --output users.json
# Generate users and view cache info
fakeuser 50 --output test.json
fakeuser --show-cache
That's it! The tool automatically:
- Downloads random users from randomuser.me
- Downloads cities data from GeoNames (no account required!)
- Caches everything for future use
- Enriches users with realistic location data
How It Works
The fakeuser command performs these steps automatically:
- Fetches Random Users: Downloads user data from randomuser.me API
- Downloads Cities Data: Gets the latest cities15000.txt from GeoNames (no account required!)
- Caches Everything: Stores data locally to avoid repeated downloads
- Enriches Locations: Replaces user cities with real cities from their country
- Adds Geographic Data: Includes accurate coordinates, timezones, and population data
Data Sources
- Users: randomuser.me - Generates realistic fake user profiles
- Cities: GeoNames.org - Geographic database with ~32,000 cities (population > 15,000)
CLI Usage
# Basic usage
fakeuser 100 # Generate 100 users
# Save to file
fakeuser 500 --output users.json # Save to specific file
# Force refetch users (cities are always cached)
fakeuser 50 --force-users # Force refetch users
# Custom cache directory
fakeuser 1000 --cache-dir /tmp/cache # Use custom cache directory
# Cache management
fakeuser --show-cache # Show cache information
fakeuser --clear-cache # Clear all cached data
Output Format
The enriched user data includes:
{
"location": {
"street": {"number": 123, "name": "Main St"},
"city": "San Francisco",
"country": "United States",
"countrycode": "US",
"coordinates": {
"latitude": "37.77493",
"longitude": "-122.41942"
},
"timezone": {
"offset": "-8:00",
"description": "America/Los_Angeles"
}
},
"_city_replacement": {
"original_city": "Anytown",
"new_city": "San Francisco",
"geonames_id": "5391959",
"population": 864816,
"country_code": "US"
}
}
Features
- 🚀 Zero Setup: No manual downloads or account creation required
- 📦 Smart Caching: Downloads data once, uses cached versions thereafter
- 🌍 356 Timezone Mappings: Complete coverage of all timezones in cities15000.txt
- 🏴 Country Code Support: Supports all ISO 2-alpha country codes
- 🎲 Random Selection: Cities are selected randomly, so larger cities aren't favored
- 📊 Metadata Tracking: Keeps track of what was changed for debugging
- ⚡ Fast: Cached data loads instantly on subsequent runs
- 💾 Space Efficient: Automatic cleanup and cache management
Cache Management
The tool automatically creates a .cache directory in your current folder:
.cache/
├── cities15000.txt # ~7MB - GeoNames cities data
└── users_500.json # User data cached by count
- Cities data: Downloaded once and cached permanently (never force-refreshed)
- User data: Cached by count (e.g.,
users_100.json,users_500.json) - Smart invalidation: Different user counts create separate cache files
- Force refresh: Use
--force-usersto refetch user data
Requirements
- Python 3.8+
- Internet connection (for initial downloads)
- ~10MB disk space for cache
requestslibrary (auto-installed)
License
This project uses GeoNames data which is available under Creative Commons Attribution 4.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fakeuser-1.0.0.tar.gz.
File metadata
- Download URL: fakeuser-1.0.0.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab11e46e7dfc14126a8824afbb02a00b96bb81d3140fe45974bd12ae0b1a4b35
|
|
| MD5 |
0cb84f5a16ec1fbcf10f4955b0930d9b
|
|
| BLAKE2b-256 |
d0517caf7df74dadbe3bc6b0e4a41d9ba95f64858ebbb789bd1a2ab55eaf8795
|
File details
Details for the file fakeuser-1.0.0-py3-none-any.whl.
File metadata
- Download URL: fakeuser-1.0.0-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
695eb55dc6723fdbaf3a123b81cb9f2a4777a477979df01002eae1561b921ec9
|
|
| MD5 |
70c94d5efd6cc4782954cc4e6576090b
|
|
| BLAKE2b-256 |
f627476d7dc491f23d8e0415f82da61c9c84a9a8cd98576b51bb268f4f87c93d
|