> ## Documentation Index
> Fetch the complete documentation index at: https://docs.countrystatecity.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Cases

> Real-world examples showing how to use CSC Export Tool for e-commerce, mobile apps, analytics, and more with exact cost breakdowns.

Discover how developers across different industries use the CSC Export Tool to solve real-world challenges. Each use case includes exact field selections, format recommendations, and cost breakdowns.

## E-commerce & Online Stores

### 🛒 Checkout Country Dropdown

**Challenge**: Create a country selection dropdown for checkout forms with currency information.

> [tab] Requirements
>
> **What You Need:**
>
> * Country names for the dropdown
> * ISO codes for form processing
> * Currency codes for payment processing
> * Currency symbols for price display
>
> **Expected Outcome:**
> Clean dropdown with \~195 countries, each with currency information for seamless checkout experience.

> [tab] Export Configuration
>
> **Dataset Selection:**
>
> * ✅ Countries
>
> **Field Selection:**
>
> * `name` - Display name for dropdown
> * `iso2` - For form processing and validation
> * `currency` - Payment processing integration
> * `currency_symbol` - Price display formatting
> * `emoji` - Enhanced UX (optional)
>
> **Format:** JSON (perfect for web applications)
>
> > [card] [View Pricing](https://countrystatecity.in/pricing)
> >
> > See current credit costs for this configuration

> [tab] Implementation
>
> ```json Sample Output theme={null}
> {
>   "countries": [
>     {
>       "name": "United States",
>       "iso2": "US",
>       "currency": "USD", 
>       "currency_symbol": "$",
>       "emoji": "🇺🇸"
>     },
>     {
>       "name": "United Kingdom",
>       "iso2": "GB", 
>       "currency": "GBP",
>       "currency_symbol": "£", 
>       "emoji": "🇬🇧"
>     }
>   ]
> }
> ```
>
> ```javascript Frontend Integration theme={null}
> // Load countries data
> const countries = exportData.countries;
>
> // Populate dropdown
> countries.forEach(country => {
>   const option = document.createElement('option');
>   option.value = country.iso2;
>   option.textContent = `${country.emoji} ${country.name}`;
>   countrySelect.appendChild(option);
> });
>
> // Update currency display when country changes
> countrySelect.addEventListener('change', (e) => {
>   const selectedCountry = countries.find(c => c.iso2 === e.target.value);
>   updatePriceDisplay(selectedCountry.currency_symbol);
> });
> ```

### 🌍 Multi-Region Shipping Calculator

**Challenge**: Build a shipping calculator that works across countries and states.

> [card] Dataset Requirements
>
> * Countries with regions
> * States with country relationships
> * Geographic coordinates for distance calculation

> [card] [View Pricing](https://countrystatecity.in/pricing)
>
> See current credit costs for Countries + States exports

> [accordion] Export Configuration
>
> **Datasets:** Countries + States
>
> **Countries Fields:**
>
> * `name`, `iso2`, `currency`, `region`, `subregion`
>
> **States Fields:**
>
> * `name`, `iso2`, `country_code`, `latitude`, `longitude`
>
> **Format:** JSON

> [accordion] Sample Implementation
>
> ```javascript Shipping Calculator theme={null}
> // Group states by country for efficient lookup
> const statesByCountry = {};
> exportData.states.forEach(state => {
>   if (!statesByCountry[state.country_code]) {
>     statesByCountry[state.country_code] = [];
>   }
>   statesByCountry[state.country_code].push(state);
> });
>
> // Calculate shipping based on location
> function calculateShipping(countryCode, stateCode = null) {
>   const country = exportData.countries.find(c => c.iso2 === countryCode);
>
>   if (stateCode && statesByCountry[countryCode]) {
>     const state = statesByCountry[countryCode].find(s => s.iso2 === stateCode);
>     return calculateDistanceShipping(state.latitude, state.longitude);
>   }
>
>   return getRegionalShippingRate(country.region);
> }
> ```

## Mobile Application Development

### 📱 Location-Based Service App

**Challenge**: Create a travel app with city-based recommendations and weather integration.

> [tab] Scenario
>
> **App Type:** Travel recommendations app
> **Need:** Cities with coordinates for weather API integration and location services
> **Target:** All available cities with coordinate data

> [tab] Export Strategy
>
> **Dataset:** Cities
>
> **Essential Fields:**
>
> * `name` - City display name
> * `country_code` - Country context
> * `state_code` - State/province context
> * `latitude`, `longitude` - Weather API integration
>
> **Format:** JSON
>
> > [card] [View Pricing](https://countrystatecity.in/pricing)
> >
> > See current credit costs for Cities exports

> [tab] Mobile Integration
>
> ```swift iOS Implementation theme={null}
> struct City: Codable {
>     let name: String
>     let countryCode: String
>     let stateCode: String
>     let latitude: Double
>     let longitude: Double
> }
>
> // Filter cities by country or region if needed
> let filteredCities = cities.filter { $0.countryCode == "US" }
>
> // Integrate with weather service
> func getWeatherForCity(_ city: City) {
>     let weatherAPI = "https://api.weather.com/v1/current"
>     let url = "\(weatherAPI)?lat=\(city.latitude)&lng=\(city.longitude)"
>
>     // Use coordinates for weather API integration
>     // ... weather integration
> }
> ```

### 🗺️ Offline Maps Application

**Challenge**: Pre-load geographical boundaries for offline map functionality.

> [!WARNING]
>
> **Data Volume Consideration**: Cities dataset contains 150,000+ records. Consider filtering by country or region to optimize app size and performance.

**1. Country Filtering Strategy**

Use the built-in country filter to export only relevant regions:

```json Export Configuration theme={null}
{
  "datasets": ["states"],
  "country_filter": ["US", "CA", "MX"], // North America only
  "fields": ["name", "state_code", "country_code", "latitude", "longitude"],
  "format": "json"
}
```

**2. Data Optimization**

```javascript Data Processing theme={null}
// Group by country for efficient storage
const statesByCountry = exportData.states.reduce((acc, state) => {
  acc[state.country_code] = acc[state.country_code] || [];
  acc[state.country_code].push({
    name: state.name,
    code: state.state_code,
    coords: [state.latitude, state.longitude]
  });
  return acc;
}, {});

// Store in mobile app's local database
await storeOfflineData('geographical_boundaries', statesByCountry);
```

## Data Analytics & Business Intelligence

### 📊 Market Analysis Dashboard

**Challenge**: Create a comprehensive dashboard showing global market data with geographic and currency insights.

> [card] Data Requirements
>
> **Countries with:**
>
> * Regional classifications
> * Currency information
> * Geographic data
> * Language and timezone data

> [card] Export Format
>
> **CSV for Excel/Tableau**
>
> * Easy pivot table creation
> * Chart integration
> * Stakeholder sharing

> [card] [View Pricing](https://countrystatecity.in/pricing)
>
> See current credit costs for analytics exports

> [tab] Field Selection
>
> **Comprehensive Analytics Fields:**
>
> ```csv Field Configuration theme={null}
> name,iso2,iso3,region,subregion,currency,currency_name,
> currency_symbol,phonecode,capital,latitude,longitude,
> timezones,translations,native,emoji,nationality
> ```
>
> **Why These Fields:**
>
> * **Geographic**: region, subregion, coordinates for mapping
> * **Currency**: currency codes, names, symbols for market analysis
> * **Communication**: phonecode, timezones for business operations
> * **Cultural**: native names, translations, nationality for localization

> [tab] Excel Integration
>
> ```excel Power Query Integration theme={null}
> // Excel Power Query M formula
> let
>     Source = Csv.Document(File.Contents("C:\exports\countries_analytics.csv")),
>     Headers = Table.PromoteHeaders(Source),
>
>     // Add calculated columns
>     WithPhonePrefix = Table.AddColumn(Headers, "PhonePrefix", 
>         each "+" & [phonecode]),
>
>     WithCurrencyInfo = Table.AddColumn(WithPhonePrefix, "CurrencyDisplay",
>         each [currency_symbol] & " (" & [currency] & ")"),
>
>     // Group by region for analysis
>     GroupedByRegion = Table.Group(WithCurrencyInfo, {"region"}, 
>         {{"Countries", each _, type table}})
> in
>     GroupedByRegion
> ```

> [tab] Tableau Dashboard
>
> **Key Visualizations:**
>
> 1. **World Map**: Currency zones by country
> 2. **Regional Distribution**: Country count by region
> 3. **Communication Coverage**: Phone code analysis
> 4. **Time Zone Analysis**: Global business hours overlap
>
> ```sql Tableau Calculated Fields theme={null}
> // Currency Zone Display
> [currency_symbol] + " " + [currency_name]
>
> // Phone Code Formatting  
> "+" + [phonecode]
>
> // Regional Country Count
> COUNT([name])
> ```

### 📈 Sales Territory Planning

**Challenge**: Optimize sales territories based on geographic and regional data.

> [accordion] Territory Mapping Strategy
>
> **Datasets Needed:**
>
> * Countries: Base territory definition
> * States: Sub-territory planning
> * Cities: Account distribution analysis
>
> **Export Configuration:**
>
> * Countries + States + Cities
>
> * CSV format for spreadsheet analysis
>
> > [card] [View Pricing](https://countrystatecity.in/pricing)
> >
> > See current credit costs for territory mapping exports
>
> **ROI Justification:** Saves 20+ hours of data collection and cleaning

> [accordion] Sales Analytics Implementation
>
> ```sql Territory Analysis Queries theme={null}
> -- Create territory performance views
> CREATE VIEW territory_performance AS
> SELECT 
>     co.region as territory,
>     COUNT(DISTINCT co.iso2) as countries_covered,
>     COUNT(DISTINCT co.currency) as currencies_supported,
>     COUNT(DISTINCT s.id) as states_count,
>     COUNT(DISTINCT ci.id) as cities_count,
>     GROUP_CONCAT(DISTINCT co.currency) as currency_list
> FROM countries co
> LEFT JOIN states s ON co.iso2 = s.country_code  
> LEFT JOIN cities ci ON s.id = ci.state_id
> GROUP BY co.region;
>
> -- Identify expansion opportunities
> SELECT territory, countries_covered, currencies_supported, currency_list
> FROM territory_performance 
> WHERE countries_covered < 5  -- Underrepresented territories
> ORDER BY countries_covered DESC;
> ```

## Web Development & APIs

### 🌐 Multi-language Website Localization

**Challenge**: Support international users with localized country/region names.

> [!NOTE]
>
> **Localization Tip**: CSC data includes native country names and translations, perfect for international websites serving global audiences.

> [tab] Export Configuration
>
> **Dataset:** Countries
>
> **Localization Fields:**
>
> * `name` - English name
> * `native` - Native language name
> * `translations` - Multiple language support
> * `currency` - Local currency
> * `nationality` - Country nationality
> * `emoji` - Country flag emoji
>
> **Format:** JSON
>
> > [card] [View Pricing](https://countrystatecity.in/pricing)
> >
> > See current credit costs

> [tab] Implementation
>
> ```javascript i18n Integration theme={null}
> // Country data with translations
> const countryData = {
>   "US": {
>     "name": "United States", 
>     "native": "United States",
>     "translations": {
>       "es": "Estados Unidos",
>       "fr": "États-Unis", 
>       "de": "Vereinigte Staaten"
>     },
>     "nationality": "American",
>     "emoji": "🇺🇸"
>   }
> };
>
> // Localization function
> function getLocalizedCountryName(countryCode, locale = 'en') {
>   const country = countryData[countryCode];
>
>   if (locale === 'en') return country.name;
>   if (locale === country.native.toLowerCase().slice(0, 2)) return country.native;
>   if (country.translations[locale]) return country.translations[locale];
>
>   return country.name; // Fallback to English
> }
>
> // Usage in React component
> function CountrySelector({ locale }) {
>   return (
>     <select>
>       {Object.keys(countryData).map(code => (
>         <option key={code} value={code}>
>           {countryData[code].emoji} {getLocalizedCountryName(code, locale)}
>         </option>
>       ))}
>     </select>
>   );
> }
> ```

### 🔗 API Response Enhancement

**Challenge**: Enhance existing API responses with geographical context.

**1. User Location Context**

**Scenario**: Add country/region context to user profiles

```json Before Enhancement theme={null}
{
  "user_id": "123",
  "name": "John Doe", 
  "country_code": "US"
}
```

```json After Enhancement theme={null}
{
  "user_id": "123",
  "name": "John Doe",
  "location": {
    "country": "United States",
    "country_code": "US", 
    "region": "Northern America",
    "currency": "USD",
    "timezone": "America/New_York",
    "flag": "🇺🇸"
  }
}
```

**2. Implementation Strategy**

```javascript API Enhancement theme={null}
// Load geographical data at server startup
const geoData = loadCSCExport('./countries_enhanced.json');
const countryLookup = new Map(
  geoData.countries.map(c => [c.iso2, c])
);

// Enhance API responses  
app.get('/users/:id', async (req, res) => {
  const user = await User.findById(req.params.id);
  const countryInfo = countryLookup.get(user.country_code);
  
  res.json({
    ...user.toJSON(),
    location: {
      country: countryInfo.name,
      country_code: countryInfo.iso2,
      region: countryInfo.region, 
      currency: countryInfo.currency,
      timezone: countryInfo.timezones[0], // Primary timezone
      flag: countryInfo.emoji
    }
  });
});
```

## Database & DevOps

### 🗄️ Database Seeding & Migration

**Challenge**: Populate database tables with geographical reference data.

> [!WARNING]
>
> **Production Tip**: Always use SQL format for database imports to ensure proper data types, constraints, and relationships.

> [tab] PostgreSQL Setup
>
> **Export Configuration:**
>
> * Dataset: Countries + States
>
> * Format: SQL
>
> > [card] [View Pricing](https://countrystatecity.in/pricing)
> >
> > See current credit costs for database exports
>
> ```sql Generated Output Example theme={null}
> -- Table creation (automatically included)
> CREATE TABLE IF NOT EXISTS countries (
>     id SERIAL PRIMARY KEY,
>     name VARCHAR(255) NOT NULL,
>     iso2 CHAR(2) UNIQUE NOT NULL,
>     iso3 CHAR(3) UNIQUE NOT NULL,
>     phonecode VARCHAR(255),
>     currency CHAR(3),
>     region VARCHAR(100),
>     subregion VARCHAR(100)
> );
>
> -- Data insertion
> INSERT INTO countries (name, iso2, iso3, phonecode, currency, region, subregion) 
> VALUES 
> ('United States', 'US', 'USA', '1', 'USD', 'Americas', 'Northern America'),
> ('Canada', 'CA', 'CAN', '1', 'CAD', 'Americas', 'Northern America');
>
> -- Foreign key relationships automatically handled
> CREATE TABLE IF NOT EXISTS states (
>     id SERIAL PRIMARY KEY,
>     name VARCHAR(255) NOT NULL,
>     state_code VARCHAR(10) NOT NULL,
>     country_id INTEGER REFERENCES countries(id),
>     latitude DECIMAL(10, 8),
>     longitude DECIMAL(11, 8)
> );
> ```

> [tab] Migration Integration
>
> ```javascript Node.js Migration theme={null}
> // database/migrations/001_seed_geographical_data.js
> const fs = require('fs');
> const path = require('path');
>
> exports.up = async function(knex) {
>   // Read the CSC-generated SQL file
>   const sqlFile = path.join(__dirname, '../seeds/csc_export.sql');
>   const sqlContent = fs.readFileSync(sqlFile, 'utf8');
>
>   // Execute the SQL statements
>   const statements = sqlContent.split(';').filter(stmt => stmt.trim());
>
>   for (const statement of statements) {
>     if (statement.trim()) {
>       await knex.raw(statement);
>     }
>   }
>
>   console.log('Geographical data seeded successfully');
> };
>
> exports.down = async function(knex) {
>   await knex('states').del();
>   await knex('countries').del();
> };
> ```

> [tab] Docker Integration
>
> ```dockerfile Database Container theme={null}
> # Dockerfile for PostgreSQL with geographical data
> FROM postgres:14
>
> # Copy CSC export SQL file
> COPY ./exports/geographical_data.sql /docker-entrypoint-initdb.d/
>
> # Environment variables
> ENV POSTGRES_DB=myapp
> ENV POSTGRES_USER=app_user 
> ENV POSTGRES_PASSWORD=secure_password
>
> # The SQL file will be automatically executed on container startup
> ```
>
> ```yaml Docker Compose theme={null}
> version: '3.8'
> services:
>   database:
>     build: ./database
>     ports:
>       - "5432:5432"
>     volumes:
>       - pgdata:/var/lib/postgresql/data
>       - ./exports:/tmp/exports
>     environment:
>       - POSTGRES_DB=myapp
>
> volumes:
>   pgdata:
> ```

## Cost Optimization Strategies

### 💡 Minimize Credit Usage

> [card] Smart Field Selection
>
> **Only export fields you actually need**
>
> * Audit your code to identify used fields
> * Remove debugging/testing fields
> * Consider computed fields vs exported fields

> [card] Format Optimization
>
> **Choose the right format**
>
> * JSON: Great for web apps
> * CSV: Great for analysis
> * SQL: Great for databases

### 🎯 Strategic Export Planning

> [accordion] Combine Related Exports
>
> **Instead of:** 3 separate exports (3 transactions, potential for higher costs)
>
> * Countries for dropdown (1 credit)
> * States for shipping (3 credits)
> * Countries for currency (1 credit) - duplicate!
>
> **Smart approach:** 1 combined export (Countries + States + JSON = 6 credits total)
>
> * Countries + States with all needed fields
> * Single download, unified data structure
> * Better data consistency

> [accordion] Leverage 30-Day Access
>
> **Re-download Strategy:**
>
> * Create comprehensive exports monthly
> * Re-download for different projects within 30 days
> * Share exports across team members
> * Plan exports around sprint cycles

> [accordion] Development vs Production
>
> **Development Phase:**
>
> * Use free JSON format for prototyping
> * Export minimal field sets for testing
> * Iterate with preview feature (free)
>
> **Production Deployment:**
>
> * Create final export with all needed fields
> * Choose production-appropriate format
> * Document export configuration for future updates

***

> [!NOTE]
>
> **Ready to implement your use case?** Start with the [getting started guide](https://docs.countrystatecity.in/tools/export-tool/getting-started.md) to create your account and get free trial credits for testing.


## Related topics

- [Country State City](https://docs.countrystatecity.in/index.md)
- [CSC Tools Overview](https://docs.countrystatecity.in/tools/overview.md)
- [Get Country Details](https://docs.countrystatecity.in/api/endpoints/get-country-details.md)
- [Frequently Asked Questions](https://docs.countrystatecity.in/api/faq.md)
- [Get State Details](https://docs.countrystatecity.in/api/endpoints/get-state-details.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.