UPRN lookup
To get the address for a UPRN, call Addresses() with the UPRN filter and no query. The UPRN (Unique Property Reference Number) is the number UK local authorities assign to each property and Ordnance Survey maintains.
package main
import (
"context"
"fmt"
"log"
idealpostcodes "go.ideal-postcodes.co.uk/sdk"
)
func main() {
client := idealpostcodes.NewClient("ak_test")
res, err := client.Addresses(context.Background(), &idealpostcodes.AddressesParams{UPRN: 50002012147})
if err != nil {
log.Fatal(err)
}
if hits := res.Result.Hits; len(hits) > 0 {
fmt.Printf("%s, %s, %s\n", hits[0].Line1, hits[0].PostTown, hits[0].Postcode)
}
}This prints 9 Malyons Road, Swanley, BR8 7RE. Query is optional, so set the UPRN filter alone.
Several addresses per UPRN
A key with PAF Alias returns the Royal Mail record plus each alias for the same property. UPRN 1, Bristol City Council, returns three hits: the paf record and two pafa aliases with different department lines. Check Dataset on each hit if you want the Royal Mail record only.
UPRN not found
Hits is empty and the request costs nothing. It does not return an error.
Batch size
Send one request per UPRN: the UPRN filter takes a single value. A Client is safe for concurrent use, so send them from several goroutines if you need throughput.
Cost
One lookup when the UPRN matches an address. Your key needs one of PAF, Multiple Residence, Not Yet Built, PAF Alias, PAF Welsh, AddressBase or AddressBase Premium.
See Addresses() for the other filters, such as PostcodeOutward and PostTown.