added Neo Browse Call
This commit is contained in:
70
NASA-NeoBrowse.ps1
Normal file
70
NASA-NeoBrowse.ps1
Normal file
@@ -0,0 +1,70 @@
|
||||
Get-Content .env | ForEach-Object {
|
||||
if ($_ -match "^\s*([^#][^=]+)=(.*)$") {
|
||||
$name = $matches[1].Trim()
|
||||
$value = $matches[2].Trim()
|
||||
|
||||
[System.Environment]::SetEnvironmentVariable($name, $value)
|
||||
}
|
||||
}
|
||||
|
||||
$apiKey = $env:API_KEY
|
||||
|
||||
try {
|
||||
$response = Invoke-RestMethod -Uri "https://api.nasa.gov/neo/rest/v1/neo/browse?api_key=$($apiKey)" -ResponseHeadersVariable headers
|
||||
#$response = Invoke-WebRequest -Uri "https://api.nasa.gov/neo/rest/v1/feed?start_date=$($startDate)&end_date=$($endDate)&api_key=$($apiKey)"
|
||||
|
||||
$response | ConvertTo-Json -Depth 10 | Out-File ".\NeoBrowse.json"
|
||||
$limit = $headers["X-RateLimit-Limit"]
|
||||
$remaining = $headers["X-RateLimit-Remaining"]
|
||||
|
||||
Write-Host "-------------"
|
||||
Write-Host "Rate Limit: $limit"
|
||||
Write-Host "Remaining : $remaining"
|
||||
Write-Host "-------------"
|
||||
}
|
||||
catch {
|
||||
Write-Host "Fehler: $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
<#
|
||||
$limit = 0
|
||||
|
||||
$response.near_earth_objects.PSObject.Properties | ForEach-Object {
|
||||
$date = $_.Name
|
||||
$asteroids = $_.Value
|
||||
|
||||
Write-Host "Datum: $date"
|
||||
Write-Host "-------------------"
|
||||
|
||||
foreach ($asteroid in $asteroids) {
|
||||
if($asteroid.is_potentially_hazardous_asteroid){
|
||||
Write-Host "| Name: $($asteroid.name) --- ID: $($asteroid.id)" -ForegroundColor Red
|
||||
}else {
|
||||
Write-Host "| Name: $($asteroid.name) --- ID: $($asteroid.id)" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Write-Host "| Miss-Distance(in KM): $($asteroid.close_approach_data.miss_distance.kilometers)"
|
||||
Write-Host "---------------------"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
# Read-Host
|
||||
|
||||
$ast_id = Read-Host "Enter ID for more information on asteroid: "
|
||||
|
||||
if($ast_id){
|
||||
try {
|
||||
$response = Invoke-RestMethod -Uri "https://api.nasa.gov/neo/rest/v1/neo/$ast_id?api_key=$($apiKey)"
|
||||
|
||||
Write-Host "-------------"
|
||||
Write-Host "Asteroid Info: $response"
|
||||
Write-Host "-------------"
|
||||
}
|
||||
catch {
|
||||
Write-Host "Fehler: $($_.Exception.Message)"
|
||||
}
|
||||
}else{
|
||||
Write-Host "No ID entered."
|
||||
}
|
||||
#>
|
||||
@@ -40,9 +40,9 @@ $response.near_earth_objects.PSObject.Properties | ForEach-Object {
|
||||
|
||||
foreach ($asteroid in $asteroids) {
|
||||
if($asteroid.is_potentially_hazardous_asteroid){
|
||||
Write-Host "| Name: $($asteroid.name) --- Hazardous: $($asteroid.is_potentially_hazardous_asteroid)" -ForegroundColor Red
|
||||
Write-Host "| Name: $($asteroid.name) --- ID: $($asteroid.id)" -ForegroundColor Red
|
||||
}else {
|
||||
Write-Host "| Name: $($asteroid.name) --- Hazardous: $($asteroid.is_potentially_hazardous_asteroid)" -ForegroundColor Green
|
||||
Write-Host "| Name: $($asteroid.name) --- ID: $($asteroid.id)" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Write-Host "| Miss-Distance(in KM): $($asteroid.close_approach_data.miss_distance.kilometers)"
|
||||
@@ -50,3 +50,23 @@ $response.near_earth_objects.PSObject.Properties | ForEach-Object {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
# Read-Host
|
||||
<#
|
||||
$ast_id = Read-Host "Enter ID for more information on asteroid: "
|
||||
|
||||
if($ast_id){
|
||||
try {
|
||||
$response = Invoke-RestMethod -Uri "https://api.nasa.gov/neo/rest/v1/neo/$ast_id?api_key=$($apiKey)"
|
||||
|
||||
Write-Host "-------------"
|
||||
Write-Host "Asteroid Info: $response"
|
||||
Write-Host "-------------"
|
||||
}
|
||||
catch {
|
||||
Write-Host "Fehler: $($_.Exception.Message)"
|
||||
}
|
||||
}else{
|
||||
Write-Host "No ID entered."
|
||||
}
|
||||
#>
|
||||
7171
NeoBrowse.json
Normal file
7171
NeoBrowse.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user