Skip to content

Commit dcd69c4

Browse files
committed
Update README.md to enhance authentication methods and usage examples
1 parent f54b937 commit dcd69c4

1 file changed

Lines changed: 27 additions & 27 deletions

File tree

README.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,51 +49,51 @@ python -c "from axiomtradeapi import AxiomTradeClient; print('✅ Installation s
4949

5050
### Basic Usage
5151

52-
#### New Token-Based Authentication (Recommended)
52+
#### 1. Automatic Authentication (Recommended)
53+
This method automatically handles login, saves your session securely, and resumes it on future runs.
5354

5455
```python
56+
import os
5557
from axiomtradeapi import AxiomTradeClient
58+
from dotenv import load_dotenv
5659

57-
# Initialize client (no credentials required in constructor)
58-
client = AxiomTradeClient()
60+
load_dotenv()
5961

60-
# Method 1: Login to get tokens
61-
tokens = client.login(
62-
email="your_email@example.com",
63-
b64_password="your_base64_encoded_password",
64-
otp_code="123456" # OTP from email
62+
# Initialize client with credentials
63+
client = AxiomTradeClient(
64+
username=os.getenv("EMAIL_ADDRESS"),
65+
password=os.getenv("AXIOM_PASSWORD")
6566
)
6667

67-
print(f"Access Token: {tokens['access_token']}")
68-
print(f"Refresh Token: {tokens['refresh_token']}")
69-
70-
# Method 2: Use existing tokens
71-
client.set_tokens(
72-
access_token="your_access_token_here",
73-
refresh_token="your_refresh_token_here"
68+
# Automatically logs in if no saved session exists
69+
# Will trigger an OTP flow if 2FA is required
70+
if not client.is_authenticated():
71+
print("Please follow the login prompt...")
72+
client.login() # Takes optional otp_callback
73+
74+
# Simulate browser connection to initialize tracking sessions
75+
# This is required for some endpoints to register you as an "active user"
76+
# and to pass detailed bot or scraper protection checks.
77+
client.connect(
78+
token_address="8P5kBTzvG7xyjTZRzi4ftzpy6mnL74AHLtHDqyDq44ST", # Optional: Simulate landing on a token page
79+
sol_public_keys=["Address1...", "Address2..."], # Optional: Check balances during connect
80+
evm_public_keys=["0xAddress1..."]
7481
)
7582

76-
# Use the API
77-
if client.is_authenticated():
78-
trending = client.get_trending_tokens('1h')
79-
print(f"Found {len(trending.get('tokens', []))} trending tokens")
83+
print(f"Logged in as: {client.auth_manager.username}")
8084
```
8185

82-
#### Environment Variables (Production)
86+
#### 2. Manual Token Authentication
87+
Use this for serverless environments or when you manage tokens externally.
8388

8489
```python
85-
import os
8690
from axiomtradeapi import AxiomTradeClient
8791

88-
# Secure authentication with environment variables
8992
client = AxiomTradeClient()
9093
client.set_tokens(
91-
access_token=os.getenv('AXIOM_ACCESS_TOKEN'),
92-
refresh_token=os.getenv('AXIOM_REFRESH_TOKEN')
94+
access_token="your_access_token_here",
95+
refresh_token="your_refresh_token_here"
9396
)
94-
95-
# Your trading logic here
96-
portfolio = client.get_user_portfolio()
9797
```
9898

9999
### Advanced Features

0 commit comments

Comments
 (0)