<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Node.js and client documentation in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/582041#M51134</link>
    <description>&lt;P&gt;Has this documentation been uploaded somewhere?&lt;/P&gt;</description>
    <pubDate>Wed, 23 Feb 2022 18:40:51 GMT</pubDate>
    <dc:creator>JForcherio</dc:creator>
    <dc:date>2022-02-23T18:40:51Z</dc:date>
    <item>
      <title>Node.js and client documentation</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/409859#M40555</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a node script writtent that uses&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/63720"&gt;@hubspot&lt;/a&gt;/api-client but Its not clear to me how to use this module. I was hoping to find documentation on its github page but all I see is into stuff and examples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I missing, where is the documentation for it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I look at the API reference the node examples simply use require() and not the api-client so Im thinking of just ignoring the client and sticking with basic require()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the advantage of the node client module?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All thoughts and suggestions welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 01:23:17 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/409859#M40555</guid>
      <dc:creator>Wallace</dc:creator>
      <dc:date>2021-02-17T01:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: Node.js and client documentation</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410071#M40580</link>
      <description>&lt;P&gt;I too have the same question. The examples provided aren't very helpful. Where is a basic get request of a specific company or contact?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 16:43:20 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410071#M40580</guid>
      <dc:creator>NMichniok</dc:creator>
      <dc:date>2021-02-17T16:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Node.js and client documentation</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410235#M40623</link>
      <description>&lt;P&gt;If it helps I found that we can call any API using something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;async function getLineItems(dealId) {
  showApiCall('Calling /crm/v3/associations/deal/line_items/batch/read API method. id:', dealId);
  let apiResponse = await hubSpotClient.apiRequest({
    method: 'POST',
    path: '/crm/v3/associations/deal/line_items/batch/read',
    body: { inputs: [{ id: dealId }] },
  });

  return apiResponse.body;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then we can call it and loop through linked line items like:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  let deals = await getDeals(companyId).catch(e =&amp;gt; { showError(e) });
  let requestStatus = deals.status;
  // TODO: handle retrieving more than one page of deals
  if (deals.results.length &amp;gt; 0) {
    let result = deals.results[0];
    let to = result.to;
    to.forEach(async function (deal) {
      let dealId = deal.id;
....&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So we can use the client modeule even though it has not been configured for all end points.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The endpoints I have worked out so far as the nice and simple ones like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;apiResponse = await hubSpotClient.crm.companies.basicApi.getById(id);
apiResponse = await hubSpotClient.crm.deals.basicApi.getById(id);
apiResponse = await hubSpotClient.crm.lineItems.basicApi.getById(id);
apiResponse = await hubSpotClient.crm.products.basicApi.getById(id);
// the pattern becomes obvious after a while &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still would have been nice to read this in a simple doc page somwhere.. which Im sure exists....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 01:39:23 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410235#M40623</guid>
      <dc:creator>Wallace</dc:creator>
      <dc:date>2021-02-18T01:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Node.js and client documentation</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410491#M40661</link>
      <description>&lt;P&gt;Thanks Wallace. That is helpful. I've only been able to find any of the functions by either sifting through the source code our doing a getOwnPropertyNames() call to see what the properties are available. I have also been digging through the basicApi for companies and contacts as well as the associationsApi that associates a company with a contact (and vice versa). I found that the Readme on github is incorrect for the associationsApi.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the docs it shows the following for the associationsApi:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;hubspotClient.crm.companies.associationsApi.create(
    createCompanyResponse.body.id,
    'contacts',
    createContactResponse.body.id,
)&lt;/LI-CODE&gt;&lt;P&gt;When in fact there is a 4th property necessary,&amp;nbsp;&lt;SPAN class="pl-s1"&gt;associationType&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN class="pl-smi"&gt;string. The associationType must be one of 28 different types (&lt;A href="https://legacydocs.hubspot.com/docs/methods/crm-associations/crm-associations-overview" target="_blank"&gt;https://legacydocs.hubspot.com/docs/methods/crm-associations/crm-associations-overview&lt;/A&gt;). For companies and contacts I have been using either 'company_to_contact' or 'contact_to_company'. Thus, the above code is now:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;hubspotClient.crm.companies.associationsApi.create(
    createCompanyResponse.body.id,
    'contacts',
    createContactResponse.body.id,
    'company_to_contact'
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 15:26:18 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410491#M40661</guid>
      <dc:creator>NMichniok</dc:creator>
      <dc:date>2021-02-18T15:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Node.js and client documentation</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410505#M40665</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/156136"&gt;@Wallace&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;Thanks!&amp;nbsp; We are actively working on documentation.&amp;nbsp; I also invite the community to write up their version of documentation and share it with the community &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;.&amp;nbsp; Let me know if you are interested and we can write up a blog post!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 15:39:05 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410505#M40665</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2021-02-18T15:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Node.js and client documentation</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410691#M40687</link>
      <description>&lt;P&gt;Good find!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also found out something invaluable when working with the client in node.js..&amp;nbsp; &amp;nbsp;don't use &lt;STRONG&gt;forEach()&lt;/STRONG&gt; as I had initially (above).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you are reading one object and from that getting a batch of associated objects, loop though them with &lt;STRONG&gt;for()&lt;/STRONG&gt; not &lt;STRONG&gt;forEach()&lt;/STRONG&gt; otherwise the code does not wait for each to finish even thought you added await.&lt;/P&gt;&lt;P&gt;You need this sort of looping logic to build up a complete temporary model of what your working with.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  let deals = await getDeals(companyId).catch(e =&amp;gt; { showError(e) });
  // TODO: handle retrieving more than one page of deals via deals.status;
  if (deals.results.length &amp;gt; 0) {
    let result = deals.results[0];
    for (const deal of result.to) {
      let dealId = deal.id;
      if (dealId) {
        // TODO when we need info about the deal..
        // let deal = await getDeal(dealId).catch(e =&amp;gt; { showError(e) });
        let lineItems = await getLineItems(dealId).catch(e =&amp;gt; { showError(e) });
        if (lineItems.results.length &amp;gt; 0) {
          let lineItemResult = lineItems.results[0];
          for (const lineItem of lineItemResult.to) {
            let lineItemId = lineItem.id;
            if (lineItemId) {
              let lineItem = await getLineItem(lineItemId).catch(e =&amp;gt; { showError(e) });
              let productId = lineItem.hs_product_id;
              if (productId) {
                let product = await getProduct(productId).catch(e =&amp;gt; { showError(e) });
...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll keep posting useful bits of info here for now.. no time to do anything more useful or productive.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 22:55:25 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410691#M40687</guid>
      <dc:creator>Wallace</dc:creator>
      <dc:date>2021-02-18T22:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Node.js and client documentation</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410708#M40688</link>
      <description>&lt;P&gt;And for those who like doing things faster.. looks like we can run the APIs in parralel by grouping all of the requests into one promise and waiting for them all to finish.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the same code above modified to get the deals and line items in parallel and using map to process each found:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  let deals = await getDeals(companyId).catch(e =&amp;gt; { showError(e) });
  // TODO: handle retrieving more than one page of deals via deals.status;
  if (deals.results.length &amp;gt; 0) {
    let dealList = deals.results[0];
    if (dealList.to) {
      await Promise.all(dealList.to.map(async (dealInfo) =&amp;gt; {
        if (dealInfo.id) {
          const lineItems = await getLineItems(dealInfo.id);
          if (lineItems.results.length &amp;gt; 0) {
            let lineItemList = lineItems.results[0];
            if (lineItemList.to) {
              await Promise.all(lineItemList.to.map(async (lineItemInfo) =&amp;gt; {
                if (lineItemInfo.id) {
                  let lineItem = await getLineItem(lineItemInfo.id).catch(e =&amp;gt; { showError(e) });
                  if (lineItem.hs_product_id) {
                    let product = await getProduct(lineItem.hs_product_id).catch(e =&amp;gt; { showError(e) });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 01:43:04 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410708#M40688</guid>
      <dc:creator>Wallace</dc:creator>
      <dc:date>2021-02-19T01:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Node.js and client documentation</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410709#M40689</link>
      <description>So when are we going to talk about that blog post &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;</description>
      <pubDate>Fri, 19 Feb 2021 01:45:20 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/410709#M40689</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2021-02-19T01:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Node.js and client documentation</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/542517#M49468</link>
      <description>&lt;P&gt;Thanks very much for your post Wallace.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd hit a wall writing custom code workflow steps which require use of the sparsely documented Hubspot Node API. There are a lot of methods which the Node API doesn't include (like support for custom objects), and your post has now opened up all of the Hubspot APIs I need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only Hubspot documentation I could find about this was on their &lt;A href="https://github.com/HubSpot/hubspot-api-nodejs#not-wrapped-endpoints" target="_blank" rel="noopener"&gt;Node JS API page on Github&lt;/A&gt;, but your post got me over the line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 05:43:32 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/542517#M49468</guid>
      <dc:creator>WaydeChristie1</dc:creator>
      <dc:date>2021-12-15T05:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Node.js and client documentation</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/582031#M51133</link>
      <description>&lt;P&gt;Found this while looking for docs. Are those up yet?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 18:33:47 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/582031#M51133</guid>
      <dc:creator>JForcherio</dc:creator>
      <dc:date>2022-02-23T18:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Node.js and client documentation</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/582041#M51134</link>
      <description>&lt;P&gt;Has this documentation been uploaded somewhere?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 18:40:51 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/582041#M51134</guid>
      <dc:creator>JForcherio</dc:creator>
      <dc:date>2022-02-23T18:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Node.js and client documentation</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/862248#M68094</link>
      <description>&lt;P&gt;Do these documents exist yet? When I go through the API reference docs I dont see any for Client Libraries&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 13:37:10 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Node-js-and-client-documentation/m-p/862248#M68094</guid>
      <dc:creator>ABrown65</dc:creator>
      <dc:date>2023-10-10T13:37:10Z</dc:date>
    </item>
  </channel>
</rss>

