Skip to main content

An unofficial API for Claude AI, allowing users to access and interact with Claude AII

Project description

Claude AI-API ( Unofficial )

This project provides an unofficial API for Claude AI, allowing users to access and interact with Claude AI .

Use Cases

1. Python 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

  pip install requests

Installation

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

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)

      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>"
response = claude_api.send_message(prompt, conversation_id)
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.

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

claude-api-1.0.5.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

claude_api-1.0.5-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file claude-api-1.0.5.tar.gz.

File metadata

  • Download URL: claude-api-1.0.5.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for claude-api-1.0.5.tar.gz
Algorithm Hash digest
SHA256 343ea3660dfb0036aaa93039924e84615d7098374993adc75cac59c0251edd1c
MD5 925706805c4d04de4c3adc03e729f7b3
BLAKE2b-256 802b7e1bead11da4b8b469f348cf4ee7cd1406e390e823753975f29539a38c1a

See more details on using hashes here.

File details

Details for the file claude_api-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: claude_api-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for claude_api-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c745b3a94ab92a560d080081b589d12ea85f7b8a3588e99b9ec7a403f1ce769e
MD5 313545c24cb55a3b652698f75aeaa77d
BLAKE2b-256 86768fb9194af468460af317c31bea8179214c987ec46eb0b4b4dc016668ad98

See more details on using hashes here.

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