@@ -33,7 +33,11 @@ for message in messages:
3333- ** Create temporary email addresses** - Generate disposable emails instantly
3434- ** List available domains** - Get domains you can use for email creation
3535- ** Receive emails** - Fetch messages sent to your temporary addresses
36- - ** Delete messages** - Clean up messages when done
36+ - ** Get individual messages** - Retrieve specific messages by ID
37+ - ** Get message source code** - Access raw email source
38+ - ** Download attachments** - Download email attachments
39+ - ** Delete messages** - Clean up individual messages
40+ - ** Delete emails** - Remove email addresses and all their messages
3741- ** Rate limit monitoring** - Track your API usage
3842- ** Error handling** - Comprehensive exception handling
3943- ** Type hints** - Full typing support for better development experience
@@ -61,48 +65,68 @@ client = TempMailClient(
6165### Creating Email Addresses
6266
6367``` python
64- from tempmail import CreateEmailOptions
65-
6668# Create random email
6769email = client.create_email()
6870
69- # Create with specific domain and prefix
70- options = CreateEmailOptions(domain = " example.com" , prefix = " mytest" )
71- email = client.create_email(options)
71+ # Create with specific domain
72+ email = client.create_email(domain = " example.com" )
73+
74+ # Create with specific email address
75+ email
= client.create_email(
email = " [email protected] " )
76+
77+ # Create with domain type preference
78+ email = client.create_email(domain_type = " premium" )
7279```
7380
7481### Listing Domains
7582
7683``` python
7784domains = client.list_domains()
7885for domain in domains:
79- print (domain.domain)
86+ print (f " Domain: { domain.name } , Type: { domain.type.value } " )
8087```
8188
8289### Managing Messages
8390
8491``` python
85- from tempmail import ListMessagesOptions
86-
8792# List all messages for an email
8893messages
= client.list_email_messages(
" [email protected] " )
94+ for message in messages:
95+ print (f " From: { message.from_addr} " )
96+ print (f " Subject: { message.subject} " )
97+ print (f " CC: { message.cc} " )
98+ print (f " Attachments: { len (message.attachments or [])} " )
99+
100+ # Get a specific message
101+ message = client.get_message(" message-id" )
102+
103+ # Get message source code
104+ source_code = client.get_message_source_code(" message-id" )
89105
90- # List with pagination
91- options = ListMessagesOptions(limit = 10 , offset = 0 )
92- messages
= client.list_email_messages(
" [email protected] " , options)
106+ # Download an attachment
107+ attachment_data = client.download_attachment(" attachment-id" )
93108
94109# Delete a message
95110client.delete_message(" message-id" )
111+
112+ # Delete an entire email address and all its messages
113+ client.delete_email(
" [email protected] " )
96114```
97115
98116### Rate Limiting
99117
100118``` python
101119# Get current rate limit status
102120rate_limit = client.get_rate_limit()
103- if rate_limit:
104- print (f " Remaining requests: { rate_limit.remaining} " )
105- print (f " Reset time: { rate_limit.reset} " )
121+ print (f " Limit: { rate_limit.limit} " )
122+ print (f " Remaining: { rate_limit.remaining} " )
123+ print (f " Used: { rate_limit.used} " )
124+ print (f " Reset time: { rate_limit.reset} " )
125+
126+ # Access last rate limit from any request
127+ last_rate_limit = client.last_rate_limit
128+ if last_rate_limit:
129+ print (f " Last known remaining: { last_rate_limit.remaining} " )
106130```
107131
108132## Error Handling
@@ -115,7 +139,6 @@ from tempmail import (
115139 AuthenticationError, # Invalid API key
116140 RateLimitError, # Rate limit exceeded
117141 ValidationError, # Invalid parameters
118- APIError # Server errors
119142)
120143
121144try :
@@ -127,8 +150,8 @@ except RateLimitError:
127150 print (" Rate limit exceeded" )
128151except ValidationError as e:
129152 print (f " Invalid parameters: { e} " )
130- except APIError as e:
131- print (f " API error: { e.status_code } - { e } " )
153+ except TempMailError as e:
154+ print (f " API error: { e} " )
132155```
133156
134157## Development
@@ -140,36 +163,68 @@ except APIError as e:
140163git clone https://github.com/temp-mail-io/temp-mail-python
141164cd temp-mail-python
142165
143- # Install in development mode
144- pip install -e " .[dev]"
166+ # Install uv (recommended)
167+ curl -LsSf https://astral.sh/uv/install.sh | sh
168+
169+ # Install dependencies
170+ uv sync --dev
145171```
146172
147173### Running Tests
148174
149175``` bash
150- pytest tests/
176+ uv run pytest tests/
151177```
152178
153- ### Code Formatting
179+ ### Code Quality
154180
155181``` bash
156- black tempmail/ tests/
157- isort tempmail/ tests/
182+ # Run all pre-commit hooks
183+ uv run pre-commit run --all-files
184+
185+ # Or run individual tools
186+ uv run ruff check # Linting
187+ uv run ruff format # Formatting
188+ uv run mypy tempmail/ # Type checking
158189```
159190
160- ### Type Checking
191+ ## Complete Example
161192
162- ``` bash
163- mypy tempmail/
164- ```
193+ ``` python
194+ from tempmail import TempMailClient, AuthenticationError, RateLimitError
165195
166- ## Examples
196+ # Initialize client
197+ client = TempMailClient(" your-api-key" )
167198
168- See the [ examples/] ( examples/ ) directory for more detailed usage examples.
199+ try :
200+ # Create a temporary email
201+ email = client.create_email()
202+ print (f " Created email: { email.email} " )
203+ print (f " TTL: { email.ttl} seconds " )
204+
205+ # List available domains
206+ domains = client.list_domains()
207+ print (f " Available domains: { len (domains)} " )
208+
209+ # Check for messages (would be empty initially)
210+ messages = client.list_email_messages(email.email)
211+ print (f " Messages: { len (messages)} " )
212+
213+ # Check rate limit
214+ rate_limit = client.get_rate_limit()
215+ print (f " Requests remaining: { rate_limit.remaining} / { rate_limit.limit} " )
216+
217+ except AuthenticationError:
218+ print (" Invalid API key" )
219+ except RateLimitError:
220+ print (" Rate limit exceeded" )
221+ except Exception as e:
222+ print (f " Error: { e} " )
223+ ```
169224
170225## License
171226
172- MIT License - see [ LICENSE] ( LICENSE ) file for details.
227+ MIT License— see [ LICENSE] ( LICENSE ) file for details.
173228
174229## Links
175230
0 commit comments