Skip to content
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python 3.9
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.9

# Run all pre-commit hooks on all the files.
# Getting only staged files can be tricky in case a new PR is opened
# since the action is run on a branch in detached head state
- name: Install and Run Pre-commit
uses: pre-commit/action@v2.0.3
uses: pre-commit/action@v3.0.1
with:
token: ${{ secrets.GITHUB_TOKEN }} #This would attempt to push back fixes

Expand All @@ -33,13 +33,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
# with:
# token: ${{ secrets.PAT }}
# submodules: recursive

- name: Set up Python 3.9
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.9

Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ pytest = "*"
pytest-cov = "*"

[requires]
python_version = "3.8"
python_version = "3.9"
623 changes: 437 additions & 186 deletions Pipfile.lock

Large diffs are not rendered by default.

80 changes: 51 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,48 +28,70 @@ $ pip install -U embedpy

To get started, sign up for your developer credentials on the [Embed Dashboard](https://embed.cowrywise.com). Once you have signed up, you can retrieve your `client_id` and `client_secret` keys from the developer dashboard. Set your credentials in the environment variables before creating an instance of the Embed Client.

```python
# Set environment variables
CLIENT_ID = CWRY-substitute-yours-here
CLIENT_SECRET = CWRY-SECRET-substitute-yours-here
### Initialization

# Create an instance of the Embed Client
```python
from embed.client import Client

# Initialize with environment variables (CLIENT_ID, CLIENT_SECRET)
client = Client()

# Or initialize with explicit credentials
client = Client(
client_id='your_client_id',
client_secret='your_client_secret',
base_url="https://sandbox.cowrywise.com" # Optional
)
```

Alternatively, you can use your credentials to instantiate the Embed Client. During this instantiation, you can specify a base URL. This is an optional parameter that defaults to the sandbox base URL.
### Example: Creating an Account and Investment

```python
from embed.client import Client
client = Client(client_id='****', client_secret='****', base_url="https://***.cowrywise.com")
# 1. Create a user account
account = client.account.create_account(
first_name="John",
last_name="Doe",
email="john.doe@example.com",
terms_of_use_accepted=True
)
account_id = account['data']['account_id']

# 2. List available assets
assets = client.asset.list_assets(asset_type="tbills")

# 3. Create an investment
investment = client.investment.create_investment(
account_id=account_id,
asset_code="AST-TBILL-0001",
amount=10000.0
)
```

## Embed API REST Methods

| Rest Method | Endpoint |
|------------------------------------------------------------------|-------------------|
| create_account(first_name=None, last_name=None, email=None) | `POST /accounts` |
| get_account(account_id) | `GET /accounts/:id` |
| update_next_of_kin(account_id=None, email=None, first_name=None,/last_name=None, phone_number=None, relationship=None, gender=None) | `POST /accounts/:id/nok` |
| get_portfolio(account_id) | `GET /accounts/:id/portfolio` |
| get_asset(asset_id) | `GET /assets/:id/` |
| list_assets(country=None, asset_type=None) | `GET /assets?country=None&asset_type=None` |
| get_index(index_id) | `GET /indexes/:id` |
| create_custom_index(account_id=None, name=None, description=None, allocations=None) | `POST /indexes` |
| modify_custom_index(account_id=None, index_id=None, allocations=None) | `PUT /indexes/:index_id` |
| get_investment(investment_id) | `GET /investments/:id` |
| create_investment(account_id=None, asset_code=None) | `POST /investments` |
| liquidate_investment(investment_id=None, units=None) | `POST /investments/:id` |
| get_price_history(asset_id=None, from_date=None, to_date=None) | `GET /prices?asset_id=None&from_date=None&to_date=None` |
| create_savings(account_id=None, days=None, interest_enabled=None, currency_code=None) | `POST /savings` |
| buy_stock(account_id=None, symbol=None, amount=None, side=None, the_type=None, time_in_force=None) | `POST /stocks/buy` |
| sell_stock(account_id=None, symbol=None, amount=None, side=None, the_type=None, time_in_force=None) | `POST /stocks/sell` |
| list_transfers(account_id=None, email=None, from_date=None, to_date=None) | `GET /transfers/:id?email=None&from_date=None&to_date=None` |
| get_deposit(deposit_id) | `GET /deposits/:id` |
| create_wallet(account_id=None, currency_code=None) | `POST /wallets` |
| transfer(wallet_id=None, product_code=None, amount=None) | `POST /wallets/:wallet_id/transfer` |
| get_wallet(wallet_id) | `GET /wallets/:wallet_id` |
| `create_account(first_name=None, last_name=None, email=None, **kwargs)` | `POST /accounts` |
| `get_account(account_id)` | `GET /accounts/:id` |
| `update_next_of_kin(account_id, email, first_name, last_name, phone_number, relationship, gender)` | `POST /accounts/:id/nok` |
| `get_portfolio(account_id)` | `GET /accounts/:id/portfolio` |
| `get_asset(asset_id)` | `GET /assets/:id/` |
| `list_assets(country=None, asset_type=None)` | `GET /assets?country=None&asset_type=None` |
| `get_index(index_id)` | `GET /indexes/:id` |
| `create_custom_index(account_id=None, name=None, description=None, allocations=None)` | `POST /indexes` |
| `modify_custom_index(account_id=None, index_id=None, allocations=None)` | `PUT /indexes/:index_id` |
| `get_investment(investment_id)` | `GET /investments/:id` |
| `create_investment(account_id=None, asset_code=None, **kwargs)` | `POST /investments` |
| `liquidate_investment(investment_id=None, units=None, **kwargs)` | `POST /investments/:id/liquidate` |
| `get_price_history(asset_id=None, from_date=None, to_date=None)` | `GET /prices?asset_id=None&from_date=None&to_date=None` |
| `create_savings(account_id=None, days=None, interest_enabled=None, currency_code=None)` | `POST /savings` |
| `buy_stock(account_id=None, symbol=None, amount=None, side=None, the_type=None, time_in_force=None)` | `POST /stocks/buy` |
| `sell_stock(account_id=None, symbol=None, amount=None, side=None, the_type=None, time_in_force=None)` | `POST /stocks/sell` |
| `list_transfers(account_id=None, email=None, from_date=None, to_date=None)` | `GET /transfers/:id?email=None&from_date=None&to_date=None` |
| `get_deposit(deposit_id)` | `GET /deposits/:id` |
| `create_wallet(account_id=None, currency_code=None)` | `POST /wallets` |
| `transfer(wallet_id=None, product_code=None, amount=None)` | `POST /wallets/:wallet_id/transfer` |
| `get_wallet(wallet_id)` | `GET /wallets/:wallet_id` |

Check the [API reference](https://developers.cowrywise.com/reference) document for all resources and their respective endpoints.

Expand Down
Loading
Loading