Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: HubSpot - Get all companies #2165

Merged
merged 4 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
253 changes: 253 additions & 0 deletions HubSpot/HubSpot_Get_all_companies.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "52a997db-a925-41e5-aacb-8e1cbfecec6d",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"<img width=\"10%\" alt=\"Naas\" src=\"https://landen.imgix.net/jtci2pxwjczr/assets/5ice39g4.png?w=160\"/>"
]
},
{
"cell_type": "markdown",
"id": "de1ed2f4-5465-4afa-b965-e106135dea33",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"# HubSpot - Get all companies"
]
},
{
"cell_type": "markdown",
"id": "7f2d1af8-15b0-4ba5-bc1c-fd2d2a498a40",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Tags:** #hubspot #crm #sales #companies #naas_drivers #snippet #dataframe"
]
},
{
"cell_type": "markdown",
"id": "61c7038a-1801-45f0-850d-2300574950ba",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel)"
]
},
{
"cell_type": "markdown",
"id": "4a8b98b3-0000-4d17-a362-05373542fca3",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Last update:** 2023-08-23 (Created: 2023-08-23)"
]
},
{
"cell_type": "markdown",
"id": "87c35262-d718-4941-81e8-dfdc34b8ba7a",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Description:** This notebook will get all companies from HubSpot CRM using the API and will be usefull to get a list of all companies in the CRM."
]
},
{
"cell_type": "markdown",
"id": "9952f0f8-6851-4b85-9274-6f85a1750829",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**References:**\n",
"- [HubSpot CRM API - Companies](https://developers.hubspot.com/docs/api/crm/companies)"
]
},
{
"cell_type": "markdown",
"id": "51490020-b538-4d09-aa3b-cd3061e1be2d",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Input"
]
},
{
"cell_type": "markdown",
"id": "049b2312-3a43-4650-ab7a-1d1e7cbc0b1a",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Import libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ebc4184a-27c0-4fa2-a611-17979a71fd41",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"from naas_drivers import hubspot\n",
"import naas"
]
},
{
"cell_type": "markdown",
"id": "a2dddd84-07ea-4368-81ed-757450c30da4",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Setup variables\n",
"**Mandatory**\n",
"\n",
"[Get your HubSpot Access token](https://knowledge.hubspot.com/articles/kcs_article/integrations/how-do-i-get-my-hubspot-api-key)\n",
"- `hs_access_token`: This variable stores an access token used for accessing the HubSpot API.\n",
"\n",
"**Optional**\n",
"- `properties`: List of properties (hubspot internal names) you want to get from companies. By default, you will get: createdate, domain, hs_lastmodifieddate, hs_object_id, name. To list of contact properties, you can use this template: \"HubSpot/HubSpot_List_company_properties.ipynb\" stored in https://github.com/jupyter-naas/awesome-notebooks."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7c935df0-f789-4c3c-941f-6aacacfa20d2",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"# Mandatory\n",
"hs_access_token = naas.secret.get(\"HS_ACCESS_TOKEN\") or \"YOUR_HS_ACCESS_TOKEN\"\n",
"\n",
"# Optional\n",
"properties = []"
]
},
{
"cell_type": "markdown",
"id": "1e3363c9-8687-461b-94a6-a6f3f0c716d2",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Model"
]
},
{
"cell_type": "markdown",
"id": "abad510b-c40f-4d93-a8f8-4ad7d4adf623",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Get all companies"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2f474191-97a5-4689-bc7f-0c84f25141b0",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"df_companies = hubspot.connect(hs_access_token).company.get_all(properties)\n",
"print(\"Rows:\", len(df_companies))\n",
"df_companies.head(1)"
]
},
{
"cell_type": "markdown",
"id": "5b97cc5e-4e76-41d4-9847-19f79fbba290",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Output"
]
},
{
"cell_type": "markdown",
"id": "1c322648-6c1a-459c-bdf8-cf7f95f4d413",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Display result"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "280654dd-9531-4f05-a81c-797230fdfa85",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"df_companies"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading