| Name | phrappy JSON |
| Version |
0.2.0
JSON |
| download |
| home_page | None |
| Summary | Unofficial typed Python Client for the Phrase TMS (Memsource) API. |
| upload_time | 2025-09-11 08:32:07 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.10 |
| license | Copyright © 2025 Henrik Kühnemann 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. |
| keywords |
api
localization
phrase
tms
translation
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
from phrappy import Phrappy
# phrappy
Typed, batteries-included Python client for **Phrase TMS (Memsource)** generated from the public OpenAPI spec. Comes with both sync and async clients, fully equipped with first-class Pydantic v2 models.
The build process is fully automated and project release is planned to follow the Phrase TMS bi-weekly release cadence.
> This project is **not** an official Phrase/Memsource SDK. Official documentation can be found at [developers.phrase.com](https://developers.phrase.com/en/api/tms/latest/introduction)
---
## Installation
```bash
pip install phrappy
```
**Requirements:** Python ≥ 3.10
---
## Quickstart
### 1) Authenticate to get a token
Either use your authentication method of choice directly to get a token.
```python
from phrappy import Phrappy
from phrappy.models import LoginDto
pp = Phrappy()
login_response = pp.authentication.login(LoginDto(
userName="your_name",
password="<password>"
))
token = login_response.token
pp.close()
```
All typed methods also accept dict inputs that are then validated under the hood. For example:
```python
from phrappy import Phrappy
pp = Phrappy()
login_response = pp.authentication.login({
"userName":"your_name",
"password":"<password>"
})
token = login_response.token
pp.close()
```
Or use the convenience method for authenticating and getting a Phrappy instance that carries its token.
```python
from phrappy import Phrappy
pp = Phrappy.from_creds(username="name@example.com", password="…")
me = pp.authentication.who_am_i()
print(me.user.uid)
pp.close()
```
Using a context manager closes the underlying HTTP client automatically:
```python
from phrappy import Phrappy
with Phrappy(token="<YOUR_TOKEN>") as pp:
me = pp.authentication.who_am_i()
print(me.user.userName)
```
### 3) Async usage
```python
import asyncio
from phrappy import AsyncPhrappy
async def main():
async with AsyncPhrappy(token="<YOUR_TOKEN>") as app:
me = await app.authentication.who_am_i()
print(me.user.userName)
asyncio.run(main())
```
---
## Examples
### Create a project and upload a job (multipart)
```python
from pathlib import Path
from phrappy import Phrappy, cdh_generator
from phrappy.models import CreateProjectV3Dto, JobCreateRequestDto
with Phrappy(token="<YOUR_TOKEN>") as pp:
proj = pp.project.create_project_v3(CreateProjectV3Dto(name="Demo", sourceLang="en", targetLangs=["sv"]))
p = Path("example.txt"); p.write_text("Hello from phrappy")
jobs = pp.job.create_job(
project_uid=proj.uid,
content_disposition=cdh_generator(p.name),
file_bytes=p.read_bytes(),
memsource=JobCreateRequestDto(targetLangs=proj.targetLangs),
)
print([j.uid for j in jobs.jobs or []])
```
### List your assigned projects
```python
me = pp.authentication.who_am_i()
page = pp.project.list_assigned_projects(me.user.uid, target_lang=["sv"]) # returns a typed page model
for item in page.content or []:
print(item.name, item.status)
```
---
## API design
- Typed models everywhere! Inputs/outputs are Pydantic v2 models generated from the OpenAPI. You can pass either a model instance **or** a `dict` for body/header parameters; the client will validate and coerce.
- Rich method docstrings based on operation descriptions and typing information.
- Every operation exists in both `Phrappy` and `AsyncPhrappy` under the same tag-based namespaces.
- Built on `httpx` with httpx.Client/httpx.AsyncClient under the hood.
> If you find a mismatch between the API behavior and the generated models, please open an issue with the request/response payloads (redacted) and the package version.
---
## Configuration
- Defaults to `https://cloud.memsource.com/web`. Override via `Phrappy(base_url=...)` or `AsyncPhrappy(base_url=...)`.
- Pass `timeout=` (seconds) to the client constructor. Per-request timeouts are also supported on `make_request` if you wrap custom calls.
---
## Testing
Test suite is being built out and currently focuses on live testing to catch documentation schema drift. Live tests will create and delete assets, costing a handful of words.
> Will gladly accept pull requests towards completion of test suite!
```bash
# run fast tests only (default)
pytest -m "not live and not destructive" -q
# run live tests against your account (creates & deletes resources!)
export PHRAPPY_TOKEN=ApiToken_...
pytest -m live -q
```
Env vars used by live tests:
- `PHRAPPY_TOKEN` **or** (`PHRAPPY_USER` and `PHRAPPY_PASSWORD`)
- `PHRAPPY_BASE_URL` (optional)
---
## Roadmap
- Complete the test suite
- Streaming uploads/downloads
- Convenience functions for AsyncJob interactions
- Toggle for type validation / raw dict input/output
---
## Release notes
### 0.2.0
- Improved naming of anonymous enums that are declared inline in schemas, when hoisted into separate models.
### 0.1.0
- Complete rewrite of build pipeline with fully automated and repeatable builds.
- Support for polymorph input and output schemas.
- Slight change in API surface due to schema naming normalization.
- Added context manager support.
- Minimal test suite implemented.
---
## License
MIT
Raw data
{
"_id": null,
"home_page": null,
"name": "phrappy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "api, localization, phrase, tms, translation",
"author": null,
"author_email": "Henrik K\u00fchnemann <hk@yellownape.se>",
"download_url": "https://files.pythonhosted.org/packages/bd/3f/41cadd2a4e4cb4269fb50aca2d86c40f8a3fe03b159b2ac799e843e22938/phrappy-0.2.0.tar.gz",
"platform": null,
"description": "from phrappy import Phrappy\n\n# phrappy\n\nTyped, batteries-included Python client for **Phrase TMS (Memsource)** generated from the public OpenAPI spec. Comes with both sync and async clients, fully equipped with first-class Pydantic v2 models.\n\nThe build process is fully automated and project release is planned to follow the Phrase TMS bi-weekly release cadence. \n\n> This project is **not** an official Phrase/Memsource SDK. Official documentation can be found at [developers.phrase.com](https://developers.phrase.com/en/api/tms/latest/introduction)\n\n---\n\n## Installation\n\n```bash\npip install phrappy\n```\n\n**Requirements:** Python \u2265 3.10\n\n---\n\n## Quickstart\n\n### 1) Authenticate to get a token\nEither use your authentication method of choice directly to get a token.\n```python\nfrom phrappy import Phrappy\nfrom phrappy.models import LoginDto\n\npp = Phrappy()\nlogin_response = pp.authentication.login(LoginDto(\n userName=\"your_name\",\n password=\"<password>\"\n))\ntoken = login_response.token\npp.close()\n```\nAll typed methods also accept dict inputs that are then validated under the hood. For example:\n```python\nfrom phrappy import Phrappy\n\n\npp = Phrappy()\nlogin_response = pp.authentication.login({\n \"userName\":\"your_name\",\n \"password\":\"<password>\"\n})\ntoken = login_response.token\npp.close()\n```\n\nOr use the convenience method for authenticating and getting a Phrappy instance that carries its token. \n```python\nfrom phrappy import Phrappy\n\npp = Phrappy.from_creds(username=\"name@example.com\", password=\"\u2026\")\nme = pp.authentication.who_am_i()\nprint(me.user.uid)\npp.close()\n```\n\nUsing a context manager closes the underlying HTTP client automatically:\n```python\nfrom phrappy import Phrappy\n\nwith Phrappy(token=\"<YOUR_TOKEN>\") as pp:\n me = pp.authentication.who_am_i()\n print(me.user.userName)\n```\n\n\n### 3) Async usage\n```python\nimport asyncio\nfrom phrappy import AsyncPhrappy\n\nasync def main():\n async with AsyncPhrappy(token=\"<YOUR_TOKEN>\") as app:\n me = await app.authentication.who_am_i()\n print(me.user.userName)\n\nasyncio.run(main())\n```\n\n---\n\n## Examples\n\n### Create a project and upload a job (multipart)\n```python\nfrom pathlib import Path\nfrom phrappy import Phrappy, cdh_generator\nfrom phrappy.models import CreateProjectV3Dto, JobCreateRequestDto\n\nwith Phrappy(token=\"<YOUR_TOKEN>\") as pp:\n proj = pp.project.create_project_v3(CreateProjectV3Dto(name=\"Demo\", sourceLang=\"en\", targetLangs=[\"sv\"]))\n\n p = Path(\"example.txt\"); p.write_text(\"Hello from phrappy\")\n jobs = pp.job.create_job(\n project_uid=proj.uid,\n content_disposition=cdh_generator(p.name),\n file_bytes=p.read_bytes(),\n memsource=JobCreateRequestDto(targetLangs=proj.targetLangs),\n )\n print([j.uid for j in jobs.jobs or []])\n```\n\n### List your assigned projects\n```python\nme = pp.authentication.who_am_i()\npage = pp.project.list_assigned_projects(me.user.uid, target_lang=[\"sv\"]) # returns a typed page model\nfor item in page.content or []:\n print(item.name, item.status)\n```\n\n---\n\n## API design\n\n- Typed models everywhere! Inputs/outputs are Pydantic v2 models generated from the OpenAPI. You can pass either a model instance **or** a `dict` for body/header parameters; the client will validate and coerce.\n- Rich method docstrings based on operation descriptions and typing information. \n- Every operation exists in both `Phrappy` and `AsyncPhrappy` under the same tag-based namespaces.\n- Built on `httpx` with httpx.Client/httpx.AsyncClient under the hood. \n\n> If you find a mismatch between the API behavior and the generated models, please open an issue with the request/response payloads (redacted) and the package version.\n\n---\n\n## Configuration\n\n- Defaults to `https://cloud.memsource.com/web`. Override via `Phrappy(base_url=...)` or `AsyncPhrappy(base_url=...)`.\n- Pass `timeout=` (seconds) to the client constructor. Per-request timeouts are also supported on `make_request` if you wrap custom calls.\n\n---\n\n## Testing\n\nTest suite is being built out and currently focuses on live testing to catch documentation schema drift. Live tests will create and delete assets, costing a handful of words. \n\n> Will gladly accept pull requests towards completion of test suite! \n\n```bash\n# run fast tests only (default)\npytest -m \"not live and not destructive\" -q\n\n# run live tests against your account (creates & deletes resources!)\nexport PHRAPPY_TOKEN=ApiToken_...\npytest -m live -q\n```\n\nEnv vars used by live tests:\n- `PHRAPPY_TOKEN` **or** (`PHRAPPY_USER` and `PHRAPPY_PASSWORD`)\n- `PHRAPPY_BASE_URL` (optional)\n\n---\n\n## Roadmap\n\n- Complete the test suite\n- Streaming uploads/downloads\n- Convenience functions for AsyncJob interactions\n- Toggle for type validation / raw dict input/output\n\n\n---\n\n## Release notes\n\n### 0.2.0\n- Improved naming of anonymous enums that are declared inline in schemas, when hoisted into separate models. \n\n### 0.1.0\n- Complete rewrite of build pipeline with fully automated and repeatable builds.\n- Support for polymorph input and output schemas. \n- Slight change in API surface due to schema naming normalization.\n- Added context manager support.\n- Minimal test suite implemented.\n\n---\n\n## License\n\nMIT\n\n",
"bugtrack_url": null,
"license": "Copyright \u00a9 2025 Henrik K\u00fchnemann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), 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 \u201cAS IS\u201d, 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.",
"summary": "Unofficial typed Python Client for the Phrase TMS (Memsource) API.",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/kuhnemann/phrappy"
},
"split_keywords": [
"api",
" localization",
" phrase",
" tms",
" translation"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ba86473b4c55d7d5e43cbc0f01fb07e3105289e0f78a6ea39cf1d3e0c15a5b2b",
"md5": "631e553733e55d70318148ff8137176d",
"sha256": "0a148b69d336fa617af53b560c5392537be4f4b3a3ed01c775230038c49e13ef"
},
"downloads": -1,
"filename": "phrappy-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "631e553733e55d70318148ff8137176d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 275794,
"upload_time": "2025-09-11T08:32:05",
"upload_time_iso_8601": "2025-09-11T08:32:05.956097Z",
"url": "https://files.pythonhosted.org/packages/ba/86/473b4c55d7d5e43cbc0f01fb07e3105289e0f78a6ea39cf1d3e0c15a5b2b/phrappy-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "bd3f41cadd2a4e4cb4269fb50aca2d86c40f8a3fe03b159b2ac799e843e22938",
"md5": "46ac28a253d388b5deea0e653b9137a3",
"sha256": "e2f60c9b179eede40f5a7987afb401418ef2e0b8344d16b090e79b6ac61a0a3d"
},
"downloads": -1,
"filename": "phrappy-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "46ac28a253d388b5deea0e653b9137a3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 3638197,
"upload_time": "2025-09-11T08:32:07",
"upload_time_iso_8601": "2025-09-11T08:32:07.988527Z",
"url": "https://files.pythonhosted.org/packages/bd/3f/41cadd2a4e4cb4269fb50aca2d86c40f8a3fe03b159b2ac799e843e22938/phrappy-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-11 08:32:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kuhnemann",
"github_project": "phrappy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "phrappy"
}