Skip to content

speakeasy-sdks/hightouch-python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python SDK

Hightouch exposes a REST API that lets users interact with resources like syncs, models, sources and destinations.

SDK Installation

pip install git+https://github.com/speakeasy-sdks/hightouch-python-sdk.git

Authentication

  • 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.

SDK Example Usage

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

Available Resources and Operations

Error Handling

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 /

Example

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

Server Selection

Select Server by Index

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

Example

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

Override Server URL Per-Client

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

Custom HTTP Client

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)

Authentication

Per-Client Security Schemes

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

SDK Generated by Speakeasy