Authentication¶
eptr2 requires credentials from the EPIAS Transparency Platform to access market data.
Getting Credentials¶
- Visit the EPIAS registration page
- Complete the registration form
- Verify your email address
- Use your registration email and password as credentials
Authentication Methods¶
Method 1: Environment File (Recommended)¶
Create a .env file in your project directory:
Then initialize without explicit credentials:
TGT Recycling
Setting recycle_tgt=True stores the authentication ticket locally (.eptr2-tgt file) and reuses it until expiration. This reduces API calls and avoids rate limiting.
Method 2: Direct Credentials¶
Pass credentials directly (useful for quick testing):
Security
Never commit credentials to version control. Use environment files or environment variables instead.
Method 3: Environment Variables¶
Set system environment variables:
Then initialize:
Configuration Options¶
The EPTR2 class accepts several authentication-related options:
| Parameter | Type | Default | Description |
|---|---|---|---|
username |
str | None | EPIAS platform username (email) |
password |
str | None | EPIAS platform password |
use_dotenv |
bool | True | Load credentials from .env file |
dotenv_path |
str | ".env" | Path to the .env file |
recycle_tgt |
bool | True | Reuse authentication tickets |
tgt_path |
str | "." | Directory to store TGT file |
force_renew_tgt |
bool | False | Force renewal of TGT |
TGT (Ticket Granting Ticket) Management¶
eptr2 uses a ticket-based authentication system:
- Initial Login: Credentials are exchanged for a TGT
- TGT Storage: With
recycle_tgt=True, the TGT is saved to.eptr2-tgt - TGT Reuse: Subsequent calls reuse the stored TGT
- Auto Renewal: TGT is automatically renewed when expired
# Custom TGT storage location
eptr = EPTR2(
use_dotenv=True,
recycle_tgt=True,
tgt_path="/path/to/store/tgt"
)
Best Practices¶
- Use
.envfiles - Keep credentials separate from code - Enable TGT recycling - Reduces authentication overhead
- Add
.envto.gitignore- Never commit credentials - Use
.env.example- Document required variables without values
Example .gitignore:
Example .env.example:
Troubleshooting¶
"Username and password must be provided"¶
Ensure credentials are properly set:
import os
print("Username set:", "EPTR_USERNAME" in os.environ)
print("Password set:", "EPTR_PASSWORD" in os.environ)
TGT Expiration Issues¶
Force TGT renewal:
Rate Limiting¶
If you encounter rate limiting, ensure recycle_tgt=True is set to minimize authentication requests.