Hightouch exposes a REST API that lets users interact with resources like syncs, models, sources and destinations.
pip install git+https://github.com/speakeasy-sdks/hightouch-python-sdk.git
- Create an API key
- From the API keys tab on the Settings page, select Add API key.
- Enter a descriptive Name for your key.
- Copy your API key and store it in a safe location. The key will only be displayed once.
- Click Create API key.
import hightouch
from hightouch.models import shared
s = hightouch.Hightouch(
security=shared.Security(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
),
)
req = shared.DestinationCreate(
configuration={
'key': '<value>',
},
name='<value>',
slug='<value>',
type='<value>',
)
res = s.create_destination(req)
if res.one_of is not None:
# handle response
pass
- create_destination - Create Destination
- create_model - Create Model
- create_source - Create Source
- create_sync - Create Sync
- get_destination - Get Destination
- get_model - Get Model
- get_source - Get Source
- get_sync - Get Sync
- get_sync_sequence_run - Sync sequence status
- list_destination - List Destinations
- list_model - List Models
- list_source - List Sources
- list_sync - List Syncs
- list_sync_runs - List Sync Runs
- trigger_run - Trigger Sync
- trigger_run_custom - Trigger Sync From ID or Slug
- trigger_run_id_graph
- trigger_sequence_run - Trigger Sync sequence
- update_destination - Update Destination
- update_model - Update Model
- update_source - Update Source
- update_sync - Update Sync
Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type.
Error Object | Status Code | Content Type |
---|---|---|
errors.ValidateErrorJSON | 409,422 | application/json |
errors.SDKError | 4xx-5xx | / |
import hightouch
from hightouch.models import errors, shared
s = hightouch.Hightouch(
security=shared.Security(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
),
)
req = shared.DestinationCreate(
configuration={
'key': '<value>',
},
name='<value>',
slug='<value>',
type='<value>',
)
res = None
try:
res = s.create_destination(req)
except errors.ValidateErrorJSON as e:
# handle exception
raise(e)
except errors.SDKError as e:
# handle exception
raise(e)
if res.one_of is not None:
# handle response
pass
You can override the default server globally by passing a server index to the server_idx: int
optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
# | Server | Variables |
---|---|---|
0 | https://api.hightouch.com/api/v1 |
None |
import hightouch
from hightouch.models import shared
s = hightouch.Hightouch(
server_idx=0,
security=shared.Security(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
),
)
req = shared.DestinationCreate(
configuration={
'key': '<value>',
},
name='<value>',
slug='<value>',
type='<value>',
)
res = s.create_destination(req)
if res.one_of is not None:
# handle response
pass
The default server can also be overridden globally by passing a URL to the server_url: str
optional parameter when initializing the SDK client instance. For example:
import hightouch
from hightouch.models import shared
s = hightouch.Hightouch(
server_url="https://api.hightouch.com/api/v1",
security=shared.Security(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
),
)
req = shared.DestinationCreate(
configuration={
'key': '<value>',
},
name='<value>',
slug='<value>',
type='<value>',
)
res = s.create_destination(req)
if res.one_of is not None:
# handle response
pass
The Python SDK makes API calls using the requests HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom requests.Session
object.
For example, you could specify a header for every request that this sdk makes as follows:
import hightouch
import requests
http_client = requests.Session()
http_client.headers.update({'x-custom-header': 'someValue'})
s = hightouch.Hightouch(client=http_client)
This SDK supports the following security scheme globally:
Name | Type | Scheme |
---|---|---|
bearer_auth |
http | HTTP Bearer |
You can set the security parameters through the security
optional parameter when initializing the SDK client instance. For example:
import hightouch
from hightouch.models import shared
s = hightouch.Hightouch(
security=shared.Security(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
),
)
req = shared.DestinationCreate(
configuration={
'key': '<value>',
},
name='<value>',
slug='<value>',
type='<value>',
)
res = s.create_destination(req)
if res.one_of is not None:
# handle response
pass