Skip to content

Instantly share code, notes, and snippets.

@digideskio
Forked from matt40k/cqc.ps1
Created December 20, 2017 02:40
Show Gist options
  • Save digideskio/bc5794bcbbb1eadb23da00fbebce62bf to your computer and use it in GitHub Desktop.
Save digideskio/bc5794bcbbb1eadb23da00fbebce62bf 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment