Skip to content

Authentication

All /api/v1/* endpoints require an API key for authentication.

Authentication Methods

IPSwamp API supports two methods for providing your API key:

Use the Authorization header with a Bearer token:

http
Authorization: Bearer <your-api-key>

Example:

bash
curl -X GET "https://ipswamp.com/api/v1/checkIP?ip=8.8.8.8" \
  -H "Authorization: Bearer your-api-key-here"

API Key Header

Alternatively, use the X-API-Key header:

http
X-API-Key: <your-api-key>

Example:

bash
curl -X GET "https://ipswamp.com/api/v1/checkIP?ip=8.8.8.8" \
  -H "X-API-Key: your-api-key-here"

Getting Your API Key

  1. Log in to your IPSwamp dashboard
  2. Navigate to API Settings
  3. Generate a new API key or copy an existing one
  4. Store your API key securely (never commit it to version control)

Security Warning

Keep your API keys secure. Never expose them in client-side code or public repositories.

Authentication Errors

Status CodeDescriptionSolution
401API key not providedInclude API key in request headers
403Invalid API keyVerify your API key is correct and active
403Expired API keyGenerate a new API key in the dashboard
403Usage limit exceededUpgrade your plan or wait for usage reset

Error Response Format

json
{
	"error": true,
	"statusCode": 401,
	"message": "API key required..."
}

Testing Your API Key

Use the test-key endpoint to validate your API key and check usage:

bash
curl -X GET "https://ipswamp.com/api/v1/test-key" \
  -H "Authorization: Bearer your-api-key-here"

Success Response:

json
{
	"success": true,
	"message": "API key validation successful! -1 Request",
	"timestamp": "2025-12-10T14:30:00.000Z",
	"organization_id": "org_abc123",
	"api_key_info": {
		"uid": "key_xyz789",
		"name": "Production API Key",
		"current_usage": 1500,
		"max_api_requests": 10000,
		"created_at": "2025-01-15T09:00:00.000Z"
	}
}

Best Practices

  1. Use environment variables to store API keys
  2. Rotate keys regularly for enhanced security
  3. Create separate keys for development and production
  4. Monitor usage via the test-key endpoint
  5. Implement retry logic with exponential backoff for rate limits

IPSwamp API Documentation