Created
June 10, 2024 07:27
-
-
Save ninthwalker/51111c3651b7532b85dce736934919d0 to your computer and use it in GitHub Desktop.
Map WoW Id to Name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Map WoW Item Id to Name | |
# set these to your own values | |
$importPath = "C:\temp\your_id_list.csv" | |
$exportPath = "C:\temp\wow_id_to_name_export.csv" | |
$csvHeader = "yourCSVHeaderFromIdList" | |
$client_id = "your client id" | |
$client_secret = "your client secret" | |
# get client info from: https://develop.battle.net/documentation/guides/getting-started | |
# import your item ID's. If they aren't in a csv format, there is other import methods you can use as well, can google. | |
$itemIds = (Import-Csv $importPath).$csvHeader | |
# get api token | |
$creds = @{ | |
client_id = $client_id | |
client_secret = $client_secret | |
grant_type = 'client_credentials' | |
} | |
$token = (Invoke-RestMethod "https://us.battle.net/oauth/token" -Body $creds -Method Post).access_token | |
# Iterate over the Ids and create csv | |
$allItems = [System.Collections.Generic.List[object]]::new() | |
foreach ($id in $itemIds) { | |
Try { | |
$name = Invoke-RestMethod -Uri "https://us.api.blizzard.com/data/wow/item/$($id)?namespace=static-us&locale=en_US&access_token=$token" -ContentType application/json | select id,name | |
$allItems.Add($name) | |
} Catch { | |
$err = [PSCustomObject]@{id=$id;name='Not Found or other api error'} | |
$allItems.Add($err) | |
} | |
} | |
$allItems | Export-Csv -NoTypeInformation -Path $exportPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment