API

knackpy.api #

get #

def get(*,
        app_id: str,
        api_key: str = None,
        slug: str = None,
        obj: str = None,
        scene: str = None,
        view: str = None,
        record_limit: int = None,
        filters: dict = None,
        max_attempts: int = 5,
        timeout: int = 30) -> [list, requests.Response]

Get records from a knack object or view. This is the raw stuff with incorrect timestamps!

Arguments:

  • app_id str - [description]
  • api_key str, optional - [description]. Defaults to None.
  • slug str, optional - Your organization’s slug (aka, subdomain). As found in your app metadata under accounts.slug.
  • obj str, optional - [description]. Defaults to None.
  • scene str, optional - [description]. Defaults to None.
  • view str, optional - [description]. Defaults to None.
  • max_attempts int, optional - [description]. Defaults to 5.
  • record_limit int, optional - [description]. Defaults to None (which is handled as infinity).
  • timeout int, optional - [description]. Defaults to 30.
  • filters [list, dict], optional - Knack record filter dict or list. Defaults to None.

Returns:

  • list - Knack records.

get_metadata #

def get_metadata(*,
                 app_id: str,
                 slug: str = None,
                 timeout: int = 30,
                 max_attempts: int = 5) -> dict

Fetch Knack application metadata. You can find your app’s metadata at: https://api.knack.com/v1/applications/<app_id:str>.

Arguments:

  • app_id str - A Knack application ID.
  • slug str, optional - Your organization’s slug (aka, subdomain). As found in your app metadata under accounts/slug.

Returns:

  • dict - A dictionary of Knack application metadata.

record #

def record(*,
           app_id: str,
           api_key: str,
           data: dict,
           method: str,
           obj: str,
           slug: str = None,
           max_attempts: int = 5,
           timeout: int = 30)

Create, update, or delete a Knack record.

Arguments:

  • app_id str - Knack application ID # noqa:E501 string.
  • api_key str - Knack API key.
  • slug str, optional - Your organization’s slug (aka, subdomain). As found in your app metadata under accounts/slug.
  • data dict - The Knack record data payload.
  • method str - Choose from create, update, or delete.
  • obj str, optional - The Knack object key which holds the record data.
  • max_attempts int - The maximum number of attempts to make if a request times out. Default values that are set in knackpy.api.request. Defaults to 5.
  • timeout int, optional - Number of seconds to wait before a Knack API request times out. Further reading: Requests docs.

Returns:

  • dict - The updated or newly created Knack record data, or, if deleting a
  • record - {"delete": true}

upload #

def upload(*,
           app_id: str,
           api_key: str,
           obj: str,
           field: str,
           path: str,
           asset_type: str,
           record_id: str = None,
           slug: str = None,
           max_attempts: int = 5,
           timeout: int = 30)

Upload a file or image to Knack. This is a two-step process:

  1. Upload file asset to Knack storage
  2. Create/update a record that links to the file in storage

Knack docs: https://www.knack.com/developer-documentation/`file`-image-uploads

Arguments:

  • app_id str - Knack application ID # noqa:E501 string.
  • api_key str - Knack API key. # noqa:E501
  • obj str - The Knack object key which holds the record data.
  • field str - The knack field key of the field you’re uploading into.
  • path str - The path to the file to be uploaded.
  • asset_type str - The type of Knack field you’re uploading to. Must be file or image.
  • record_id str, optional - The knack record ID to which the upload will be attached. If None, will create a new record. Otherwise will update an existing record.
  • slug str, optional - Your organization’s slug (aka, subdomain). As found in your app metadata under accounts/slug.
  • max_attempts int - The maximum number of attempts to make if a request times out. Default values that are set in knackpy.api.request. Defaults to 5.
  • timeout int, optional - Number of seconds to wait before a Knack API request times out. Further reading: Requests docs.