Name | tangany_settlement_api_sdk JSON |
Version |
0.1.6
JSON |
| download |
home_page | None |
Summary | Inofficial Python SDK for consuming Tangany Settlement API |
upload_time | 2024-09-24 13:48:55 |
maintainer | None |
docs_url | None |
author | Marcel |
requires_python | <4.0,>=3.10 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Tangany Settlement API Python SDK
Unofficial Python SDK for consuming Tangany Settlement API.
## Installation
To install the SDK, you can use pip:
```bash
pip install tangany_settlement_api_sdk
```
## Usage
### Initialization
First, import the SDK:
```python
from tangany_settlement_api_sdk import SettlementClient
from tangany_settlement_api_sdk.auth import Credentials
```
Initialize the SDK by providing API credentials and create a Settlement API client:
```python
credentials = Credentials(client_id="xxx", client_secret="yyy")
api = SettlementClient(credentials=credentials)
```
## Examples
There is a [jupyter notebook file](./examples.ipynb) with all examples, here is an excerpt of some examples to demonstrate how to use the SDK:
### Accounts
#### Create accounts
```python
api.accounts.create(id="00000001", label="Satoshi Nakamoto's account", type="internal")
```
#### Update account label
```python
api.accounts.update(id="00000001", op="replace", path="/label", value="Satoshi Nakamoto's HODL account")
```
#### List all account ids
```python
account_ids = []
next_page_token = ""
while next_page_token != None:
results = api.accounts.list(next_page_token)
next_page_token = results['nextPageToken']
for result in results['items']:
account_ids.append(result['id'])
```
#### Delete accounts
```python
api.accounts.delete(id="00000001")
```
### Assets
#### Get all asset ids
```python
api = SettlementClient(credentials=credentials)
asset_ids = []
for asset in api.assets.list()['items']:
asset_ids.append(asset['id'])
```
#### Get a specific asset
```python
result = api.assets.get(id="BTC")
```
### Ledgers
#### Create ledger
```python
api.ledgers.create("Test", "My test ledger")
```
#### List ledgers
```python
result = api.ledgers.list()
```
#### Get a specific ledger
```python
result = api.ledgers.get(id="Test")
```
### Transactions
#### Create a virtual transaction
```python
api.transactions.create(
ledger_id="Test",
transaction_id="TX_SAMPLE",
from_account_id="00000001",
to_account_id="00000002",
value_date="2023-11-11T15:00:00.000Z",
asset_id="BTC",
value="1.0",
fiat_currency="EUR",
fiat_value="30000.00",
reference="BTC-REF",
trade_info_fill_date="2023-11-10T15:00:00.000Z",
trade_info_market_maker_tx_id="123456789"
)
```
#### Get a single transaction
```python
result = api.transactions.get(ledger_id="Test", transaction_id="TX_SAMPLE")
```
#### Get all transactions for a specific account id
```python
transactions = []
next_page_token = ""
while next_page_token != None:
results = api.transactions.list(ledger_id="Test", involving_account_id="00000001", next_page_token=next_page_token)
next_page_token = results['nextPageToken']
for result in results['items']:
transactions.append(result)
```
#### Get all transactions after a specific booking date
```python
transactions = []
next_page_token = ""
while next_page_token != None:
results = api.transactions.list(ledger_id="Test", booking_date_after="2023-11-11", next_page_token=next_page_token)
next_page_token = results['nextPageToken']
for result in results['items']:
transactions.append(result)
```
#### Delete a single transaction (mark as cancelled)
```python
api.transactions.delete(ledger_id="Test", transaction_id="TX_SAMPLE")
```
### Fundings
#### Sync on-chain deposit as virtual transaction (create deposit)
```python
api.funding_deposits.create(
ledger_id="Test",
transaction_id=f"TX_GENESIS",
to_account_id="00000001",
value_date="2023-11-11T15:00:00.000Z",
asset_id="BTC",
value="1.0",
fiat_currency="EUR",
fiat_value="30000.00",
reference="BTC-REF",
txHash="0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
)
```
#### List fundings
```python
transactions = []
next_page_token = ""
while next_page_token != None:
results = api.fundings.list(ledger_id="Test", next_page_token=next_page_token)
next_page_token = results['nextPageToken']
for result in results['items']:
transactions.append(result)
```
### Balances
#### List all account balances
```python
account_balances = []
next_page_token = ""
while next_page_token != None:
results = api.account_balances.list(ledger_id="Test", valuta_date="2023-11-12", next_page_token=next_page_token)
next_page_token = results['nextPageToken']
for result in results['items']:
account_balances.append(result)
```
#### Get single account balance
```python
result = api.account_balances.get(ledger_id="Test", account_id="00000001")
```
#### Get ledger balance of all assets
```python
result = api.asset_balances.get(ledger_id="Test")
```
### Reports
#### Create immediate report
```python
api.reports.create(id="report1", type="account_balances_v1", format="csv", ledger_id="Test", date="2023-11-13")
```
#### List all reports
```python
result = api.reports.list()
```
#### Get a single report
```python
result = api.reports.get(id="report1")
```
#### List report results
```python
result = api.report_results.list("report1")
```
#### Download a report
```python
result = api.report_results.get(report_id="report1", result_id="2023-11-17T12:07:00Z")
```
#### Delete report
```python
result = api.reports.delete(id="report1")
```
## Changelog
All notable changes to this project are documented in the [changelog](./CHANGELOG.MD)
## Testing
For testing provide your credentials to [examples.ipynb](./examples.ipynb) and run the notebook.
## Deployment
To release a new version of this SDK please update the version contained in the [pyproject.toml](./pyproject.toml) file.
After testing just use _poetry_ to build and publish a new version to [pypi.org](https://pypi.org/project/tangany_settlement_api_sdk/):
```
poetry build
poetry publish
```
## API documentation
Full API documentation is available at https://docs.tangany.com
<img src="https://cwstorecdn0.blob.core.windows.net/web/stoplight/TanganySettlementAPI.png" width="50%" alt="Tangany" align="middle" />
<br><br>
***
<br><br>
<div align="center"><img src="https://cwstorecdn0.blob.core.windows.net/web/tangany_logo_wordmark_on_dark.png" width="50%" alt="Tangany" align="middle" />
<p>
</p>
<p>
© 2023 <a href="https://tangany.com">Tangany GmbH</a>
</p>
<p>
<a href="https://tangany.com/imprint/">Imprint</a>
• <a href="https://tangany.com/legal-privacy/">Legal & privacy</a>
• <a href="https://tangany.com#newsletter">Newsletter</a>
• <a href="https://twitter.com/tangany">Twitter</a>
• <a href="https://www.facebook.com/tanganywallet">Facebook</a>
• <a href="https://www.linkedin.com/company/tangany/">LinkedIn</a>
• <a href="https://www.youtube.com/channel/UCmDr1clodG1ov-iX_GMkwMA">YouTube</a>
• <a href="https://github.com/Tangany/">Github</a>
</p>
</div>
Raw data
{
"_id": null,
"home_page": null,
"name": "tangany_settlement_api_sdk",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Marcel",
"author_email": "marcel.nellesen@tangany.com",
"download_url": "https://files.pythonhosted.org/packages/40/06/a3e9f6253d5a4882a3c17a688132dc219382e676fa5dbedb968adc42c730/tangany_settlement_api_sdk-0.1.6.tar.gz",
"platform": null,
"description": "# Tangany Settlement API Python SDK\n\nUnofficial Python SDK for consuming Tangany Settlement API.\n\n## Installation\n\nTo install the SDK, you can use pip:\n\n```bash\npip install tangany_settlement_api_sdk\n```\n\n## Usage\n\n### Initialization\n\nFirst, import the SDK:\n```python\nfrom tangany_settlement_api_sdk import SettlementClient\nfrom tangany_settlement_api_sdk.auth import Credentials\n\n```\n\nInitialize the SDK by providing API credentials and create a Settlement API client:\n\n```python\ncredentials = Credentials(client_id=\"xxx\", client_secret=\"yyy\")\napi = SettlementClient(credentials=credentials)\n```\n\n## Examples\n\nThere is a [jupyter notebook file](./examples.ipynb) with all examples, here is an excerpt of some examples to demonstrate how to use the SDK:\n\n### Accounts\n\n#### Create accounts\n```python\napi.accounts.create(id=\"00000001\", label=\"Satoshi Nakamoto's account\", type=\"internal\")\n```\n\n\n#### Update account label \n```python\napi.accounts.update(id=\"00000001\", op=\"replace\", path=\"/label\", value=\"Satoshi Nakamoto's HODL account\") \n```\n\n#### List all account ids \n```python\naccount_ids = []\nnext_page_token = \"\"\n\nwhile next_page_token != None:\n results = api.accounts.list(next_page_token) \n next_page_token = results['nextPageToken'] \n for result in results['items']:\n account_ids.append(result['id'])\n```\n\n#### Delete accounts\n```python\napi.accounts.delete(id=\"00000001\")\n```\n\n### Assets\n\n#### Get all asset ids \n```python\napi = SettlementClient(credentials=credentials)\nasset_ids = []\nfor asset in api.assets.list()['items']:\n asset_ids.append(asset['id'])\n```\n\n#### Get a specific asset \n```python\nresult = api.assets.get(id=\"BTC\")\n```\n\n### Ledgers \n\n#### Create ledger \n```python\napi.ledgers.create(\"Test\", \"My test ledger\")\n```\n\n#### List ledgers \n```python\nresult = api.ledgers.list()\n```\n\n#### Get a specific ledger \n```python\nresult = api.ledgers.get(id=\"Test\")\n```\n\n### Transactions \n\n#### Create a virtual transaction \n```python\napi.transactions.create(\n ledger_id=\"Test\",\n transaction_id=\"TX_SAMPLE\",\n from_account_id=\"00000001\",\n to_account_id=\"00000002\",\n value_date=\"2023-11-11T15:00:00.000Z\",\n asset_id=\"BTC\",\n value=\"1.0\",\n fiat_currency=\"EUR\",\n fiat_value=\"30000.00\",\n reference=\"BTC-REF\",\n trade_info_fill_date=\"2023-11-10T15:00:00.000Z\",\n trade_info_market_maker_tx_id=\"123456789\" \n)\n```\n\n#### Get a single transaction \n```python\nresult = api.transactions.get(ledger_id=\"Test\", transaction_id=\"TX_SAMPLE\")\n```\n\n#### Get all transactions for a specific account id \n```python\ntransactions = []\nnext_page_token = \"\"\n\nwhile next_page_token != None:\n results = api.transactions.list(ledger_id=\"Test\", involving_account_id=\"00000001\", next_page_token=next_page_token)\n next_page_token = results['nextPageToken'] \n for result in results['items']:\n transactions.append(result)\n```\n\n#### Get all transactions after a specific booking date \n```python\ntransactions = []\nnext_page_token = \"\"\n\nwhile next_page_token != None:\n results = api.transactions.list(ledger_id=\"Test\", booking_date_after=\"2023-11-11\", next_page_token=next_page_token)\n next_page_token = results['nextPageToken'] \n for result in results['items']:\n transactions.append(result)\n```\n\n#### Delete a single transaction (mark as cancelled) \n```python\napi.transactions.delete(ledger_id=\"Test\", transaction_id=\"TX_SAMPLE\")\n\n```\n### Fundings\n#### Sync on-chain deposit as virtual transaction (create deposit) \n```python\napi.funding_deposits.create(\n ledger_id=\"Test\",\n transaction_id=f\"TX_GENESIS\",\n to_account_id=\"00000001\",\n value_date=\"2023-11-11T15:00:00.000Z\",\n asset_id=\"BTC\",\n value=\"1.0\",\n fiat_currency=\"EUR\",\n fiat_value=\"30000.00\",\n reference=\"BTC-REF\",\n txHash=\"0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f\"\n)\n```\n\n#### List fundings \n```python\ntransactions = []\nnext_page_token = \"\"\n\nwhile next_page_token != None:\n results = api.fundings.list(ledger_id=\"Test\", next_page_token=next_page_token)\n next_page_token = results['nextPageToken'] \n for result in results['items']:\n transactions.append(result)\n```\n\n### Balances\n\n#### List all account balances \n```python\naccount_balances = []\nnext_page_token = \"\"\n\nwhile next_page_token != None:\n results = api.account_balances.list(ledger_id=\"Test\", valuta_date=\"2023-11-12\", next_page_token=next_page_token)\n next_page_token = results['nextPageToken'] \n for result in results['items']:\n account_balances.append(result)\n```\n\n#### Get single account balance \n```python\nresult = api.account_balances.get(ledger_id=\"Test\", account_id=\"00000001\")\n```\n\n#### Get ledger balance of all assets \n```python\nresult = api.asset_balances.get(ledger_id=\"Test\")\n```\n\n### Reports\n\n#### Create immediate report \n```python\napi.reports.create(id=\"report1\", type=\"account_balances_v1\", format=\"csv\", ledger_id=\"Test\", date=\"2023-11-13\")\n```\n\n#### List all reports \n```python\nresult = api.reports.list()\n```\n\n#### Get a single report \n```python\nresult = api.reports.get(id=\"report1\")\n```\n\n#### List report results \n```python\nresult = api.report_results.list(\"report1\")\n```\n\n\n#### Download a report \n```python\nresult = api.report_results.get(report_id=\"report1\", result_id=\"2023-11-17T12:07:00Z\")\n```\n\n\n#### Delete report \n```python\nresult = api.reports.delete(id=\"report1\")\n```\n\n## Changelog\nAll notable changes to this project are documented in the [changelog](./CHANGELOG.MD)\n\n## Testing\nFor testing provide your credentials to [examples.ipynb](./examples.ipynb) and run the notebook.\n\n## Deployment\nTo release a new version of this SDK please update the version contained in the [pyproject.toml](./pyproject.toml) file.\nAfter testing just use _poetry_ to build and publish a new version to [pypi.org](https://pypi.org/project/tangany_settlement_api_sdk/):\n\n```\npoetry build\npoetry publish\n```\n\n## API documentation\nFull API documentation is available at https://docs.tangany.com\n\n<img src=\"https://cwstorecdn0.blob.core.windows.net/web/stoplight/TanganySettlementAPI.png\" width=\"50%\" alt=\"Tangany\" align=\"middle\" />\n<br><br>\n\n***\n\n<br><br>\n<div align=\"center\"><img src=\"https://cwstorecdn0.blob.core.windows.net/web/tangany_logo_wordmark_on_dark.png\" width=\"50%\" alt=\"Tangany\" align=\"middle\" />\n<p>\n\n</p>\n<p>\n\u00a9 2023 <a href=\"https://tangany.com\">Tangany GmbH</a>\n</p>\n<p>\n <a href=\"https://tangany.com/imprint/\">Imprint</a>\n\u2022 <a href=\"https://tangany.com/legal-privacy/\">Legal & privacy</a>\n\u2022 <a href=\"https://tangany.com#newsletter\">Newsletter</a>\n\u2022 <a href=\"https://twitter.com/tangany\">Twitter</a>\n\u2022 <a href=\"https://www.facebook.com/tanganywallet\">Facebook</a>\n\u2022 <a href=\"https://www.linkedin.com/company/tangany/\">LinkedIn</a>\n\u2022 <a href=\"https://www.youtube.com/channel/UCmDr1clodG1ov-iX_GMkwMA\">YouTube</a>\n\u2022 <a href=\"https://github.com/Tangany/\">Github</a>\n</p>\n</div>",
"bugtrack_url": null,
"license": "MIT",
"summary": "Inofficial Python SDK for consuming Tangany Settlement API",
"version": "0.1.6",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "779f48762139e75bd21d28035d03e6910e880dad8eb46f27e95dd39fad92cafe",
"md5": "ccb2c6dda12becbfeb788558a6f88ece",
"sha256": "be16855748d3cc8b5ec70c129c01944a511ed4aea381ea8ffdab26dc75bff9e0"
},
"downloads": -1,
"filename": "tangany_settlement_api_sdk-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ccb2c6dda12becbfeb788558a6f88ece",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 16801,
"upload_time": "2024-09-24T13:48:54",
"upload_time_iso_8601": "2024-09-24T13:48:54.860873Z",
"url": "https://files.pythonhosted.org/packages/77/9f/48762139e75bd21d28035d03e6910e880dad8eb46f27e95dd39fad92cafe/tangany_settlement_api_sdk-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4006a3e9f6253d5a4882a3c17a688132dc219382e676fa5dbedb968adc42c730",
"md5": "7d2152335ea76057e2f99817bf4a170e",
"sha256": "1400eabb327da43bf7547c5a0ce3a7ac7e5697f034b39f58d0060696fb23ff55"
},
"downloads": -1,
"filename": "tangany_settlement_api_sdk-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "7d2152335ea76057e2f99817bf4a170e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 10116,
"upload_time": "2024-09-24T13:48:55",
"upload_time_iso_8601": "2024-09-24T13:48:55.852491Z",
"url": "https://files.pythonhosted.org/packages/40/06/a3e9f6253d5a4882a3c17a688132dc219382e676fa5dbedb968adc42c730/tangany_settlement_api_sdk-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-24 13:48:55",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "tangany_settlement_api_sdk"
}