Configuration

The FMP Node Wrapper supports multiple configuration options to suit different use cases and security requirements.

API Key Configuration

The FMP client supports three ways to provide your API key:

Set the FMP_API_KEY environment variable and initialize without parameters:

TypeScriptTypeScript

Setup:

bashbash
bashbash

Option 2: Direct Configuration

Provide the API key directly in the constructor:

TypeScriptTypeScript

Option 3: Mixed Configuration

Provide partial configuration and let the client fall back to environment variables:

TypeScriptTypeScript

Configuration Options

OptionTypeDefaultDescription
apiKeystringFMP_API_KEY env varYour FMP API key (optional if env var is set)
timeoutnumber10000Request timeout in milliseconds

Error Handling

The client provides clear error messages for configuration issues:

TypeScriptTypeScript

Security Best Practices

1. Use Environment Variables

Always use environment variables for API keys in production:

TypeScriptTypeScript

2. Never Commit API Keys

Ensure your .env file is in .gitignore:

bashbash

3. Use Different Keys for Different Environments

bashbash

Environment-Specific Configuration

Development

TypeScriptTypeScript

Production

TypeScriptTypeScript

Testing

TypeScriptTypeScript

Advanced Configuration

Multiple Client Instances

You can create multiple client instances with different configurations:

TypeScriptTypeScript

Troubleshooting

Common Issues

Issue: "FMP API key is required" error Solution: Set the FMP_API_KEY environment variable or provide it in the config

Issue: Environment variable not detected Solution:

  • Ensure the variable is set correctly
  • Restart your terminal/IDE
  • Check for typos in the variable name

Issue: Timeout errors Solution: Increase the timeout value:

TypeScriptTypeScript

Debugging

Enable debug logging to troubleshoot configuration issues:

TypeScriptTypeScript

Next Steps