Skip to main content

Crisp API Python.

Project description

python-crisp-api

The Crisp API Python wrapper. Authenticate, send messages, fetch conversations, access your agent accounts from your Python code.

Copyright 2018 Crisp IM SARL. See LICENSE for copying information.

Usage

Install the library:

pip install crisp-api

Then, import it:

from crisp_api import Crisp

Construct a new authenticated Crisp client with your identifier and key tokens.

client = Crisp()

client.authenticate(identifier, key)

Then, your client is ready to be consumed!

Authentication

To authenticate against the API, generate your session identifier and session key once using the Crisp token generation utility. You'll get a token keypair made of 2 values.

Keep your token keypair values private, and store them safely for long-term use.

Then, add authentication parameters to your client instance right after you create it:

client = Crisp()

# Make sure to use the correct tier if you are authenticating a plugin
# eg. with a permanent token generated from Crisp Marketplace
client.set_tier("plugin")

# Authenticate to API (identifier, key)
# eg. client.authenticate("13937834-f6ce-4556-ae4f-9e0c54faf038", "eb6c3623245521d7a6c35f5b29f3fa756e893f034ed551d84518961c5ff16dec")
client.authenticate(identifier, key)

# Now, you can use authenticated API sections.

🔴 Important: Make sure to generate your token once, and use the same token keys in all your subsequent requests to the API. Do not generate too many tokens, as we may invalidate your older tokens to make room for newer tokens.

Resource Methods

Most useful available Crisp API resources are implemented. Programmatic methods names are named after their label name in the API Reference.

Thus, it is straightforward to look for them in the library while reading the API Reference.

In the following method prototypes, crisp is to be replaced with your Crisp API instance. For example, instanciate client = Crisp() and then call eg: client.website.list_conversations(website_id, 1).

When calling a method that writes data to the API (eg. send a message with: client.website.send_message_in_conversation()), you need to submit it this way:

website_id = "88972681-a00c-4b3b-a383-cab281636484"
session_id = "session_9df2a21e-f113-41d4-8ed2-bad8b49cafd1"

client.website.send_message_in_conversation(
  website_id, session_id,

  {
    "type": "text",
    "content": "This message was sent from python-crisp-api! :)",
    "from": "operator",
    "origin": "chat"
  }
)

Website

  • Website Conversations

    • List Conversations: client.website.list_conversations(website_id, page_number)
    • Search Conversations: client.website.search_conversations(website_id, page_number, search_query, search_type, search_operator, include_empty, filter_unread, filter_resolved, filter_not_resolved, filter_mention, filter_assigned, filter_unassigned, filter_date_start, filter_date_end, order_date_created", order_date_updated)
  • Website Conversation

    • Create A New Conversation: client.website.create_new_conversation(website_id)
    • Check If Conversation Exists: client.website.check_conversation_exists(website_id, session_id)
    • Get A Conversation: client.website.get_conversation(website_id, session_id)
    • Remove A Conversation: client.website.remove_conversation(website_id, session_id)
    • Initiate A Conversation With Existing Session: client.website.initiate_conversation_with_existing_session(website_id, session_id)
    • Get Messages In Conversation: client.website.get_messages_in_conversation(website_id, session_id, query)
    • Send A Message In Conversation: client.website.send_message_in_conversation(website_id, session_id, query)
    • Update A Message In Conversation: client.website.update_message_in_conversation(website_id, session_id, fingerprint, data)
    • Compose A Message In Conversation: client.website.compose_message_in_conversation(website_id, session_id, data)
    • Mark Messages As Read In Conversation: client.website.mark_messages_read_in_conversation(website_id, session_id, data)
    • Mark Messages As Delivered In Conversation: client.website.mark_messages_delivered_in_conversation(website_id, session_id, data)
    • Get Conversation Routing Assign: client.website.get_conversation_routing_assign(website_id, session_id)
    • Assign Conversation Routing: client.website.assign_conversation_routing(website_id, session_id, data)
    • Get Conversation Metas: client.website.get_conversation_metas(website_id, session_id)
    • Update Conversation Metas: client.website.update_conversation_metas(website_id, session_id, data)
    • List Conversation Pages: client.website.list_conversation_pages(website_id, session_id, page_number)
    • List Conversation Events: client.website.list_conversation_events(website_id, session_id, page_number)
    • Get Conversation State: client.website.get_conversation_state(website_id, session_id)
    • Change Conversation State: client.website.change_conversation_state(website_id, session_id, data)
    • Get Block Status For Conversation: client.website.get_block_status_for_conversation(website_id, session_id)
    • Block Incoming Messages For Conversation: client.website.block_incoming_messages_for_conversation(website_id, session_id, data)
    • Request Email Transcript For Conversation: client.website.request_email_transcript_for_conversation(website_id, session_id, data)
  • Website People

    • Get People Statistics: client.website.get_people_statistics(website_id)
    • List People Segments: client.website.list_people_segments(website_id, page_number)
    • List People Profiles: client.website.list_people_profiles(website_id, page_number)
    • Add New People Profile: client.website.add_new_people_profile(website_id, data)
    • Check If People Profile Exists: client.website.check_people_profile_exists(website_id, people_id)
    • Get People Profile: client.website.get_people_profile(website_id, people_id)
    • Save People Profile: client.website.save_people_profile(website_id, people_id, data)
    • Update People Profile: client.website.update_people_profile(website_id, people_id, data)
    • Remove People Profile: client.website.remove_people_profile(website_id, people_id)
    • List People Conversations: client.website.list_people_conversations(website_id, people_id, page_number)
    • Add A People Event: client.website.add_people_event(website_id, people_id, data)
    • List People Events: client.website.list_people_events(website_id, people_id, page_number)
    • Get People Data: client.website.get_people_data(website_id, people_id)
    • Save People Data: client.website.save_people_data(website_id, people_id, data)
    • Get People Subscription Status: client.website.get_people_subscription_status(website_id, people_id)
    • Update People Subscription Status: client.website.update_people_subscription_status(website_id, people_id, data)
  • Website Base

    • Create Website: client.website.create_website(data)
    • Get A Website: client.website.get_website(website_id)
    • Delete A Website: client.website.delete_website(website_id)
  • Website Batch

    • Batch Resolve Items: client.website.batch_resolve_items(website_id, data)
    • Batch Read Items: client.website.batch_read_items(website_id, data)
    • Batch Remove Items: client.website.batch_remove_items(website_id, data)
  • Website Availability

    • Get Website Availability Status: client.website.get_website_availability_status(website_id)
  • Website Operator

    • List Website Operators: client.website.list_website_operators(website_id)
    • List Last Active Website Operators: client.website.list_last_active_website_operators(website_id)
  • Website Settings

    • Get Website Settings: client.website.get_website_settings(website_id)
    • Update Website Settings: client.website.update_website_settings(website_id, data)
  • Website Visitors

    • Count Visitors: client.website.count_visitors(website_id)
    • List Visitors: client.website.list_visitors(website_id, page_number)

Plugin

  • Plugin Connect

    • Get Plugin Connect Account: client.get_connect_account()
    • Check Plugin Connect Session Validity: client.check_connect_session_validity()
    • List All Connected Websites: client.list_all_connect_websites(page_number, filter_configured)
  • Plugin Subscription

    • List All Active Subscriptions: client.list_all_active_subscriptions()
    • List Subscriptions For Website: client.list_subscriptions_website(website_id)
    • Get Subscription Details: client.get_subscription_details(website_id, plugin_id)
    • Subscribe Website To Plugin: client.subscribe_plugin_to_website(website_id)
    • Unsubscribe Plugin From Website: client.unsubscribe_plugin_from_website(website_id, plugin_id)
    • Get Subscription Settings: client.get_subscription_settings(website_id, plugin_id)
    • Save Subscription Settings: client.save_subscription_settings(website_id, plugin_id, settings)
    • Update Subscription Settings: client.update_subscription_settings(website_id, plugin_id, settings)
    • Forward Plugin Payload To Channel: client.forward_plugin_payload_to_channel(website_id, plugin_id, data)
    • Dispatch Plugin Event: client.dispatch_plugin_event(website_id, plugin_id, data)

Bucket

  • Bucket URL
    • Generate Bucket URL: client.bucket.generate_bucket_url(data)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crisp-api-1.1.10.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

crisp_api-1.1.10-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file crisp-api-1.1.10.tar.gz.

File metadata

  • Download URL: crisp-api-1.1.10.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.4

File hashes

Hashes for crisp-api-1.1.10.tar.gz
Algorithm Hash digest
SHA256 f8a1c5b6cfe5f5936ed0eb5648050c0b1e6199a7dcb4366b305d8aaf7760ee9d
MD5 ce4174a0fd43fcafe1e149df786e6197
BLAKE2b-256 7b95896975bfa84c0536db0877b4ddb7a1ee34ce876cf8d98bc428457bd53402

See more details on using hashes here.

Provenance

File details

Details for the file crisp_api-1.1.10-py3-none-any.whl.

File metadata

  • Download URL: crisp_api-1.1.10-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.4

File hashes

Hashes for crisp_api-1.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 678b4764a185251ed32dbcd33719d10c3d66870478635676e0cf887a4f18388d
MD5 461efdb90826d3be70d0beec2133e2e7
BLAKE2b-256 dc4c7752aab6f5dc3d81909e552a8ed02b8341f96d6074981e5210d91ee079ee

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page