cp .env.example .envEdit the .env file and replace your_api_key_here with your actual API key:
AIS_STREAM_API_KEY=your_actual_key_from_aisstream_iopython examples/example_ais_stream.pyThat's it! Your API key is now secure and hidden from version control.
- Visit: https://aisstream.io/
- Sign up for a free account
- Copy your API key from the dashboard
- Paste it into your
.envfile
# One-time setup
cp .env.example .env
echo "AIS_STREAM_API_KEY=your_key" >> .env
# Run anytime
python examples/example_ais_stream.pyPros:
- β Most secure
- β Easy to manage
- β Git-ignored by default
- β Best for development
# Set once per session
export AIS_STREAM_API_KEY='your_key'
# Run anytime
python examples/example_ais_stream.pyPros:
- β Good for CI/CD
- β Production-ready
- β No files needed
python examples/example_ais_stream.py YOUR_KEYCons:
- β Visible in shell history
- β Not secure
- β Only for quick testing
β DO:
- Use
.envfile for development - Use environment variables for production
- Keep
.envfile private (never commit it) - Use
.env.examplefor documentation
β DON'T:
- Hardcode API keys in source code
- Commit
.envfiles to git - Share API keys in chat or email
- Use command line for production
# Check if API key is set
echo $AIS_STREAM_API_KEY
# If empty, set it:
export AIS_STREAM_API_KEY='your_key'
# Or use .env file:
cp .env.example .env
# Edit .env and add your keypip install python-dotenv# Make sure .env is in the project root
ls -la .env
# Check file permissions
chmod 600 .env
# Verify content
cat .envFor more details, see:
SECURE_API_KEY_GUIDE.md- Comprehensive security guidenode/InputNode/README_Websocket_AIS.md- WebSocket node documentation
- Check the documentation files above
- Run the tests:
python tests/test_env_config.py - Look at the example:
examples/example_ais_stream.py