Develo API Example:

This is an example of using Develo's API to search for an address, and then order a report:

 
import requests
import time
import os

#Search for an address to return it's ID
def SearchAddress(address: str):
    url = "https://app.develo.com.au/api/v2/geocoder/search"
    headers = {"Develo-Api-Token": f"{my_token}"}
    params = {"search": address}
    
    response = requests.get(url, headers=headers, params=params, timeout=10)
    response.raise_for_status()
    
    # Get first response and return the GUID/ID
    data = response.json()
    print(data)
    if data and len(data) > 0:
        return data[0]['guid']
    return None

#Order a report using the property guid
def OrderReport(spd_guid:str):
    url = "https://app.develo.com.au/api/v2/reports/order/spd"
    headers = {"Develo-Api-Token": f"{my_token}"}
    payload = {"spd": spd_guid}
    
    response = requests.post(url, headers=headers, json=payload, timeout=10)
    response.raise_for_status()
    print(response.json())
    return response.json()['uuid']

#Check the status of an ordered report
def CheckReportStatus(report_id:str):
    url = f"https://app.develo.com.au/api/v2/reports/{report_id}"
    headers = {"Develo-Api-Token": f"{my_token}"}

    response = requests.get(url, headers=headers, timeout=10)
    response.raise_for_status()
    print(response.json())
    return response.json()
	
#Download a report
def DownloadReport(pdf_url: str):
    print(pdf_url)
    response = requests.get(pdf_url, timeout=10)
    
    script_dir = os.path.dirname(os.path.abspath(__file__))
    filename = "develo_report.pdf"
    file_path = os.path.join(script_dir, filename)
    
    with open(file_path, 'wb') as f:
        f.write(response.content)
    print(f"Report downloaded successfully as {file_path}")



def main():
    global my_token
    
    my_token = "YOUR TOKEN HERE"
    address = "202 Ann St, Brisbane City QLD 4000"
    
    #search for an address
    spd_guid = SearchAddress(address)
    
    #if an address was found
    if spd_guid:
    
        #order a report
        report_id = OrderReport(spd_guid)
        
        #poll and wait for it
        while True:
            
            #get the report's data
            data = CheckReportStatus(report_id)
            
            # Not ready yet
            if data['status'].lower() != 'success':
                print(f"Status: {data['status']}. Waiting...")
                time.sleep(30)
            
            # Report is completed
            else:
                DownloadReport(data['pdf_url'])
                break # Exit loop once downloaded
    else:
        print("Address not found.")

if __name__ == "__main__":
    main()