A quick Powershell snippet to integrate into the FraudGuard.io API

This PowerShell script performs the following steps:

  1. Sets the FraudGuard.io API credentials (username and password).
  2. Defines the IP address to query.
  3. Constructs the API endpoint URL.
  4. Converts the credentials to Base64 format for basic authentication.
  5. Sets the Authorization header with the encoded credentials.
  6. Sends a GET request to the API endpoint using Invoke-WebRequest.
  7. Checks if the request was successful (status code 200) and prints the response content.
  8. Prints an error message if the request was unsuccessful.
$username = 'username'
$password = 'password'

# IP address to query
$ipAddress = '8.8.8.8'

# API endpoint
$apiUrl = "https://api.fraudguard.io/ip/$ipAddress"

# Convert credentials to base64
$pair = "$($username):$($password)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"

# Set headers
$headers = @{
    Authorization = $basicAuthValue
}

# Send GET request to the API
$response = Invoke-WebRequest -Uri $apiUrl -Headers $headers

# Check if the request was successful
if ($response.StatusCode -eq 200) {
    $responseContent = $response.Content
    Write-Output $responseContent
} else {
    Write-Output "Error: $($response.StatusCode) - $($response.StatusDescription)"
}

Make sure to replace ‘username’ and ‘password’ with your actual API credentials.