HubSpot
HubSpot is a developer and marketer of software products for inbound marketing, sales, and customer service.
The HubSpot Wrapper is a WebAssembly(Wasm) foreign data wrapper which allows you to read data from your HubSpot for use within your Postgres database.
Available Versions
Version | Wasm Package URL | Checksum |
---|---|---|
0.1.0 | https://github.com/supabase/wrappers/releases/download/wasm_hubspot_fdw_v0.1.0/hubspot_fdw.wasm |
2cbf39e9e28aa732a225db09b2186a2342c44697d4fa047652d358e292ba5521 |
Preparation
Before you can query HubSpot, you need to enable the Wrappers extension and store your credentials in Postgres.
Enable Wrappers
Make sure the wrappers
extension is installed on your database:
1 |
|
Enable the HubSpot Wrapper
Enable the Wasm foreign data wrapper:
1 2 3 |
|
Store your credentials (optional)
By default, Postgres stores FDW credentials inside pg_catalog.pg_foreign_server
in plain text. Anyone with access to this table will be able to view these credentials. Wrappers is designed to work with Vault, which provides an additional level of security for storing credentials. We recommend using Vault to store your credentials.
1 2 3 4 5 6 7 |
|
Connecting to HubSpot
We need to provide Postgres with the credentials to access HubSpot and any additional options. We can do this using the create server
command:
1 2 3 4 5 6 7 8 9 10 |
|
1 2 3 4 5 6 7 8 9 10 |
|
Note the fdw_package_*
options are required, which specify the Wasm package metadata. You can get the available package version list from above.
Create a schema
We recommend creating a schema to hold all the foreign tables:
1 |
|
Options
The full list of foreign table options are below:
object
- Object name in HubSpot, required.
Supported objects are listed below:
Object name |
---|
objects/companies |
objects/contacts |
objects/deals |
objects/feedback_submissions |
objects/goal_targets |
objects/leads |
objects/line_items |
objects/<objectType> |
objects/partner_clients |
objects/products |
objects/tickets |
Note
The objectType
in objects/<objectType>
must be substituted with an object type ID, e.g. a custom object 2-3508482
.
Entities
Below are all the entities supported by this FDW. Each entity must have id
, created_at
, updated_at
and attrs
columns, the other columns can be any properties defined on the corresponding HubSpot object. For example, if there is a custom property user_id
defined on the Contacts
object, the table DDL can be:
1 2 3 4 5 6 7 8 9 10 11 |
|
The column user_id
is the custom property internal name, which can be found in the Details
section of Edit property
page on HubSpot Settings
-> Data Management
-> Properties
.
Companies
This is object represents the companies and organizations that interact with your business.
Ref: HubSpot API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
companies | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Notes
- The
attrs
column contains additional user attributes in JSON format
Contacts
This is object represents the contacts.
Ref: HubSpot API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
contacts | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Notes
- The
attrs
column contains additional user attributes in JSON format
Deals
This is object represents the transactions with contacts and/or companies.
Ref: HubSpot API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
deals | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 |
|
Notes
- The
attrs
column contains additional user attributes in JSON format
Feedback submissions
This is object represents the information submitted to your NPS, CSAT, CES, and custom feedback surveys.
Ref: HubSpot API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
feedback_submissions | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 |
|
Notes
- The
attrs
column contains additional user attributes in JSON format
Goals
This is object represents the user-specific quotas for their sales and services teams based on templates provided by HubSpot.
Ref: HubSpot API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
goal_targets | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 |
|
Notes
- The
attrs
column contains additional user attributes in JSON format
Leads
This is object represents the contacts or companies that are potential customers who have shown interest in your products or services.
Ref: HubSpot API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
leads | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 |
|
Notes
- The
attrs
column contains additional user attributes in JSON format
Deals
This is object represents the instances of products to deals and quotes.
Ref: HubSpot API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
line_items | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 |
|
Notes
- The
attrs
column contains additional user attributes in JSON format
Objects
This is object represents the objects included in all accounts, such as contacts and companies, as well as for custom objects.
Ref: HubSpot API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 |
|
Notes
- The
attrs
column contains additional user attributes in JSON format
Partner clients
This is object represents the customers that Solutions Partners have a sold or managed relationship with.
Ref: HubSpot API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
partner_clients | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 |
|
Notes
- The
attrs
column contains additional user attributes in JSON format
Products
This is object represents the collection of goods and services that your company offers.
Ref: HubSpot API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
products | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 |
|
Notes
- The
attrs
column contains additional user attributes in JSON format
Tickets
This is object represents the customer service requests in your CRM.
Ref: HubSpot API docs
Operations
Object | Select | Insert | Update | Delete | Truncate |
---|---|---|---|---|---|
tickets | ✅ | ❌ | ❌ | ❌ | ❌ |
Usage
1 2 3 4 5 6 7 8 9 10 11 |
|
Notes
- The
attrs
column contains additional user attributes in JSON format
Query Pushdown Support
where
clause pushdown
This FDW supports where id = 'xxx'
clause pushdown for all entities. For example,
1 |
|
limit
clause pushdown
This FDW supports limit
clause pushdown for all the entities. For example,
1 |
|
Supported Data Types
Postgres Data Type | HubSpot Data Type |
---|---|
boolean | Boolean |
bigint | Number |
double precision | Number |
numeric | Number |
text | String |
timestamp | Time |
timestamptz | Time |
jsonb | Json |
The HubSpot API uses JSON formatted data, please refer to HubSpot API docs for more details.
Limitations
This section describes important limitations and considerations when using this FDW:
- Large result sets may experience slower performance due to full data transfer requirement
- Query pushdown support limited to 'id' columns only
- Materialized views using these foreign tables may fail during logical backups
Examples
Below are some examples on how to use HubSpot foreign tables.
Basic example
This example will create a "foreign table" inside your Postgres database and query its data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
attrs
is a special column which stores all the object attributes in JSON format, you can extract any attributes needed from it. See more examples below.
Query JSON attributes
1 2 3 4 |
|
Query custom properties
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Note that the column user_id
is the custom property internal name, not its display name. It can be found in the Details
section of Edit property
page on HubSpot Settings
-> Data Management
-> Properties
.
Query custom objects
Suppose we have a HubSpot custom object Projects
and its object type id is 2-3508482
. It also has a custom property name
, we can define the foreign table and query it as below:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Note that custom object type id 2-3508482
can be found in page URL on HubSpot Settings
-> Data Management
-> Custom Objects
. For example,
1 |
|