from linkup import LinkupClient
import json
from pprint import pprint
class SignupRadar:
def __init__(self, api_key):
self.client = LinkupClient(api_key=api_key)
self.schema = {
"type": "object",
"properties": {
"fullName": {
"type": "string",
"description": "The full name of the person"
},
"company": {
"type": "string",
"description": "The company the person works for"
},
"position": {
"type": "string",
"description": "The job title or position of the person"
},
"linkedInUrl": {
"type": "string",
"description": "The LinkedIn profile URL of the person"
},
"companyWebsite": {
"type": "string",
"description": "The website of the company"
},
"additionalInfo": {
"type": "string",
"description": "Any additional relevant information about the person"
}
},
"required": ["fullName", "company"]
}
self.schema_str = json.dumps(self.schema)
def generate_query(self, email):
name_part = email.split('@')[0]
domain = email.split('@')[1]
# Handle different name formats (snake_case, dot.case, etc.)
if "_" in name_part:
name_parts = name_part.split("_")
formatted_name = " ".join(part.capitalize() for part in name_parts)
elif "." in name_part:
name_parts = name_part.split(".")
formatted_name = " ".join(part.capitalize() for part in name_parts)
else:
formatted_name = name_part.capitalize()
# Determine company from domain
common_domains = ["gmail.com", "hotmail.com", "outlook.com", "yahoo.com", "icloud.com"]
if domain not in common_domains:
company = domain.split('.')[0].capitalize()
return f"Find the LinkedIn profile URL for this person: {formatted_name} at {company}. If the domain of the email address ({domain}) is not a common email provider, it is probably the name of the company this person works for and {domain} is probably the company website, so search specifically for someone with that name at this company. Return their full name, position, company details, LinkedIn URL, as well as any relevant information you can find about them."
else:
return f"Find the LinkedIn profile URL for this person with email username {formatted_name}. Return their full name, current position, company, and LinkedIn URL."
def lookup(self, email):
query = self.generate_query(email)
response = self.client.search(
query=query,
depth="deep", # Use deep for more thorough results
output_type="structured",
structured_output_schema=self.schema_str
)
return response
# Example usage
if __name__ == "__main__":
radar = SignupRadar(api_key="<YOUR_LINKUP_API_KEY>")
# Example emails
emails = [
"philippe@linkup.so",
"boris@linkup.so"
]
for email in emails:
print(f"\nLooking up: {email}")
result = radar.lookup(email)
pprint(result)