claude-api


Nameclaude-api JSON
Version 1.0.17 PyPI version JSON
download
home_pagehttps://github.com/KoushikNavuluri/Claude-API/
SummaryAn unofficial API for Claude AI, allowing users to access and interact with Claude AII
upload_time2023-08-17 15:24:08
maintainer
docs_urlNone
authorKoushik
requires_python>=3.7
licenseMIT
keywords claude ai claude-ai api requests chatbot
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Claude AI-API ( Unofficial )
This project provides an unofficial API for Claude AI, allowing users to access and interact with Claude AI .

<img src="https://github.com/KoushikNavuluri/Claude-API/assets/103725723/385fa539-e725-4c20-86ff-0864e6ffab82" width="400">



#### Current Version == 1.0.17 ( Added Timeouts,Faster Requests,File handling Fixed.. )

## Table of contents

  * [Use Cases](#use-cases)
  * [Prerequisites](#prerequisites)
  * [Installation](#installation)
  * [Usage](#usage)
  * [List All Conversations](#list-all-conversations)
  * [Send Message](#send-message)
  * [Send Message with attachment](#send-message-with-attachment)
  * [Delete Conversation](#delete-conversation)
  * [Chat Conversation History](#chat-conversation-history)
  * [Create New Chat](#create-new-chat)
  * [Reset All Conversations](#reset-all-conversations)
  * [Rename Chat](#rename-chat)
  * [Disclaimer](#disclaimer)


## Use Cases 

    1. Python Console ChatBot ( Check in usecases folder for sample console chatbot )

    2. Discord Chatbot   
    
    3. Many more can be done....
    

## Prerequisites

To use this API, you need to have the following:

Python installed on your system
requests library installed 
```bash
  pip install requests

```

## Installation

To use the Claude AI Unofficial API, you can either clone the GitHub repository or directly download the Python file.

Terminal :

    pip install claude-api
    
or

Clone the repository:

    git clone https://github.com/KoushikNavuluri/Claude-API.git

## Usage


Import the claude_api module in your Python script:

    from claude_api import Client

* Next, you need to create an instance of the Client class by providing your Claude AI cookie:

* You can get cookie from the browser's developer tools network tab ( see for any claude.ai requests check out cookie ,copy whole value ) or storage tab ( You can find cookie of claude.ai ,there will be four values )

* (Checkout below image for the format of cookie ,It is Better to Use from network tab to grab cookie easily )

   ![Screenshot (8)](https://github.com/KoushikNavuluri/Claude-API/assets/103725723/355971e3-f46c-47fc-a3cf-008bb55bb4c6)


      cookie = os.environ.get('cookie')
      claude_api = Client(cookie)

## List All Conversations

To list all the conversation Id's you had with Claude , you can use the list_all_conversations method:

    conversations = claude_api.list_all_conversations()
    for conversation in conversations:
        conversation_id = conversation['uuid']
        print(conversation_id)

## Send Message

To send a message to Claude, you can use the send_message method. You need to provide the prompt and the conversation ID:



    prompt = "Hello, Claude!"
    conversation_id = "<conversation_id>" or claude_api.create_new_chat()['uuid']
    response = claude_api.send_message(prompt, conversation_id)
    print(response)

## Send Message with attachment

You can send any type of attachment to claude to get responses using attachment argument in send_message().
Note: Claude currently supports only some file types.

{ You can also add timeout if you need ,using timeout parameter[default set to 500] }

    prompt = "Hey,Summarize me this document.!"
    conversation_id = "<conversation_id>" or claude_api.create_new_chat()['uuid']
    response = claude_api.send_message(prompt, conversation_id,attachment="path/to/file.pdf",timeout=600)
    print(response)


## Delete Conversation

To delete a conversation, you can use the delete_conversation method:


    conversation_id = "<conversation_id>"
    deleted = claude_api.delete_conversation(conversation_id)
    if deleted:
        print("Conversation deleted successfully")
    else:
        print("Failed to delete conversation")

## Chat Conversation History

To get the chat conversation history, you can use the chat_conversation_history method:    

    conversation_id = "<conversation_id>"
    history = claude_api.chat_conversation_history(conversation_id)
    print(history)

## Create New Chat

To create a new chat conversation (id), you can use the create_new_chat method:


    new_chat = claude_api.create_new_chat()
    conversation_id = new_chat['uuid']
    print(conversation_id)

## Reset All Conversations

To reset all conversations, you can use the reset_all method:


    reset = claude_api.reset_all()
    if reset:
        print("All conversations reset successfully")
    else:
        print("Failed to reset conversations")   

## Rename Chat

To rename a chat conversation, you can use the rename_chat method:

    conversation_id = "<conversation_id>"
    title = "New Chat Title"
    renamed = claude_api.rename_chat(title, conversation_id)
    if renamed:
        print("Chat conversation renamed successfully")
    else:
        print("Failed to rename chat conversation")

## Disclaimer

This project provides an unofficial API for Claude AI and is not affiliated with or endorsed by Claude AI or Anthropic. Use it at your own risk.

Please refer to the official Claude AI documentation[https://claude.ai/docs] for more information on how to use Claude AI.
        
    




    

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/KoushikNavuluri/Claude-API/",
    "name": "claude-api",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "claude,ai,claude-ai,API,requests,chatbot",
    "author": "Koushik",
    "author_email": "koushikk@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/42/f6/4a4970d54d1288da5052df8b9d75c65a94650ab380efda6289726d04f129/claude-api-1.0.17.tar.gz",
    "platform": null,
    "description": "# Claude AI-API ( Unofficial )\r\nThis project provides an unofficial API for Claude AI, allowing users to access and interact with Claude AI .\r\n\r\n<img src=\"https://github.com/KoushikNavuluri/Claude-API/assets/103725723/385fa539-e725-4c20-86ff-0864e6ffab82\" width=\"400\">\r\n\r\n\r\n\r\n#### Current Version == 1.0.17 ( Added Timeouts,Faster Requests,File handling Fixed.. )\r\n\r\n## Table of contents\r\n\r\n  * [Use Cases](#use-cases)\r\n  * [Prerequisites](#prerequisites)\r\n  * [Installation](#installation)\r\n  * [Usage](#usage)\r\n  * [List All Conversations](#list-all-conversations)\r\n  * [Send Message](#send-message)\r\n  * [Send Message with attachment](#send-message-with-attachment)\r\n  * [Delete Conversation](#delete-conversation)\r\n  * [Chat Conversation History](#chat-conversation-history)\r\n  * [Create New Chat](#create-new-chat)\r\n  * [Reset All Conversations](#reset-all-conversations)\r\n  * [Rename Chat](#rename-chat)\r\n  * [Disclaimer](#disclaimer)\r\n\r\n\r\n## Use Cases \r\n\r\n    1. Python Console ChatBot ( Check in usecases folder for sample console chatbot )\r\n\r\n    2. Discord Chatbot   \r\n    \r\n    3. Many more can be done....\r\n    \r\n\r\n## Prerequisites\r\n\r\nTo use this API, you need to have the following:\r\n\r\nPython installed on your system\r\nrequests library installed \r\n```bash\r\n  pip install requests\r\n\r\n```\r\n\r\n## Installation\r\n\r\nTo use the Claude AI Unofficial API, you can either clone the GitHub repository or directly download the Python file.\r\n\r\nTerminal :\r\n\r\n    pip install claude-api\r\n    \r\nor\r\n\r\nClone the repository:\r\n\r\n    git clone https://github.com/KoushikNavuluri/Claude-API.git\r\n\r\n## Usage\r\n\r\n\r\nImport the claude_api module in your Python script:\r\n\r\n    from claude_api import Client\r\n\r\n* Next, you need to create an instance of the Client class by providing your Claude AI cookie:\r\n\r\n* You can get cookie from the browser's developer tools network tab ( see for any claude.ai requests check out cookie ,copy whole value ) or storage tab ( You can find cookie of claude.ai ,there will be four values )\r\n\r\n* (Checkout below image for the format of cookie ,It is Better to Use from network tab to grab cookie easily )\r\n\r\n   ![Screenshot (8)](https://github.com/KoushikNavuluri/Claude-API/assets/103725723/355971e3-f46c-47fc-a3cf-008bb55bb4c6)\r\n\r\n\r\n      cookie = os.environ.get('cookie')\r\n      claude_api = Client(cookie)\r\n\r\n## List All Conversations\r\n\r\nTo list all the conversation Id's you had with Claude , you can use the list_all_conversations method:\r\n\r\n    conversations = claude_api.list_all_conversations()\r\n    for conversation in conversations:\r\n        conversation_id = conversation['uuid']\r\n        print(conversation_id)\r\n\r\n## Send Message\r\n\r\nTo send a message to Claude, you can use the send_message method. You need to provide the prompt and the conversation ID:\r\n\r\n\r\n\r\n    prompt = \"Hello, Claude!\"\r\n    conversation_id = \"<conversation_id>\" or claude_api.create_new_chat()['uuid']\r\n    response = claude_api.send_message(prompt, conversation_id)\r\n    print(response)\r\n\r\n## Send Message with attachment\r\n\r\nYou can send any type of attachment to claude to get responses using attachment argument in send_message().\r\nNote: Claude currently supports only some file types.\r\n\r\n{ You can also add timeout if you need ,using timeout parameter[default set to 500] }\r\n\r\n    prompt = \"Hey,Summarize me this document.!\"\r\n    conversation_id = \"<conversation_id>\" or claude_api.create_new_chat()['uuid']\r\n    response = claude_api.send_message(prompt, conversation_id,attachment=\"path/to/file.pdf\",timeout=600)\r\n    print(response)\r\n\r\n\r\n## Delete Conversation\r\n\r\nTo delete a conversation, you can use the delete_conversation method:\r\n\r\n\r\n    conversation_id = \"<conversation_id>\"\r\n    deleted = claude_api.delete_conversation(conversation_id)\r\n    if deleted:\r\n        print(\"Conversation deleted successfully\")\r\n    else:\r\n        print(\"Failed to delete conversation\")\r\n\r\n## Chat Conversation History\r\n\r\nTo get the chat conversation history, you can use the chat_conversation_history method:    \r\n\r\n    conversation_id = \"<conversation_id>\"\r\n    history = claude_api.chat_conversation_history(conversation_id)\r\n    print(history)\r\n\r\n## Create New Chat\r\n\r\nTo create a new chat conversation (id), you can use the create_new_chat method:\r\n\r\n\r\n    new_chat = claude_api.create_new_chat()\r\n    conversation_id = new_chat['uuid']\r\n    print(conversation_id)\r\n\r\n## Reset All Conversations\r\n\r\nTo reset all conversations, you can use the reset_all method:\r\n\r\n\r\n    reset = claude_api.reset_all()\r\n    if reset:\r\n        print(\"All conversations reset successfully\")\r\n    else:\r\n        print(\"Failed to reset conversations\")   \r\n\r\n## Rename Chat\r\n\r\nTo rename a chat conversation, you can use the rename_chat method:\r\n\r\n    conversation_id = \"<conversation_id>\"\r\n    title = \"New Chat Title\"\r\n    renamed = claude_api.rename_chat(title, conversation_id)\r\n    if renamed:\r\n        print(\"Chat conversation renamed successfully\")\r\n    else:\r\n        print(\"Failed to rename chat conversation\")\r\n\r\n## Disclaimer\r\n\r\nThis project provides an unofficial API for Claude AI and is not affiliated with or endorsed by Claude AI or Anthropic. Use it at your own risk.\r\n\r\nPlease refer to the official Claude AI documentation[https://claude.ai/docs] for more information on how to use Claude AI.\r\n        \r\n    \r\n\r\n\r\n\r\n\r\n    \r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An unofficial API for Claude AI, allowing users to access and interact with Claude AII",
    "version": "1.0.17",
    "project_urls": {
        "Homepage": "https://github.com/KoushikNavuluri/Claude-API/"
    },
    "split_keywords": [
        "claude",
        "ai",
        "claude-ai",
        "api",
        "requests",
        "chatbot"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f0323156dba75e1f50f6dea64e32a9097f0f0cff5f58b53462d4a142c51564b",
                "md5": "679f997dd983a9abd41dd6b86feb7424",
                "sha256": "5d0d12d17608c3d966277bd3385824d1ffa992bede6be76f65623b909d50c5b2"
            },
            "downloads": -1,
            "filename": "claude_api-1.0.17-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "679f997dd983a9abd41dd6b86feb7424",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6227,
            "upload_time": "2023-08-17T15:24:06",
            "upload_time_iso_8601": "2023-08-17T15:24:06.907686Z",
            "url": "https://files.pythonhosted.org/packages/3f/03/23156dba75e1f50f6dea64e32a9097f0f0cff5f58b53462d4a142c51564b/claude_api-1.0.17-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "42f64a4970d54d1288da5052df8b9d75c65a94650ab380efda6289726d04f129",
                "md5": "2dc5d6119e1c141a59b1f90337db9e69",
                "sha256": "489c0c49eac93c3d91854ec1cbf6070087dc63d891b3acd83e87f47ea2fe24c2"
            },
            "downloads": -1,
            "filename": "claude-api-1.0.17.tar.gz",
            "has_sig": false,
            "md5_digest": "2dc5d6119e1c141a59b1f90337db9e69",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6095,
            "upload_time": "2023-08-17T15:24:08",
            "upload_time_iso_8601": "2023-08-17T15:24:08.229458Z",
            "url": "https://files.pythonhosted.org/packages/42/f6/4a4970d54d1288da5052df8b9d75c65a94650ab380efda6289726d04f129/claude-api-1.0.17.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-17 15:24:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "KoushikNavuluri",
    "github_project": "Claude-API",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "claude-api"
}
        
Elapsed time: 0.11309s