### Install Go SDK Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Install the Go SDK using the go get command. Ensure your Go environment is properly configured. ```bash go get github.com/Fushey/go-disposable-email-checker ``` -------------------------------- ### Go SDK Usage Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Example of how to install and use the Go SDK to check emails, domains, and retrieve usage information. It also demonstrates configuring regional endpoints. ```APIDOC ## Go SDK ### Installation ```bash go get github.com/Fushey/go-disposable-email-checker ``` ### Usage ```go package main import ( "fmt" tempmailchecker "github.com/Fushey/go-disposable-email-checker" ) func main() { // Create client checker := tempmailchecker.MustNew("your_api_key") // Check email result, _ := checker.Check("user@tempmail.com") if result.Temp { fmt.Println("Disposable email!") } // Check domain result, _ = checker.CheckDomain("tempmail.com") // Use regional endpoint checker, _ = tempmailchecker.New("your_api_key", tempmailchecker.WithEndpoint(tempmailchecker.EndpointUS), ) // Get usage usage, _ := checker.GetUsage() fmt.Printf("Used: %d / %d\n", usage.UsageToday, usage.Limit) } ``` ``` -------------------------------- ### PHP SDK Usage Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Example of how to install and use the PHP SDK to check emails, domains, and retrieve usage information. It also shows how to configure regional endpoints. ```APIDOC ## PHP SDK ### Installation ```bash composer require tempmailchecker/php-sdk ``` ### Usage ```php check('user@tempmail.com'); if ($result['temp']) { echo "Disposable email!"; } // Check domain $result = $checker->checkDomain('tempmail.com'); // Use regional endpoint $checker = new TempMailChecker('your_api_key', TempMailChecker::ENDPOINT_US); // Get usage $usage = $checker->getUsage(); echo "Used: {$usage['usage_today']} / {$usage['limit']}"; ?> ``` ``` -------------------------------- ### Node.js SDK Usage Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Example of how to install and use the Node.js SDK to check emails, domains, and retrieve usage information. It also demonstrates configuring regional endpoints. ```APIDOC ## Node.js SDK ### Installation ```bash npm install @tempmailchecker/node-sdk # or yarn add @tempmailchecker/node-sdk # or pnpm add @tempmailchecker/node-sdk ``` ### Usage ```javascript import { TempMailChecker, ENDPOINT_US } from '@tempmailchecker/node-sdk'; // Create client const checker = new TempMailChecker('your_api_key'); // Check email const result = await checker.check('user@tempmail.com'); if (result.temp) { console.log('Disposable email!'); } // Check domain const domainResult = await checker.checkDomain('tempmail.com'); // Use regional endpoint const usChecker = new TempMailChecker('your_api_key', { endpoint: ENDPOINT_US }); // Get usage const usage = await checker.getUsage(); console.log(`Used: ${usage.usage_today} / ${usage.limit}`); ``` ``` -------------------------------- ### Install Node.js SDK Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Install the Node.js SDK using npm, yarn, or pnpm. This command should be run in your project's root directory. ```bash npm install @tempmailchecker/node-sdk # or yarn add @tempmailchecker/node-sdk # or pnpm add @tempmailchecker/node-sdk ``` -------------------------------- ### Get Usage Request Example Source: https://github.com/fushey/api-documentation/blob/main/docs/api-reference.md Example cURL request to fetch API usage statistics. Ensure 'tmck_your_api_key' is replaced with your actual API key. ```bash curl "https://tempmailchecker.com/usage?key=tmck_your_api_key" ``` -------------------------------- ### Python SDK Usage Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Example of how to install and use the Python SDK to check emails, domains, and retrieve usage information. It also shows how to configure regional endpoints. ```APIDOC ## Python SDK ### Installation ```bash pip install tempmailchecker ``` ### Usage ```python from tempmailchecker import TempMailChecker, ENDPOINT_US # Create client checker = TempMailChecker('your_api_key') # Check email result = checker.check('user@tempmail.com') if result['temp']: print('Disposable email!') # Check domain result = checker.check_domain('tempmail.com') # Use regional endpoint checker = TempMailChecker('your_api_key', endpoint=ENDPOINT_US) # Get usage usage = checker.get_usage() print(f"Used: {usage['usage_today']} / {usage['limit']}") ``` ``` -------------------------------- ### Install Python SDK Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Install the Python SDK using pip. This command should be executed in your project's virtual environment. ```bash pip install tempmailchecker ``` -------------------------------- ### Install PHP SDK Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Use Composer to install the PHP SDK. This is required before using the SDK in your project. ```bash composer require tempmailchecker/php-sdk ``` -------------------------------- ### Get API Usage with SDKs Source: https://github.com/fushey/api-documentation/blob/main/docs/rate-limits.md Examples of how to retrieve your current API usage statistics using various SDKs. These snippets show how to access usage data like requests made today and the daily limit. ```php // PHP $usage = $checker->getUsage(); echo "Used: {$usage['usage_today']} / {$usage['limit']}"; ``` ```javascript // Node.js const usage = await checker.getUsage(); console.log(`Used: ${usage.usage_today} / ${usage.limit}`); ``` ```python # Python usage = checker.get_usage() print(f"Used: {usage['usage_today']} / {usage['limit']}") ``` ```go // Go usage, _ := checker.GetUsage() fmt.Printf("Used: %d / %d\n", usage.UsageToday, usage.Limit) ``` -------------------------------- ### Check Domain Request Example Source: https://github.com/fushey/api-documentation/blob/main/docs/api-reference.md Example cURL request to check if a domain is disposable. Replace 'tmck_your_api_key' with your valid API key. ```bash curl "https://tempmailchecker.com/check?domain=guerrillamail.com" \ -H "X-API-Key: tmck_your_api_key" ``` -------------------------------- ### Execute Bash CLI Tool Source: https://context7.com/fushey/api-documentation/llms.txt Demonstrates how to make the bash script executable and run it with example email addresses. Shows expected output and exit codes. ```bash chmod +x check-email.sh ./check-email.sh test@tempmail.com # ⚠️ test@tempmail.com is a disposable email — exit 1 ./check-email.sh user@gmail.com # ✓ user@gmail.com is legitimate — exit 0 ``` -------------------------------- ### Node.js SDK Usage Source: https://context7.com/fushey/api-documentation/llms.txt Demonstrates how to install and use the TempMailChecker Node.js SDK to check emails and domains, manage usage, and handle errors. ```APIDOC ## Node.js SDK Install via npm/yarn/pnpm and use the `TempMailChecker` class with async/await. Includes TypeScript support. ```javascript // Install: npm install @tempmailchecker/node-sdk import { TempMailChecker, ENDPOINT_US } from '@tempmailchecker/node-sdk'; const checker = new TempMailChecker(process.env.TEMPMAILCHECKER_API_KEY); // Check email const result = await checker.check('user@tempmail.com'); if (result.temp) { console.log('Disposable email detected!'); } // Check domain const domainResult = await checker.checkDomain('10minutemail.com'); // Use US regional endpoint const usChecker = new TempMailChecker('your_api_key', { endpoint: ENDPOINT_US }); // Get usage const usage = await checker.getUsage(); console.log(`Used: ${usage.usage_today} / ${usage.limit}`); // Express registration route with full error handling app.post('/register', async (req, res) => { const { email, password } = req.body; try { const result = await checker.check(email); if (result.temp) { return res.status(400).json({ error: 'Please use a permanent email address.' }); } } catch (error) { if (error.message.includes('Rate limit')) { // Graceful degradation — allow signup, flag for review } else if (error.message.includes('Invalid API key')) { console.error('TempMailChecker: invalid API key'); } } // Continue with registration... }); // Retry with exponential backoff for transient errors async function checkWithRetry(email, maxRetries = 3) { for (let i = 0; i < maxRetries; i++) { try { return await checker.check(email); } catch (error) { if (error.message.includes('Rate limit')) throw error; // Don't retry rate limits if (i === maxRetries - 1) throw error; await new Promise(r => setTimeout(r, 1000 * Math.pow(2, i))); } } } ``` ``` -------------------------------- ### Get Usage Source: https://github.com/fushey/api-documentation/blob/main/docs/api-reference.md Check your current API usage statistics. No `X-API-Key` header is required for this endpoint. ```APIDOC ## Get Usage ### Description Check your current API usage statistics. ### Method GET ### Endpoint /usage ### Parameters #### Query Parameters - **key** (string) - Required - Your API key ### Request Example ```bash curl "https://tempmailchecker.com/usage?key=tmck_your_api_key" ``` ### Response #### Success Response (200 OK) - **usage_today** (integer) - Requests made today - **limit** (integer) - Daily request limit - **reset** (string) - When the counter resets #### Response Example ```json { "usage_today": 15, "limit": 25, "reset": "midnight UTC" } ``` ``` -------------------------------- ### Go SDK Usage Source: https://context7.com/fushey/api-documentation/llms.txt Install and use the Go SDK to check emails and domains. Supports functional options for endpoint and timeout configuration. ```APIDOC ## Go SDK Install via `go get` and use the `TempMailChecker` struct. Supports functional options for endpoint and timeout configuration. ```go // Install: go get github.com/Fushey/go-disposable-email-checker package main import ( "fmt" "os" tempmailchecker "github.com/Fushey/go-disposable-email-checker" ) func main() { // Create client checker := tempmailchecker.MustNew(os.Getenv("TEMPMAILCHECKER_API_KEY")) // Check email result, err := checker.Check("user@tempmail.com") if err != nil { handleError(err) return } if result.Temp { fmt.Println("Disposable email detected!") } // Check domain result, _ = checker.CheckDomain("guerrillamail.com") // Use US regional endpoint usChecker, _ := tempmailchecker.New("your_api_key", tempmailchecker.WithEndpoint(tempmailchecker.EndpointUS), ) _ = usChecker // Get usage usage, _ := checker.GetUsage() fmt.Printf("Used: %d / %d\n", usage.UsageToday, usage.Limit) } func handleError(err error) { if tempmailchecker.IsRateLimitError(err) { fmt.Println("Rate limit exceeded, try again after midnight UTC") } else if tempmailchecker.IsAPIError(err) { fmt.Printf("API error: %v\n", err) } else { fmt.Printf("Unexpected error: %v\n", err) } } ``` ``` -------------------------------- ### Curl Example for Missing Parameter Error Source: https://context7.com/fushey/api-documentation/llms.txt Demonstrates how to make a curl request that triggers a 400 error due to missing parameters. ```bash # 400 — missing parameter curl "https://tempmailchecker.com/check" -H "X-API-Key: tmck_key" ``` -------------------------------- ### Check Email Request Example Source: https://github.com/fushey/api-documentation/blob/main/docs/api-reference.md Example cURL request to check if an email address is disposable. Ensure to replace 'tmck_your_api_key' with your actual API key. ```bash curl "https://tempmailchecker.com/check?email=user@tempmail.com" \ -H "X-API-Key: tmck_your_api_key" ``` -------------------------------- ### Node.js SDK: Basic Usage and Error Handling Source: https://context7.com/fushey/api-documentation/llms.txt Install via npm/yarn/pnpm and use the `TempMailChecker` class with async/await. Includes TypeScript support. Demonstrates email/domain checking, regional endpoints, usage retrieval, and Express route error handling with retries. ```javascript // Install: npm install @tempmailchecker/node-sdk import { TempMailChecker, ENDPOINT_US } from '@tempmailchecker/node-sdk'; const checker = new TempMailChecker(process.env.TEMPMAILCHECKER_API_KEY); // Check email const result = await checker.check('user@tempmail.com'); if (result.temp) { console.log('Disposable email detected!'); } // Check domain const domainResult = await checker.checkDomain('10minutemail.com'); // Use US regional endpoint const usChecker = new TempMailChecker('your_api_key', { endpoint: ENDPOINT_US }); // Get usage const usage = await checker.getUsage(); console.log(`Used: ${usage.usage_today} / ${usage.limit}`); // Express registration route with full error handling app.post('/register', async (req, res) => { const { email, password } = req.body; try { const result = await checker.check(email); if (result.temp) { return res.status(400).json({ error: 'Please use a permanent email address.' }); } } catch (error) { if (error.message.includes('Rate limit')) { // Graceful degradation — allow signup, flag for review } else if (error.message.includes('Invalid API key')) { console.error('TempMailChecker: invalid API key'); } } // Continue with registration... }); // Retry with exponential backoff for transient errors async function checkWithRetry(email, maxRetries = 3) { for (let i = 0; i < maxRetries; i++) { try { return await checker.check(email); } catch (error) { if (error.message.includes('Rate limit')) throw error; // Don't retry rate limits if (i === maxRetries - 1) throw error; await new Promise(r => setTimeout(r, 1000 * Math.pow(2, i))); } } } ``` -------------------------------- ### Go SDK Error Handling Source: https://github.com/fushey/api-documentation/blob/main/docs/errors.md Example of how to handle API errors using the TempMailChecker Go SDK. ```APIDOC ## Handling Errors in Go SDK ```go import tempmailchecker "github.com/Fushey/go-disposable-email-checker" checker := tempmailchecker.MustNew("your_api_key") result, err := checker.Check(email) if err != nil { if tempmailchecker.IsRateLimitError(err) { fmt.Println("Rate limit exceeded, try again later") } else if tempmailchecker.IsAPIError(err) { fmt.Printf("API error: %v\n", err) } else { fmt.Printf("Error: %v\n", err) } return } ``` ``` -------------------------------- ### Correct cURL Request Examples Source: https://github.com/fushey/api-documentation/blob/main/docs/errors.md These cURL commands demonstrate how to correctly include either an email or a domain parameter in your API request. Always include your API key in the X-API-Key header. ```bash # Correct curl "https://tempmailchecker.com/check?email=test@example.com" -H "X-API-Key: YOUR_KEY" # Also correct curl "https://tempmailchecker.com/check?domain=example.com" -H "X-API-Key: YOUR_KEY" ``` -------------------------------- ### Python SDK Usage Source: https://context7.com/fushey/api-documentation/llms.txt Illustrates how to install and utilize the TempMailChecker Python SDK for email and domain validation, regional endpoints, and usage tracking. ```APIDOC ## Python SDK Install via pip and use the `TempMailChecker` class. Supports regional endpoints and domain-level checks. ```python # Install: pip install tempmailchecker from tempmailchecker import TempMailChecker, ENDPOINT_US import os import time checker = TempMailChecker(os.environ['TEMPMAILCHECKER_API_KEY']) # Check email result = checker.check('user@tempmail.com') if result['temp']: print('Disposable email detected!') # Check domain result = checker.check_domain('guerrillamail.com') # Use US regional endpoint us_checker = TempMailChecker('your_api_key', endpoint=ENDPOINT_US) # Get usage usage = checker.get_usage() print(f"Used: {usage['usage_today']} / {usage['limit']}") # Django registration view with error handling def register(request): email = request.POST.get('email') try: result = checker.check(email) if result['temp']: return JsonResponse({'error': 'Please use a permanent email address.'}, status=400) except Exception as e: if 'Rate limit' in str(e): pass # Allow registration on rate limit elif 'Invalid API key' in str(e): print('TempMailChecker: invalid API key') # Batch validation with rate limiting emails = ['user1@gmail.com', 'user2@tempmail.com', 'user3@yahoo.com', 'user4@10minutemail.com'] results = [] for email in emails: try: result = checker.check(email) results.append({'email': email, 'disposable': result['temp']}) time.sleep(0.1) # 100ms delay — stays well under daily limits except Exception as e: print(f'Error checking {email}: {e}') disposable = [r for r in results if r['disposable']] print(f'Found {len(disposable)} disposable emails out of {len(results)} checked') ``` ``` -------------------------------- ### Python SDK: Basic Usage and Error Handling Source: https://context7.com/fushey/api-documentation/llms.txt Install via pip and use the `TempMailChecker` class. Supports regional endpoints and domain-level checks. Demonstrates email/domain checking, regional endpoints, usage retrieval, and Django view error handling with batch validation and rate limiting. ```python # Install: pip install tempmailchecker from tempmailchecker import TempMailChecker, ENDPOINT_US import os import time checker = TempMailChecker(os.environ['TEMPMAILCHECKER_API_KEY']) # Check email result = checker.check('user@tempmail.com') if result['temp']: print('Disposable email detected!') # Check domain result = checker.check_domain('guerrillamail.com') # Use US regional endpoint us_checker = TempMailChecker('your_api_key', endpoint=ENDPOINT_US) # Get usage usage = checker.get_usage() print(f"Used: {usage['usage_today']} / {usage['limit']}") # Django registration view with error handling def register(request): email = request.POST.get('email') try: result = checker.check(email) if result['temp']: return JsonResponse({'error': 'Please use a permanent email address.'}, status=400) except Exception as e: if 'Rate limit' in str(e): pass # Allow registration on rate limit elif 'Invalid API key' in str(e): print('TempMailChecker: invalid API key') # Batch validation with rate limiting emails = ['user1@gmail.com', 'user2@tempmail.com', 'user3@yahoo.com', 'user4@10minutemail.com'] results = [] for email in emails: try: result = checker.check(email) results.append({'email': email, 'disposable': result['temp']}) time.sleep(0.1) # 100ms delay — stays well under daily limits except Exception as e: print(f'Error checking {email}: {e}') disposable = [r for r in results if r['disposable']] print(f'Found {len(disposable)} disposable emails out of {len(results)} checked') ``` -------------------------------- ### Python SDK Error Handling Source: https://github.com/fushey/api-documentation/blob/main/docs/errors.md Example of how to handle API errors using the TempMailChecker Python SDK. ```APIDOC ## Handling Errors in Python SDK ```python from tempmailchecker import TempMailChecker checker = TempMailChecker('your_api_key') try: result = checker.check(email) except Exception as e: if 'Rate limit' in str(e): print('Rate limit exceeded, try again later') elif 'Invalid API key' in str(e): print('Invalid API key') else: print(f'Error: {e}') ``` ``` -------------------------------- ### PHP SDK Error Handling Source: https://github.com/fushey/api-documentation/blob/main/docs/errors.md Example of how to handle API errors using the TempMailChecker PHP SDK. ```APIDOC ## Handling Errors in PHP SDK ```php use TempMailChecker\TempMailChecker; use Exception; $checker = new TempMailChecker('your_api_key'); try { $result = $checker->check($email); } catch (Exception $e) { if (strpos($e->getMessage(), 'Rate limit') !== false) { // Handle rate limit echo "Rate limit exceeded, try again later"; } elseif (strpos($e->getMessage(), 'Invalid API key') !== false) { // Handle invalid key echo "Invalid API key"; } else { // Handle other errors error_log($e->getMessage()); } } ``` ``` -------------------------------- ### Check Email with API Key Source: https://context7.com/fushey/api-documentation/llms.txt Example of checking an email address using the API with a specific API key. Handles invalid keys and rate limiting. ```bash curl "https://tempmailchecker.com/check?email=test@example.com" -H "X-API-Key: bad_key" ``` ```json {"error": "Invalid API key", "temp": null} ``` ```json {"error": "Rate limit exceeded", "message": "You have exceeded your daily limit of 25 requests", "limit": 25, "used": 25, "reset": "midnight UTC"} ``` -------------------------------- ### PHP SDK Usage Source: https://context7.com/fushey/api-documentation/llms.txt Example of how to use the PHP SDK to interact with the TempMailChecker API for checking emails, domains, selecting regional endpoints, and retrieving usage statistics. ```APIDOC ## PHP SDK ### Description Install via Composer and use the `TempMailChecker` class to check emails, check domains, select regional endpoints, and retrieve usage stats. ### Installation ```bash composer require tempmailchecker/php-sdk ``` ### Usage Example ```php check('user@tempmail.com'); if ($result['temp']) { echo "Disposable email detected!\n"; } else { echo "Legitimate email address.\n"; } } catch (Exception $e) { echo "Error checking email: " . $e->getMessage() . "\n"; } // Check domain name try { $result = $checker->checkDomain('guerrillamail.com'); if ($result['temp']) { echo "Disposable domain detected!\n"; } else { echo "Legitimate domain.\n"; } } catch (Exception $e) { echo "Error checking domain: " . $e->getMessage() . "\n"; } // Use a specific regional endpoint (e.g., US) $usChecker = new TempMailChecker('your_api_key', TempMailChecker::ENDPOINT_US); try { $result = $usChecker->check('user@example.com'); // Process result... } catch (Exception $e) { echo "Error checking email with US endpoint: " . $e->getMessage() . "\n"; } // Get usage statistics try { $usage = $checker->getUsage(); echo "Usage Today: " . $usage['usage_today'] . " / " . $usage['limit'] . "\n"; echo "Reset Time: " . $usage['reset'] . "\n"; } catch (Exception $e) { echo "Error retrieving usage: " . $e->getMessage() . "\n"; } // Full error handling example in a controller // class RegisterController extends Controller // { // public function register(Request $request) // { // $email = $request->input('email'); // $checker = new TempMailChecker(config('services.tempmailchecker.key')); // try { // $result = $checker->check($email); // if ($result['temp']) { // return back()->withErrors(['email' => 'Please use a permanent email address.']); // } // } catch (Exception $e) { // if (strpos($e->getMessage(), 'Rate limit') !== false) { // // Allow registration but flag for review // } elseif (strpos($e->getMessage(), 'Invalid API key') !== false) { // error_log('TempMailChecker: invalid API key'); // } // } // // Continue with registration... // } // } ``` ``` -------------------------------- ### Node.js SDK Error Handling Source: https://github.com/fushey/api-documentation/blob/main/docs/errors.md Example of how to handle API errors using the TempMailChecker Node.js SDK. ```APIDOC ## Handling Errors in Node.js SDK ```javascript import { TempMailChecker } from '@tempmailchecker/node-sdk'; const checker = new TempMailChecker('your_api_key'); try { const result = await checker.check(email); } catch (error) { if (error.message.includes('Rate limit')) { console.log('Rate limit exceeded, try again later'); } else if (error.message.includes('Invalid API key')) { console.log('Invalid API key'); } else { console.error('Error:', error.message); } } ``` ``` -------------------------------- ### Get Usage Success Response Source: https://github.com/fushey/api-documentation/blob/main/docs/api-reference.md The response provides today's request count, the daily limit, and the time when the counter resets. ```json { "usage_today": 15, "limit": 25, "reset": "midnight UTC" } ``` -------------------------------- ### PHP SDK Usage Source: https://context7.com/fushey/api-documentation/llms.txt Example of using the PHP SDK to check emails, check domains, select regional endpoints, and retrieve usage statistics. Includes basic error handling for rate limits and invalid API keys within a Laravel controller context. ```php check('user@tempmail.com'); if ($result['temp']) { echo "Disposable email detected!\n"; } // Check domain $result = $checker->checkDomain('guerrillamail.com'); // Use US regional endpoint $usChecker = new TempMailChecker('your_api_key', TempMailChecker::ENDPOINT_US); // Get usage $usage = $checker->getUsage(); echo "Used: {$usage['usage_today']} / {$usage['limit']}\n"; // Full error handling in a Laravel registration controller class RegisterController extends Controller { public function register(Request $request) { $email = $request->input('email'); $checker = new TempMailChecker(config('services.tempmailchecker.key')); try { $result = $checker->check($email); if ($result['temp']) { return back()->withErrors(['email' => 'Please use a permanent email address.']); } } catch (Exception $e) { if (strpos($e->getMessage(), 'Rate limit') !== false) { // Allow registration but flag for review } elseif (strpos($e->getMessage(), 'Invalid API key') !== false) { error_log('TempMailChecker: invalid API key'); } } // Continue with registration... } } ``` -------------------------------- ### Go Error Handling with TempMailChecker SDK Source: https://github.com/fushey/api-documentation/blob/main/docs/errors.md This Go code example shows how to check for specific error types returned by the TempMailChecker SDK, such as rate limit errors or general API errors, using helper functions. ```go import tempmailchecker "github.com/Fushey/go-disposable-email-checker" checker := tempmailchecker.MustNew("your_api_key") result, err := checker.Check(email) if err != nil { if tempmailchecker.IsRateLimitError(err) { fmt.Println("Rate limit exceeded, try again later") } else if tempmailchecker.IsAPIError(err) { fmt.Printf("API error: %v\n", err) } else { fmt.Printf("Error: %v\n", err) } return } ``` -------------------------------- ### Get Usage Statistics Source: https://context7.com/fushey/api-documentation/llms.txt Retrieve your current daily API usage, your limit, and when the counter resets. This endpoint uses a query parameter for the key instead of the `X-API-Key` header. ```APIDOC ## Get Usage Statistics ### Description Retrieve your current daily API usage, your limit, and when the counter resets. This endpoint uses a query parameter for the key rather than the `X-API-Key` header. ### Method GET ### Endpoint `https://tempmailchecker.com/usage?key=[your_api_key]` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. ### Request Example ```bash curl "https://tempmailchecker.com/usage?key=tmck_your_api_key" ``` ### Response #### Success Response (200) - **usage_today** (integer) - The number of API requests made today. - **limit** (integer) - Your daily API request limit. - **reset** (string) - The time when the usage counter resets (e.g., "midnight UTC"). #### Response Example ```json { "usage_today": 15, "limit": 25, "reset": "midnight UTC" } ``` ``` -------------------------------- ### REST API Usage Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Example of how to use the TempMailChecker REST API directly with cURL for checking emails. ```APIDOC ## Other Languages Don't see your language? The TempMailChecker API is a simple REST API that works with any HTTP client. ```bash curl "https://tempmailchecker.com/check?email=test@example.com" \ -H "X-API-Key: your_api_key" ``` See the [API Reference](api-reference.md) for complete documentation. ``` -------------------------------- ### Get Usage Statistics with cURL Source: https://context7.com/fushey/api-documentation/llms.txt Use cURL to retrieve your current daily API usage, the limit, and the reset time. This endpoint requires the API key as a query parameter. ```bash # cURL — check usage curl "https://tempmailchecker.com/usage?key=tmck_your_api_key" ``` ```json # Response # { # "usage_today": 15, # "limit": 25, # "reset": "midnight UTC" # } ``` -------------------------------- ### Get Usage Endpoint Source: https://github.com/fushey/api-documentation/blob/main/docs/api-reference.md Retrieve your current API usage statistics. This endpoint requires your API key as a query parameter, not in the header. ```http GET /usage?key={api_key} ``` -------------------------------- ### API JSON Response Examples Source: https://github.com/fushey/api-documentation/blob/main/docs/getting-started.md The API returns a JSON object indicating whether the email is disposable ('temp': true) or legitimate ('temp': false). ```json {"temp": true} // Email is disposable ``` ```json {"temp": false} // Email is legitimate ``` -------------------------------- ### Implement Rate Limiting for Batch Processing Source: https://github.com/fushey/api-documentation/blob/main/docs/rate-limits.md When processing large lists of emails, introduce delays between API requests to stay within rate limits. This example uses `time.sleep` to pause execution, ensuring a controlled request rate. ```python import time emails = [...] # Large list for email in emails: result = checker.check(email) process(result) time.sleep(0.1) # 100ms between requests = 600/minute max ``` -------------------------------- ### Real-time Email Validation in HTML Form (JavaScript) Source: https://github.com/fushey/api-documentation/blob/main/docs/examples.md Perform real-time disposable email validation directly in an HTML form using JavaScript. This example uses a debounced input event listener and fetches results from a hypothetical `/api/check-email` endpoint. ```html
``` -------------------------------- ### Initialize and Use Go SDK Source: https://context7.com/fushey/api-documentation/llms.txt Instantiate the client using an API key and functional options for configuration. Handles email and domain checks, and retrieves usage statistics. ```go // Install: go get github.com/Fushey/go-disposable-email-checker package main import ( "fmt" "os" tempmailchecker "github.com/Fushey/go-disposable-email-checker" ) func main() { // Create client checker := tempmailchecker.MustNew(os.Getenv("TEMPMAILCHECKER_API_KEY")) // Check email result, err := checker.Check("user@tempmail.com") if err != nil { handleError(err) return } if result.Temp { fmt.Println("Disposable email detected!") } // Check domain result, _ = checker.CheckDomain("guerrillamail.com") // Use US regional endpoint usChecker, _ := tempmailchecker.New("your_api_key", tempmailchecker.WithEndpoint(tempmailchecker.EndpointUS), ) _ = usChecker // Get usage usage, _ := checker.GetUsage() fmt.Printf("Used: %d / %d\n", usage.UsageToday, usage.Limit) } func handleError(err error) { if tempmailchecker.IsRateLimitError(err) { fmt.Println("Rate limit exceeded, try again after midnight UTC") } else if tempmailchecker.IsAPIError(err) { fmt.Printf("API error: %v\n", err) } else { fmt.Printf("Unexpected error: %v\n", err) } } ``` ```go // Install: go get github.com/Fushey/go-disposable-email-checker package main import ( "fmt" "os" tempmailchecker "github.com/Fushey/go-disposable-email-checker" ) func main() { // Create client checker := tempmailchecker.MustNew(os.Getenv("TEMPMAILCHECKER_API_KEY")) // Check email result, err := checker.Check("user@tempmail.com") if err != nil { handleError(err) return } if result.Temp { fmt.Println("Disposable email detected!") } // Check domain result, _ = checker.CheckDomain("guerrillamail.com") // Use US regional endpoint usChecker, _ := tempmailchecker.New("your_api_key", tempmailchecker.WithEndpoint(tempmailchecker.EndpointUS), ) _ = usChecker // Get usage usage, _ := checker.GetUsage() fmt.Printf("Used: %d / %d\n", usage.UsageToday, usage.Limit) } func handleError(err error) { if tempmailchecker.IsRateLimitError(err) { fmt.Println("Rate limit exceeded, try again after midnight UTC") } else if tempmailchecker.IsAPIError(err) { fmt.Printf("API error: %v\n", err) } else { fmt.Printf("Unexpected error: %v\n", err) } } ``` -------------------------------- ### Go SDK Usage Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Import the SDK package, create a client using MustNew or New with your API key, and then check emails or domains. Regional endpoints can be configured using WithEndpoint. ```go package main import ( "fmt" tempmailchecker "github.com/Fushey/go-disposable-email-checker" ) func main() { // Create client checker := tempmailchecker.MustNew("your_api_key") // Check email result, _ := checker.Check("user@tempmail.com") if result.Temp { fmt.Println("Disposable email!") } // Check domain result, _ = checker.CheckDomain("tempmail.com") // Use regional endpoint checker, _ = tempmailchecker.New("your_api_key", tempmailchecker.WithEndpoint(tempmailchecker.EndpointUS), ) // Get usage usage, _ := checker.GetUsage() fmt.Printf("Used: %d / %d\n", usage.UsageToday, usage.Limit) } ``` -------------------------------- ### Node.js SDK Usage Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Import the necessary components, create a client with your API key, and then check emails or domains. Regional endpoints can be configured during client instantiation. ```javascript import { TempMailChecker, ENDPOINT_US } from '@tempmailchecker/node-sdk'; // Create client const checker = new TempMailChecker('your_api_key'); // Check email const result = await checker.check('user@tempmail.com'); if (result.temp) { console.log('Disposable email!'); } // Check domain const domainResult = await checker.checkDomain('tempmail.com'); // Use regional endpoint const usChecker = new TempMailChecker('your_api_key', { endpoint: ENDPOINT_US }); // Get usage const usage = await checker.getUsage(); console.log(`Used: ${usage.usage_today} / ${usage.limit}`); ``` -------------------------------- ### API Key Authentication Header Source: https://github.com/fushey/api-documentation/blob/main/docs/api-reference.md Include your API key in the request header for authentication. Get your free API key from tempmailchecker.com. ```http X-API-Key: your_api_key ``` -------------------------------- ### Python SDK Usage Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Import the TempMailChecker class and constants, create a client with your API key, and then check emails or domains. Regional endpoints can be specified during client creation. ```python from tempmailchecker import TempMailChecker, ENDPOINT_US # Create client checker = TempMailChecker('your_api_key') # Check email result = checker.check('user@tempmail.com') if result['temp']: print('Disposable email!') # Check domain result = checker.check_domain('tempmail.com') # Use regional endpoint checker = TempMailChecker('your_api_key', endpoint=ENDPOINT_US) # Get usage usage = checker.get_usage() print(f"Used: {usage['usage_today']} / {usage['limit']}") ``` -------------------------------- ### Best Practice: Cache Results Source: https://github.com/fushey/api-documentation/blob/main/docs/errors.md Illustrates how to implement caching to reduce redundant API calls and improve performance. ```APIDOC ## Best Practice: Cache Results ```javascript const cache = new Map(); async function checkCached(email) { const domain = email.split('@')[1]; if (cache.has(domain)) { return cache.get(domain); } const result = await checker.check(email); cache.set(domain, result); return result; } ``` ``` -------------------------------- ### Best Practice: Graceful Degradation Source: https://github.com/fushey/api-documentation/blob/main/docs/errors.md Shows how to implement graceful degradation to ensure application availability even when the API is experiencing issues. ```APIDOC ## Best Practice: Graceful Degradation ```javascript async function validateEmail(email) { try { const result = await checker.check(email); return !result.temp; } catch (error) { // If the API is unavailable, allow the email console.error('Email check failed, allowing:', error); return true; } } ``` ``` -------------------------------- ### PHP SDK Usage Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Instantiate the client with your API key, check emails or domains, and retrieve usage statistics. Regional endpoints can also be specified. ```php check('user@tempmail.com'); if ($result['temp']) { echo "Disposable email!"; } // Check domain $result = $checker->checkDomain('tempmail.com'); // Use regional endpoint $checker = new TempMailChecker('your_api_key', TempMailChecker::ENDPOINT_US); // Get usage $usage = $checker->getUsage(); echo "Used: {$usage['usage_today']} / {$usage['limit']}"; ``` -------------------------------- ### Best Practice: Implement Retries Source: https://github.com/fushey/api-documentation/blob/main/docs/errors.md Demonstrates a strategy for implementing retries with exponential backoff for handling transient API errors. ```APIDOC ## Best Practice: Implement Retries ```javascript async function checkWithRetry(email, maxRetries = 3) { for (let i = 0; i < maxRetries; i++) { try { return await checker.check(email); } catch (error) { if (error.message.includes('Rate limit')) { throw error; // Do not retry rate limits } if (i === maxRetries - 1) throw error; await sleep(1000 * Math.pow(2, i)); // Exponential backoff } } } ``` ``` -------------------------------- ### Check Email with Go SDK Source: https://github.com/fushey/api-documentation/blob/main/docs/getting-started.md Initialize the TempMailChecker client with your API key and check an email address using the Go SDK. Detects disposable email addresses. ```go import tempmailchecker "github.com/Fushey/go-disposable-email-checker" checker := tempmailchecker.MustNew("YOUR_API_KEY") result, _ := checker.Check("test@tempmail.com") if result.Temp { fmt.Println("Disposable email detected!") } ``` -------------------------------- ### Check Usage Endpoint Source: https://github.com/fushey/api-documentation/blob/main/docs/rate-limits.md You can check your current API usage against your daily limit using the `/usage` endpoint. Replace `YOUR_API_KEY` with your actual API key. ```APIDOC ## GET /usage ### Description Retrieves the current API usage statistics for the authenticated user. ### Method GET ### Endpoint /usage ### Query Parameters - **key** (string) - Required - Your API key for authentication. ### Response #### Success Response (200) - **usage_today** (integer) - The number of requests made today. - **limit** (integer) - The maximum number of requests allowed per day. - **reset** (string) - The time when the rate limit resets (e.g., 'midnight UTC'). ### Request Example ```bash curl "https://tempmailchecker.com/usage?key=YOUR_API_KEY" ``` ### Response Example ```json { "usage_today": 15, "limit": 25, "reset": "midnight UTC" } ``` ``` -------------------------------- ### Validate Email on Registration Form (Go Gin) Source: https://github.com/fushey/api-documentation/blob/main/docs/examples.md Implement disposable email validation in a Go Gin handler. Initialize the checker with your API key from environment variables. ```go // handlers/auth.go package handlers import ( "github.com/gin-gonic/gin" tempmailchecker "github.com/Fushey/go-disposable-email-checker" ) var checker = tempmailchecker.MustNew(os.Getenv("TEMPMAILCHECKER_API_KEY")) func Register(c *gin.Context) { email := c.PostForm("email") // Check for disposable email result, err := checker.Check(email) if err == nil && result.Temp { c.JSON(400, gin.H{ "error": "Please use a permanent email address.", }) return } // Continue with registration... } ``` -------------------------------- ### Check API Usage with cURL Source: https://github.com/fushey/api-documentation/blob/main/docs/rate-limits.md Use the /usage endpoint to check your current API request usage for the day. Replace YOUR_API_KEY with your actual API key. ```bash curl "https://tempmailchecker.com/usage?key=YOUR_API_KEY" ``` -------------------------------- ### Error Response: Missing Parameter Source: https://github.com/fushey/api-documentation/blob/main/docs/api-reference.md This error occurs if the required 'email' or 'domain' parameter is not included in the request. ```json { "error": "Missing email or domain parameter" } ``` -------------------------------- ### Make a Request using cURL Source: https://github.com/fushey/api-documentation/blob/main/docs/getting-started.md Use this cURL command to make a request to the TempMailChecker API. Replace 'YOUR_API_KEY' with your actual API key. ```bash curl "https://tempmailchecker.com/check?email=test@tempmail.com" \ -H "X-API-Key: YOUR_API_KEY" ``` -------------------------------- ### Invalid API Key Error (401) Source: https://github.com/fushey/api-documentation/blob/main/docs/errors.md Details the error response and solution for when an invalid or missing API key is provided. ```APIDOC ## Invalid API Key (401) ### Description This error is returned when the provided API key is missing, malformed, or does not exist. ### Response Example ```json { "error": "Invalid API key", "temp": null } ``` ### Solution 1. Verify that the `X-API-Key` header is included in your request. 2. Ensure your API key is correct. 3. Obtain a new API key from [tempmailchecker.com](https://tempmailchecker.com) if necessary. ``` -------------------------------- ### Check Email with Node.js SDK Source: https://github.com/fushey/api-documentation/blob/main/docs/getting-started.md Initialize the TempMailChecker client with your API key and check an email address using the Node.js SDK. Identifies disposable emails. ```javascript import { TempMailChecker } from '@tempmailchecker/node-sdk'; const checker = new TempMailChecker('YOUR_API_KEY'); const result = await checker.check('test@tempmail.com'); if (result.temp) { console.log('Disposable email detected!'); } ``` -------------------------------- ### Check Usage Source: https://github.com/fushey/api-documentation/blob/main/README.md Retrieves the current API usage statistics for a given API key. ```APIDOC ## GET /usage?key=your_api_key ### Description Retrieves the current API usage statistics for a given API key. ### Method GET ### Endpoint `/usage?key=your_api_key` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. ### Response #### Success Response (200) - **usage_today** (integer) - The number of requests made today. - **limit** (integer) - The daily request limit. - **reset** (string) - The time when the usage resets (e.g., "midnight UTC"). ### Response Example ```json { "usage_today": 15, "limit": 25, "reset": "midnight UTC" } ``` ``` -------------------------------- ### Direct API Usage with cURL Source: https://github.com/fushey/api-documentation/blob/main/docs/sdks.md Make direct API requests using cURL to check an email address. Ensure you include your API key in the X-API-Key header. ```bash curl "https://tempmailchecker.com/check?email=test@example.com" \ -H "X-API-Key: your_api_key" ```