APIs & Integrations

mpal5
Member

How to get company postcode (zip code)

SOLVE

Hello,
I am trying to retrieve data from HubSpot using Hubspot API for python https://github.com/HubSpot/hubspot-api-python.
My code is:
from hubspot import HubSpot
from hubspot.auth.oauth import ApiException

api_client = HubSpot()

client_id = "#####"
client_secret = "#####"
code = '#####'
try:
tokens = api_client.auth.oauth.tokens_api.create_token(
grant_type="authorization_code",
redirect_uri="https://www.example.com/auth-callback",
client_id=client_id,
client_secret=client_secret,
code=code
)
except ApiException as e:
print("Exception when calling create_token method: %s\n" % e)

api_client = HubSpot(access_token=tokens.access_token)

all_companies = api_client.crm.companies.get_all()
print(all_companies)

However, this request returns me some info about companies. Properties field contains info:

'properties': {'createdate': '2022-04-11T09:35:55.818Z',
                'domain': 'mycompany.com',
                'hs_lastmodifieddate': '2022-04-11T09:38:27.998Z',
                'hs_object_id': '1234567',
                'name': 'My Company'},

I need address and postcode for the company. In my account this info is available, I see  that this info comes from HubSpot Insights database.
Could you please suggest me how to get company address in my case?

Many thanks!


 

 

 

0 Upvotes
1 Accepted solution
taran42
Solution
Contributor

How to get company postcode (zip code)

SOLVE

@mpal5 I'm less familiar with v3 as v2, but I think they work the same way as in you need to call the properties you are looking for. From the v3 GitHub documentation: 

 

try:
    simple_public_object_input = SimplePublicObjectInput(
        properties={"email": "email@example.com"}
    )

 

So you need to call the address and postcode properties in place of email.

View solution in original post

3 Replies 3
taran42
Solution
Contributor

How to get company postcode (zip code)

SOLVE

@mpal5 I'm less familiar with v3 as v2, but I think they work the same way as in you need to call the properties you are looking for. From the v3 GitHub documentation: 

 

try:
    simple_public_object_input = SimplePublicObjectInput(
        properties={"email": "email@example.com"}
    )

 

So you need to call the address and postcode properties in place of email.

mpal5
Member

How to get company postcode (zip code)

SOLVE

Thank you @taran42 !

It works for me in this way:
all_companies = api_client.crm.companies.get_all(properties="city","state","country","zip","domain", "industry", "name"])

Jaycee_Lewis
Community Manager
Community Manager

How to get company postcode (zip code)

SOLVE

Hi, @mpal5 👋 Thanks for reaching out. Hey @taran42, do you have any Python expertise you can share with @mpal5?

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes