Skip to content

Commit 1934ba5

Browse files
dshkolclaude
andcommitted
Configure RTD to use CANCENSUS_API_KEY environment variable
- Examples will use real API key when building on RTD - API key configured securely via RTD environment variables - No fake data fallbacks - authentic census data only 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a1ddca8 commit 1934ba5

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

docs/conf.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
# Set environment variables for better RTD compatibility
2626
os.environ['MPLBACKEND'] = 'Agg' # Use non-interactive backend
2727

28+
# Set up API key for RTD builds if available
29+
api_key = os.environ.get('CANCENSUS_API_KEY')
30+
if api_key:
31+
# Set up API key for examples to use
32+
os.environ['PYCANCENSUS_API_KEY'] = api_key
33+
print("API key configured for RTD build")
34+
else:
35+
print("No API key found - examples will use mock data")
36+
2837
# Disable problematic extensions on RTD if needed
2938
print("Building on Read the Docs - using RTD-optimized configuration")
3039

docs/examples/plot_basic_census_data.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
import pandas as pd
1818

1919
# Set your API key (you'll need to replace this with your actual key)
20-
# For demonstration, we'll handle the case where no key is set
21-
try:
22-
# pc.set_api_key("your_api_key_here") # Uncomment and add your key
23-
print("API key setup - replace 'your_api_key_here' with your actual key")
24-
except:
25-
print("No API key set - some examples may not work")
20+
import os
21+
api_key = os.environ.get('CANCENSUS_API_KEY')
22+
if api_key:
23+
pc.set_api_key(api_key)
24+
print("API key configured")
25+
else:
26+
print("No API key - examples will show code structure")
27+
print("Get your API key at: https://censusmapper.ca/users/sign_up")
2628

2729
# %%
2830
# Exploring Available Datasets

0 commit comments

Comments
 (0)