Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Python Tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install -r requirements-dev.txt

- name: Run tests
run: |
pytest tests/ --maxfail=1 --disable-warnings -v

- name: Check types with mypy
run: |
mypy src/a1base

- name: Check style with ruff
run: |
ruff check src/a1base tests
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 A1Base AI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
175 changes: 146 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,164 @@

A powerful and easy-to-use Python client for interacting with the A1Base API. Give your AI agents a phone number, an email, and real autonomy on the internet.

## Features
## Installation

- Send individual messages via WhatsApp
- Send group messages with attachments
- Retrieve message and thread details
- Get recent messages from threads
- Handle incoming WhatsApp messages
- Email integration
- Built-in security features:
- HTTPS-only communication
- Rate limiting
- Input sanitization
- Webhook security
- Safe error handling

## Installation
bash
```bash
pip install a1base
```

## Quick Start
python

```python
from a1base import A1BaseClient
from a1base.models import MessageRequest
Initialize client
from a1base.models import MessageRequest, EmailRequest

# Initialize client
client = A1BaseClient(
api_key="your_api_key",
api_secret="your_api_secret"
api_key="your_api_key",
api_secret="your_api_secret"
)
Send a WhatsApp message

# Send a WhatsApp message
message = MessageRequest(
content="Hello, World!",
from_="+1234567890",
to="+0987654321",
service="whatsapp"
content="Hello, World!",
from_="+1234567890",
to="+0987654321",
service="whatsapp"
)
response = client.send_individual_message("your_account_id", message)
print(f"Message status: {response.status}")

# Send an email
email = EmailRequest(
sender_address="jane@a101.bot",
recipient_address="john@a101.bot",
subject="Hello from A1Base",
body="Have a nice day!",
headers={
"cc": ["sarah@a101.bot"],
"reply-to": "jane@a101.bot"
}
)
response = client.send_email("your_account_id", email)
print(f"Email status: {response.status}")
```

## Authentication

The A1Base client uses API key authentication. You'll need both an API key and an API secret:

```python
client = A1BaseClient(
api_key="your_api_key",
api_secret="your_api_secret"
)
```

These credentials are automatically included in all API requests as headers.

## Features

### Messaging

#### Send Individual Messages
```python
from a1base.models import MessageRequest

message = MessageRequest(
content="Your message content",
from_="+1234567890", # Sender's phone number
to="+0987654321", # Recipient's phone number
service="whatsapp", # "whatsapp" or "telegram"
attachment_uri="https://example.com/file.pdf" # Optional
)

response = client.send_individual_message("account_id", message)
```

#### Send Group Messages
```python
from a1base.models import GroupMessageRequest

message = GroupMessageRequest(
content="Group message content",
from_="+1234567890",
service="whatsapp",
attachment_uri="https://example.com/image.jpg" # Optional
)

response = client.send_group_message("account_id", message)
```

#### Get Message Details
```python
# Get details of a specific message
message_details = client.get_message_details("account_id", "message_id")

# Get recent messages from a thread
recent_messages = client.get_recent_messages("account_id", "thread_id")

# Get thread details
thread_details = client.get_thread_details("account_id", "thread_id")

# Get all threads
all_threads = client.get_all_threads("account_id")

# Get threads for a specific phone number
number_threads = client.get_threads_by_number("account_id", "+1234567890")
```

### Email

#### Send Emails
```python
from a1base.models import EmailRequest

email = EmailRequest(
sender_address="sender@a101.bot",
recipient_address="recipient@a101.bot",
subject="Email Subject",
body="Email body content",
headers={
"bcc": ["bcc@a101.bot"],
"cc": ["cc@a101.bot"],
"reply-to": "reply@a101.bot"
},
attachment_uri="https://example.com/attachment.pdf" # Optional
)

response = client.send_email("account_id", email)
```

### Error Handling

The client includes built-in error handling for common scenarios:

```python
from a1base import AuthenticationError, ValidationError, RateLimitError

try:
response = client.send_individual_message("account_id", message)
except AuthenticationError:
print("Invalid API credentials")
except ValidationError as e:
print(f"Invalid request: {e}")
except RateLimitError:
print("Rate limit exceeded")
```

## Development

To contribute to the project, install development dependencies:

## Documentation
```bash
# Clone the repository
git clone https://github.com/a1baseai/a1base-python.git
cd a1base-python

For detailed documentation, visit [docs.a1base.com](https://docs.a1base.com)
# Install development dependencies
pip install -r requirements-dev.txt
```

## Security Features

Expand Down Expand Up @@ -76,4 +193,4 @@ We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
12 changes: 12 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[mypy]
ignore_missing_imports = True
strict = True
check_untyped_defs = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
disallow_untyped_decorators = True
no_implicit_optional = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_return_any = True
warn_unreachable = True
5 changes: 5 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pytest>=7.0.0
coverage>=6.0.0
mypy>=1.0.0
ruff>=0.1.0
black>=23.0.0
Loading