Methods

  • Fetches all list entries in the list with the supplied list id.

    Please note: the returned response has a different shape than when using a paginated request (see below)

    Parameters

    Returns Promise<ListEntryResponse[]>

    An array of all list entries in the list with the supplied list id.

    const entries = await affinity.lists.entries.all({ list_id: 123 })
    console.log(`The first of ${entries.length} entries is for`, entries?.[0].entity)
  • Fetches up to the number specified in PagingParameters.page_size of list entries in the list with the supplied list id.

    Please note: the returned response has a different shape than when using a non-paginated request (see above).

    Parameters

    Returns Promise<PagedListEntryResponse>

    A chunk of list entries with the maximum size specified in the query.

    const { list_entries, next_page_token } = await affinity.lists.entries.all({
    list_id: 123,
    page_size: 10
    })
    console.log(`The first of ${list_entries.length} entries in this page is for`, list_entries?.[0].entity)
    console.log(next_page_token
    ? `The next page token is '${next_page_token}'`
    : 'No more pages to fetch'
    )
  • Creates a new list entry in the list with the supplied list_id.

    Notes:

    • Opportunities cannot be created using this endpoint. Instead use the POST /opportunities endpoint.
    • Person and company lists can contain the same entity multiple times. Depending on your use case, before you add an entry, you may want to verify whether or not it exists in the list already.

    Parameters

    Returns Promise<ListEntryResponse>

    The created list entry object.

    const newListEntry = await affinity.lists.entries.create({
    list_id: 450,
    entity_id: 38706
    })
    console.log(newListEntry)
  • Deletes a specific list entry.

    Parameters

    Returns Promise<boolean>

    boolean indicating whether the list entry was successfully deleted.

    const success = await affinity.lists.entries.delete({
    list_id: 450,
    list_entry_id: 16367
    })
    console.log(success ? 'List entry deleted': 'List entry not deleted')
  • Returns an async iterator that yields all list entries in the list with the supplied list id. Each yielded array contains up to the number specified in PagingParameters.page_size of list entries. Use this method if you want to process the list entries in a streaming fashion.

    Please note: the yielded list entries array may be empty on the last page.

    Parameters

    Returns AsyncGenerator<ListEntryResponse[], any, any>

    let page = 0
    for await (const entries of affinity.lists.entries.pagedIterator({
    list_id: 123,
    page_size: 10
    })) {
    console.log(`Page ${++page} of entries:`, entries)
    }