C# .NET Wrapper around the common HubSpot APIs:
HubSpot.NET supports authorization by API key or through HubSpot's OAuth workflow. [As is noted in HubSpot's API documentation](), it is recommended to use the OAuth form if your integration is going to be used commercially due to an increased level of security. However, we have made it optional to target OAuth or API key authentication so you can develop against the authentication provider that best suits your needs.
To get started, install the Nuget package and create a instance of HubSpotApi
passing your API Key as the only parameter; or if using OAuth pass in the Client ID, Client Secret, and App ID.
var api = new HubSpotApi("MY API KEY");
// Create a contact
var contact = api.Contact.Create(new ContactHubSpotModel()
{
Email = "john@squaredup.com",
FirstName = "John",
LastName = "Smith",
Phone = "00000 000000",
Company = "Squared Up Ltd."
});
var api = new HubSpotApi("clientID", "clientSecret", "HubSpotAppID");
// Create a contact
var contact = api.Contact.Create(new ContactHubSpotModel()
{
Email = "john@squaredup.com",
FirstName = "John",
LastName = "Smith",
Phone = "00000 000000",
Company = "Squared Up Ltd."
});
For more examples see the HubSpot.NET.Examples project.
As HubSpot lets you create and add custom properties to your contacts, companies and deals it's likely you'll want to implement your own models. This is straightforward, simply extend the models shipped with this library, e.g. ContactHubSpotModel
and add your own properties. Use the DataMember
attributes to indicate the internal name. For example
public class Contact : ContactHubSpotModel
{
[DataMember(Name = "activities")]
public string Activities { get; set; }
[DataMember(Name = "type")]
public string Type { get; set; }
}
These properties should be of type string
and set as a semicolon delimitered list of values, e.g. "value1;value2". This is required by HubSpot, see here for more details.
Please read CONTRIBUTING.md for more information on how to contribute. PRs welcome!
This project is licensed under the MIT License - see the LICENSE file for details