Skip to content

Instantly share code, notes, and snippets.

@matt40k
Last active July 7, 2020 10:30
Show Gist options
  • Save matt40k/84c133de01f29191e65852acbfa89c22 to your computer and use it in GitHub Desktop.
Save matt40k/84c133de01f29191e65852acbfa89c22 to your computer and use it in GitHub Desktop.
Care Quality Commission (CQC) - Basic PowerShell script to query Providers API (https://api.cqc.org.uk/public/v1/)
$url = 'https://api.cqc.org.uk/public/v1/'
$proxy = 'http://proxy:8000'
$limit = '1000000'
#$limit = '5'
$name = 'partnerCode={{ YOUR COMPANY NAME \ CODE }}'
#$limit = '5'
$providersUrl = $url+"providers?perPage=$limit&$name"
Write-Host $providersUrl
$r = Invoke-WebRequest -Uri $providersUrl -Method GET -ProxyUseDefaultCredentials -Proxy $proxy
$items = $r.Content | ConvertFrom-Json
#Write-Host $items.total
$count = 0
$output = ''
foreach ($item in $items.providers)
{
$count = $count + 1
$providerUrl = $url+"providers/"+$item.providerId+"/?"+$name
#Write-Host $count = $providerUrl
$r = Invoke-WebRequest -Uri $providerUrl -Method GET -ProxyUseDefaultCredentials -Proxy $proxy
$provider = $r.Content | ConvertFrom-Json
$out = $provider.providerId + ',' + $provider.name + ',' + $provider.postalCode + ',' + $provider.currentRatings.overall.rating
#Write-Host $out
$output = $output + $out + "`n"
#Write-Host $output
}
Write-Host $output
@pbjones
Copy link

pbjones commented Jan 12, 2018

Interesting - you've also gone max rows on a single call. I thought there might be a way to search and be a bit more efficient but it looks like this is the only way to go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment