Access hubspot like an ORM. Full Typescript Support.
Inspired by Prisma.io's API
Explore the docs »
·
Report Bug
·
Request Feature
·
Ask a Question
·
Say Hello 👋
Table of Contents
Goals of this library:
-
fully type safe access to hubspot REST API to access all types in hubspot like contacts, deals, and especially including custom types
-
code first approach to maintaining the types and property in hubspot. just like any standard ORM like prisma, you define all the types in code and then run a migration to update hubspot.
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
Get a hubspot access token. Instructions here https://developers.hubspot.com/docs/api/private-apps.
Node
NPM:
$ npm install hubmodelYARN:
$ yarn add hubmodelPNPM:
$ pnpm add hubmodelDENO
import {...} from "https://deno.land/x/hubmodel/mod.ts"For more examples, please refer to the Documentation
### fetching
// retreive all contacts and all their properties
await client.contacts.findMany({});
// retrieve all contacts but only include the 3 properties
await client.contacts.findMany({
select: {
address: true,
hs_createdate: true,
email: true,
firstname: true,
},
});Why create your own client instead of fixing the types of the existing hubspot client?
Fixing existing hubspot client types was originally the approach but i had some issues with its API design, so felt i could kill 2 birds with 1 stone by diverging from the original client.
What should i do if this hubspot client is missing a hubspot endpoint?
Depends. Hubspot client has a lot of endpoints to cover, so instead of trying to replace all functionality, this library focuses on making the majority of the workflows intuitive with typescript and leaving the remaining workflows to the original hubspot client. If you need to use an endpoint that this library doesn't have, in the short term, I'd recommend using the hubspot client. In the long term, this library might want to support the endpoints so file a github ticket/discussion etc and we can discuss :)
- Cli to generate bespoke hubspot model for the hubspot account
- Query hubspot collections
- specify fields to read on the collection using a
select - filter which objects to retrieve from hubspot using a
where - Select nested associated objects
- collection pipelines
- retrieve a properties historical values
- retrieve a collections activity
- Create hubspot objects
- Create associations between hubspot objects
- Update an object's fields
- Update an object's associations
- ORM - ORM like functionality, defining your hubspot schema in code and then syncing it to hubspot directly just like you would for a database. Inspired by https://www.prisma.io/
See the open issues for a full list of known issues.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt for more information.
Joseph Siddall - j.b.siddall@gmail.com
Github Link: https://github.com/jbsiddall/hubmodel Docs Link: https://hubmodel.dev/