# How to get ZIP code from Company using HubSpot API (Node.js)?

**URL:** <https://community.hubspot.com/t/how-to-get-zip-code-from-company-using-hubspot-api-node-js/85760>\
**Category:** APIs & Integrations\
**Tags:** companies\
**Created:** [July 20, 2023, 1:07pm UTC](https://community.hubspot.com/t/how-to-get-zip-code-from-company-using-hubspot-api-node-js/85760 "2023-07-20T13:07:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisSosa1337](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@ChrisSosa1337](https://community.hubspot.com/u/ChrisSosa1337)\
**Post date:** [July 20, 2023, 1:07pm UTC](https://community.hubspot.com/t/how-to-get-zip-code-from-company-using-hubspot-api-node-js/85760/1 "2023-07-20T13:07:48Z")

</div>

I am new with the HubSpot API and was working with the sample code from the HubSpot Academy tutorials, and would like to narrow down the API call to the ZIP code. I would like to know, how would I do this using Node.js? Could you please help me out here? Thanks.

---

<div class="post-metadata">

**Author:** ![coldrickjack](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/coldrickjack/32/6684_2.png) [@coldrickjack](https://community.hubspot.com/u/coldrickjack)\
**Post date:** [July 20, 2023, 1:27pm UTC](https://community.hubspot.com/t/how-to-get-zip-code-from-company-using-hubspot-api-node-js/85760/2 "2023-07-20T13:27:47Z")

</div>

Hey @ChrisSosa1337, I’m not super familiar with the exact tutorial you are referring to but if you are hoping to retrieve a specific property for a company you can do something like this:

```lia-code-sample
const hubspot = require('@hubspot/api-client');

const hubspotClient = new hubspot.Client({"accessToken":"YOUR_ACCESS_TOKEN"});

const companyId = "8109465573"; //ID of the company
const properties = ["zip"]; // Add whatever properties you'd like 
const propertiesWithHistory = undefined;
const associations = undefined;
const archived = false;
const idProperty = undefined;

try {
 const apiResponse = await hubspotClient.crm.companies.basicApi.getById(companyId, properties, propertiesWithHistory, associations, archived, idProperty);
 console.log(JSON.stringify(apiResponse, null, 2));
} catch (e) {
 e.message === 'HTTP request failed'
 ? console.error(JSON.stringify(e.response, null, 2))
 : console.error(e)
}

```

Which would return:

```lia-code-sample
{
 "id": "8109465573",
 "properties": {
 "createdate": "2023-07-20T13:25:52.999Z",
 "hs_lastmodifieddate": "2023-07-20T13:25:55.548Z",
 "hs_object_id": "8109465573",
 "zip": "11040"
 },
 "createdAt": "2023-07-20T13:25:52.999Z",
 "updatedAt": "2023-07-20T13:25:55.548Z",
 "archived": false
}

```

---

<div class="post-metadata">

**Author:** ![ChrisSosa1337](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@ChrisSosa1337](https://community.hubspot.com/u/ChrisSosa1337)\
**Post date:** [July 20, 2023, 2:09pm UTC](https://community.hubspot.com/t/how-to-get-zip-code-from-company-using-hubspot-api-node-js/85760/3 "2023-07-20T14:09:02Z")

</div>

This is my current code:

```lia-code-sample
const express = require('express');
const axios = require('axios');
const hubspot = require('@hubspot/api-client');

const app = express();

const private_app_token = 'app_token'

app.get('/companies', async (req, res) => {
 const companies = 'https://api.hubspot.com/crm/v3/objects/companies';
 const headers = {
 Authorization : `Bearer ${private_app_token}`,
 'Content-Type': 'application/json'
 }

 const companyId = "8109465573"; //ID of the company
 const properties = ["zip"]; // Add whatever properties you'd like
 const propertiesWithHistory = undefined;
 const associations = undefined;
 const archived = false;
 const idProperty = undefined;

 try {
 const apiResponse = await hubspotClient.crm.companies.basicApi.getById(companyId, properties, propertiesWithHistory, associations, archived, idProperty);
 console.log(JSON.stringify(apiResponse, null, 2));

 } catch (e) {
 e.message === 'HTTP request failed'
 ? console.error(JSON.stringify(e.response, null, 2))
 : console.error(e)
 }

});

app.listen(3000, () => console.log('Listening on http://localhost:3000'));

```

I am new to this. Anything I am doing wrong? I type [http://localhost:3000/companies](http://localhost:3000/companies) into my browser and I get the error “hubspotClient is not defined”. Could you please help me here?

---

<div class="post-metadata">

**Author:** ![ChrisSosa1337](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@ChrisSosa1337](https://community.hubspot.com/u/ChrisSosa1337)\
**Post date:** [July 20, 2023, 7:51pm UTC](https://community.hubspot.com/t/how-to-get-zip-code-from-company-using-hubspot-api-node-js/85760/4 "2023-07-20T19:51:15Z")

</div>

The example I am using is from this course:  
[Introduction to the HubSpot APIs](https://academy.hubspot.com/courses/introduction-to-hubspot-apis)

I am new to the HubSpot APIs. BTW this is a private app. From your example code, how would I set up Port 3000? It appears your code isn’t using Express. I tried running your code and I get an error that await must be in an async function. Wrapping the code in an async block, nothing happens. I should perhaps view some of the tutorials with the HubSpot CLI to do what I need.
