Skip to main content

Psychic

psychicapi is the python client library for Psychic.

What is Psychic?

Psychic is a platform for integrating with your customer’s SaaS tools like Notion, Zendesk, Confluence, and Google Drive via OAuth and syncing documents from these applications to your SQL or vector database. You can think of it like Plaid for unstructured data. Psychic is easy to set up - you use it by importing the react library and configuring it with your Psychic API key, which you can get from the Psychic dashboard. When your users connect their applications, you can view these connections from the dashboard and retrieve data using the server-side libraries.

Quick start

  1. Create an account in the dashboard.
  2. Use the react library to add the Psychic link modal to your frontend react app. Users will use this to connect their SaaS apps. Or, use the playground to connect your own data sources.
  3. Use psychicapi to retrieve documents from your active connections.

Usage

Initialization

from psychicapi import ConnectorId, Psychic 
psychic = Psychic(secret_key="secret-key")

Get active connections

# Get all active connections and optionally filter by connector id and/or account id
connections = psychic.get_connections(account_id="account_id")

Retrieve documents from a connection

page_cursor = None
all_docs = []
while True:
    docs_response = psychic.get_documents(account_id="account_id", connector_id=ConnectorId.notion, page_cursor=page_cursor, page_size=100)
    if docs_response is None:
        break
    all_docs.extend(docs_response.documents)
    page_cursor = docs_response.next_page_cursor
    if page_cursor is None:
        break
print(all_docs)

Retrieve messages from a connection

To retrieve messages from connectors like slack and gmail, use the get_conversations function.

page_cursor = None
all_messages = []
while True:
    messages_response = psychic.get_conversations(account_id="account_id", connector_id=ConnectorId.gmail, page_cursor=page_cursor)
    if messages_response is None:
        break
    all_messages.extend(messages_response.messages)
    page_cursor = messages_response.next_page_cursor
    if page_cursor is None:
        break
print(all_messages)

Retrieve tickets from a connection

To retrieve messages from connectors like zendesk, use the get_tickets function.

page_cursor = None
all_tickets = []
while True:
    tickets_response = psychic.get_tickets(account_id="account_id", connector_id=ConnectorId.zendesk, redact_pii=True, page_cursor=page_cursor)
    if tickets_response is None:
        break
    all_tickets.extend(tickets_response.tickets)
    page_cursor = tickets_response.next_page_cursor
    if page_cursor is None:
        break
print(all_tickets)

Advanced Filtering

Filtering by section(s)

Most file storage, CRM and helpdesk apps have documents organized in sections. Confluence calls them spaces, Zendesk calls them sections, Google Drive calls them folders. Psychic allows you to define filters based on these sections using the SectionFilter class. You can define and query sections as follows:

from psychicapi import Psychic, ConnectorId, Section, SectionFilter

client = Psychic("YOUR-SECRET-KEY")
connections = client.get_connections(connector_id=ConnectorId.notion, account_id="test")
connection = connections[0]

# get existing section filters
existing_filters = connection.section_filters

# get all available sections from the connection. these will be folders, sections, spaces, etc. depending on the connector
sections = connection.sections

# have the user pick one or more sections
i = 0
filter = SectionFilter(id='index1', sections=[sections[i]])

# add the section filter to the connection
client.add_section_filter(connector_id=ConnectorId.notion, account_id="test", section_filter=filter)

# get documents from the sections in the filter
client.get_documents(account_id="test", connector_id=ConnectorId.notion, section_filter_id="index1")

Filtering by uri

Every document returned by Psychic has a uri. If you want to query a document by uri instead of retrieving all documents in a connection, you can use the optional uris parameter in get_documents

client.get_documents(
    account_id="test", 
    connector_id=ConnectorId.notion, 
    uris=["https://docs.google.com/document/d/document-id-1/edit?usp=drivesdk", "https://drive.google.com/file/d/document-id-2/view?usp=drivesdk"]
)

Local development

To run the python package locally, use the following command:

pip install -e /path/to/package

Metadata

Release files for ragstack 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ragstack 0.0.1
File Size Uploaded Provenance
ragstack-0.0.1.tar.gz 4.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ragstack 0.0.1
File Interpreter ABI Platform
ragstack-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.8 kB

Release files / ragstack-0.0.1.tar.gz

Download URL ragstack-0.0.1.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f08e9295dffa9a8ea1c6ad907977a7d79f57d07945bfa5146651ef734cd3be7a
BLAKE2b-256 checksum
How to use checksums
0688654d6af4fa8fe931bd76c29b42d0a7744b6b92b298df416a4abea2df88c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/1.26.16 tqdm/4.65.0 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/1.5.0 colorama/0.4.6 CPython/3.10.12

Release files / ragstack-0.0.1-py3-none-any.whl

Download URL ragstack-0.0.1-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
609a589b71cffd3eccdb85d2cbff7a5a11ecca4644a2adeedc175eff74dbfd08
BLAKE2b-256 checksum
How to use checksums
c02ad99d373d0327d5599ede705e887e8b4a44ddceb5147fea92782b9f15576d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/1.26.16 tqdm/4.65.0 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/1.5.0 colorama/0.4.6 CPython/3.10.12

Security for ragstack 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page