This unofficial Hubspot API Rust Library provides convenient access to the Hubspot CRM API from applications written in the Rust language.
To install the Hubspot API from crates.io, add the following line to your;
Cargo.toml
toml
[dependencies]
hubspot = "0.1.0"
dotenv = "0.15" # Or preferred
This library utilises Hubspot Private App tokens to authenticate your requests. You can set up a Private App by following the instructions here: https://developers.hubspot.com/docs/api/private-apps
To set up your hubspot client you will need to add the following code.
.env
```
HUBSPOTAPIDOMAIN=api.hubapi.com
HUBSPOTAPIKEY=
```
main.rs ```rust let hubspot = Hubspot::builder() .domain(&env::var("HUBSPOTAPIDOMAIN").expect("HUBSPOTAPIDOMAIN is not set")) .key(&env::var("HUBSPOTAPIKEY").expect("HUBSPOTAPIKEY is not set")) .portalid(&env::var("HUBSPOTPORTALID").expect("HUBSPOTPORTAL_ID is not set")) .build() .expect("Unable to create Hubspot configuration");
```
Below is an example of how to read a deal by ID.
example.rs ```rust use std::io::Result; use hubspot::{ Deal, DealAssociationsResults as AssociationsResults, Hubspot };
// This is where you specify the deal properties that will be returned by hubspot
pub struct DealProperties { pub pipeline: String, pub deal_regions: String, pub industry: String, }
// This is where you specify which objects associations you want returned by hubspot
pub struct DealAssociations { pub companies: AssociationsResults, pub contacts: AssociationsResults, }
async fn getdealexamples(hubspot: Hubspot, dealid: &str) {
let deal = hubspot
.objects
.deals
.read::
Please open an issue on github, and we will prioritize accordingly.