# Migrating from legacy to v3 api

**URL:** <https://community.hubspot.com/t/migrating-from-legacy-to-v3-api/75510>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [February 19, 2023, 12:55am UTC](https://community.hubspot.com/t/migrating-from-legacy-to-v3-api/75510 "2023-02-19T00:55:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![audreyjw](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/audreyjw/32/60590_2.png) [@audreyjw](https://community.hubspot.com/u/audreyjw)\
**Post date:** [February 19, 2023, 12:55am UTC](https://community.hubspot.com/t/migrating-from-legacy-to-v3-api/75510/1 "2023-02-19T00:55:28Z")

</div>

Hi there!  
Ever since the api keys are now dupricated, I am rewriting my Hubspot apis such that I can use

`Authorization: Bearer <private-app-token>`

Instead of **hapikey=key\_value**

However am I facing **crutial** issues which doesn’t seem to be documented on the latest Hubspot documentation/sites…

**Issue #1**

Since it is mendatory for our system to use Hubspot legacy endpoints

`GET /contacts/v1/lists/all/contacts/all`

`GET /contacts/v1/lists/${id}/contacts/all`

(the List endpoints are not yet available to v3 so I need to keep the legacy endpoints running)  
When I make a request to Get contacts or Get List’s contacts, then only the first page of the response payload data is returned. **The pagination (vidOffset) and request count (count) query params are not working**.

 ![Screenshot 2023-02-18 at 7.47.57 PM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/d/6d1159248f748d10dd39cc98a0eb90f0b2f6bbd6.png)

**Issue #2**

My second issue is when I try calling the GET /limit endpoint, the response always returns a 403 even if I set the same/right Authentication Bearer token using the private app token (while not passing the hapikey=key\_value anymore)

`/integrations/v1/limit/daily`

Here is the error message I am getting:

_Request failed with status code 403 - Could not fetch Hubspot limit_

Can you please help me understand and resolve those 2 issues please?  
Thank you very much.  
**Related documentation:**  
- [Auth Migration](https://developers.hubspot.com/docs/api/migrate-an-api-key-integration-to-a-private-app)  
- [Get List Contacts](https://legacydocs.hubspot.com/docs/methods/contacts/get_contacts)  
- [Get Limit](https://developers.hubspot.com/docs/api/usage-details#rate-limits)

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [February 20, 2023, 8:21am UTC](https://community.hubspot.com/t/migrating-from-legacy-to-v3-api/75510/2 "2023-02-20T08:21:02Z")

</div>

Hello @audreyjw  
Regarding your first issue with the HubSpot legacy endpoints, it is true that the pagination parameters are not supported in those endpoints. However, you can still fetch all the contacts or list contacts by making multiple requests and incrementing the `vidOffset` parameter with each subsequent request until you have fetched all the data. Here’s an example in Node.js:

```lia-code-sample
const axios = require('axios');

async function getAllContacts() {
 let allContacts = [];
 let vidOffset = 0;
 let hasMore = true;
 while (hasMore) {
 const res = await axios.get(`https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=YOUR_API_KEY&vidOffset=${vidOffset}&count=100`);
 allContacts = allContacts.concat(res.data.contacts);
 hasMore = res.data['has-more'];
 vidOffset = res.data['vid-offset'];
 }
 return allContacts;
}

```

Regarding your second issue with the `GET /limit` endpoint, make sure that the private app that you are using has the correct scopes to access the `/limit` endpoint. You can check the scopes by going to the App Marketplace, clicking on your private app, and then clicking on “Scopes” under the “Install” section. Make sure that the “Integrations: Read your API usage limits” scope is selected.  
Thanks & Regards  
Himanshu Rauthan

---

<div class="post-metadata">

**Author:** ![audreyjw](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/audreyjw/32/60590_2.png) [@audreyjw](https://community.hubspot.com/u/audreyjw)\
**Post date:** [February 20, 2023, 4:04pm UTC](https://community.hubspot.com/t/migrating-from-legacy-to-v3-api/75510/3 "2023-02-20T16:04:49Z")

</div>

Hello Himanshu Rauthan,  
Thank you for your reply,  
Regarding **Issue #1** , I realized for the following two endpoints:

`GET /contacts/v1/lists/${id}/contacts/all`

`GET /contacts/v1/lists/all/contacts/all`

I am using **axios** package in nodejs to make the GET request and relized that with version

`axios v1.3.3`

I was not encoding query params arrays properly. Here is what I had to do in order to serialize the _ **property** _ query param (array) for anyone experiencing similary issues in the future:

`paramsSerializer: { // ref: https://github.com/axios/axios/issues/5058#issuecomment-1272107602 indexes: null // by default: false},`

After this change I was able to use the legacy endpoints with my private app token + pagination no problem! Sorry that was my mistake all along…!

---

<div class="post-metadata">

**Author:** ![audreyjw](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/audreyjw/32/60590_2.png) [@audreyjw](https://community.hubspot.com/u/audreyjw)\
**Post date:** [February 20, 2023, 4:05pm UTC](https://community.hubspot.com/t/migrating-from-legacy-to-v3-api/75510/4 "2023-02-20T16:05:18Z")

</div>

For **issue #2** , I do not see the **Integrations: Read your API usage limits** option in my Hubspot account. I navigated here:  
_[https://app.hubspot.com/private-apps/\](https://app.hubspot.com/private-apps/%5C)/\<private-app-id\>/edit_  
I don’t see that option “Installs” under the “_Scopes_” tab:

 ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/b/7b8b83029223ca0bf6b08ccc58e49b0ecce399fe.png)  
Am I not looking at the right place?

Thank you for your help and I am looking forward to your reply.

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [February 21, 2023, 1:22pm UTC](https://community.hubspot.com/t/migrating-from-legacy-to-v3-api/75510/5 "2023-02-21T13:22:17Z")

</div>

Hello @audreyjw  
Private apps can not be installed, they can be directly used by using private token.  
Install option will be available in public apps using oauth2 flow.  
Regarding the apis limits, you can check this doc: [API usage guidelines and limits - HubSpot docs](https://developers.hubspot.com/docs/api/usage-details)  
Thanks & Regrads  
Himanshu Rauthan

---

<div class="post-metadata">

**Author:** ![audreyjw](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/audreyjw/32/60590_2.png) [@audreyjw](https://community.hubspot.com/u/audreyjw)\
**Post date:** [February 21, 2023, 1:34pm UTC](https://community.hubspot.com/t/migrating-from-legacy-to-v3-api/75510/6 "2023-02-21T13:34:23Z")

</div>

Hi Himanshu, not sure I understand you last reply.. You mentioned in your first reply:

> Regarding your second issue with the GET /limit endpoint, make sure that the private app that you are using has the correct scopes to access the /limit endpoint. You can check the scopes by going to the App Marketplace, clicking on your private app, and then clicking on “Scopes” under the “Install” section. Make sure that the “Integrations: Read your API usage limits” scope is selected.
> 
> * * *

So I know that it’s an access token generetad by the private app. 🙂  
In my last reply I shared that I can’t see the :Integrations: Read your API usage limits" scope from the Scopes tab. Nothing is mentioned in the doc regarding this as well.  
Even with the access token set in my response header as  
_Authentication: “Bearer \<access-token\>”_  
I am getting:  
_Request failed with status code 403 - Could not fetch Hubspot limit_  
Looking forward to solve this issue.

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [February 21, 2023, 1:50pm UTC](https://community.hubspot.com/t/migrating-from-legacy-to-v3-api/75510/7 "2023-02-21T13:50:31Z")

</div>

@audreyjw  
Sorry for misunderstanding the image which you shared in the scopes section please score down where you can view and modify the scopes that your app has been granted. Make sure that the “Integrations: Read your API usage limits” scope is selected. If it is not, click on “Edit Scopes” and select this scope, then save your changes.  
After you have verified that the correct scope is selected, try making the GET /limit request again and see if the issue has been resolved. If this resolves the issue plz let me know.

---

<div class="post-metadata">

**Author:** ![audreyjw](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/audreyjw/32/60590_2.png) [@audreyjw](https://community.hubspot.com/u/audreyjw)\
**Post date:** [February 21, 2023, 2:33pm UTC](https://community.hubspot.com/t/migrating-from-legacy-to-v3-api/75510/8 "2023-02-21T14:33:58Z")

</div>

Hi @himanshurauthan like mentioned, **I don’t see the option**  **“Integrations: Read your API usage limits”** can you share a URL sample of where I should see this?  
I am currently looking into:  
_[https://app.hubspot.com/private-apps/\](https://app.hubspot.com/private-apps/%5C)/\<private-app-id\>/edit_

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [February 22, 2023, 6:50am UTC](https://community.hubspot.com/t/migrating-from-legacy-to-v3-api/75510/9 "2023-02-22T06:50:04Z")

</div>

Hello @audreyjw  
Apologies for the misunderstanding, I checked especially about getting the rate limits from the API using a private app token but got the same response with status code 403 as you. The oauth scope it is looking for is only available for oauth2 access tokens so it seems there is currently no way to get the data with this endpoint using a private app token. But this rate limit information can be found in the headers of any API call response. So alternatively you can use any of the search endpoints to get that information and get the data from response headers.  
Please let me know if that answers your question. Thanks

 ![image_2023_02_22T03_40_19_323Z.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/c/c5ab21b7601ed708b60fef602a86d7d63e8b9df1.png)

---

<div class="post-metadata">

**Author:** ![audreyjw](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/audreyjw/32/60590_2.png) [@audreyjw](https://community.hubspot.com/u/audreyjw)\
**Post date:** [February 22, 2023, 3:14pm UTC](https://community.hubspot.com/t/migrating-from-legacy-to-v3-api/75510/10 "2023-02-22T15:14:07Z")

</div>

@himanshurauthan Thank you for your clarifications, my understanding is that this api /limit is not supported anymore by the new flow of authentication using the private app access token.  
That being said, I will update my code such that I will read the response headers to know my limits.  
Thank you again for your help!
