{"id":22540912,"url":"https://github.com/affinda/affinda-python","last_synced_at":"2025-11-08T06:04:49.696Z","repository":{"id":55612699,"uuid":"394150971","full_name":"affinda/affinda-python","owner":"affinda","description":"Python client library for the Affinda API","archived":false,"fork":false,"pushed_at":"2025-03-31T03:59:01.000Z","size":3025,"stargazers_count":9,"open_issues_count":2,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-31T04:28:07.528Z","etag":null,"topics":["affinda","api","python"],"latest_commit_sha":null,"homepage":"https://affinda.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/affinda.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-09T04:41:55.000Z","updated_at":"2025-03-31T03:59:04.000Z","dependencies_parsed_at":"2023-02-19T13:00:43.565Z","dependency_job_id":"6f023185-680c-4eef-bd34-a0ba8cf41f2b","html_url":"https://github.com/affinda/affinda-python","commit_stats":{"total_commits":139,"total_committers":7,"mean_commits":"19.857142857142858","dds":0.5107913669064748,"last_synced_commit":"4452b13ef0d64d4d7ee4cb1ab6c0df24607ba2e9"},"previous_names":[],"tags_count":84,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/affinda%2Faffinda-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/affinda%2Faffinda-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/affinda%2Faffinda-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/affinda%2Faffinda-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/affinda","download_url":"https://codeload.github.com/affinda/affinda-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119439,"owners_count":21050754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["affinda","api","python"],"created_at":"2024-12-07T12:13:06.828Z","updated_at":"2025-11-08T06:04:49.646Z","avatar_url":"https://github.com/affinda.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python Client Library for Affinda Document Parser API\n\n![affinda logo](https://api.affinda.com/static/documentation/affinda_logo_light.png)\n\n[![pypi ver](https://img.shields.io/pypi/v/affinda)](https://pypi.org/project/affinda/)\n[![pypi pyver](https://img.shields.io/pypi/pyversions/affinda)](https://pypi.org/affinda/)\n[![pypi dlm](https://img.shields.io/pypi/dm/affinda)](https://pypi.org/project/affinda/)\n[![license](https://img.shields.io/github/license/affinda/affinda-python)](https://choosealicense.com/licenses/mit/)\n\n[![codestyle](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n[![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/affinda/affinda-python)\n\nThis is a python client for the Affinda document parsing API which wraps all available endpoints\nand handles authentication and signing. You may also want to refer to the full\n[API documentation](https://api.affinda.com/docs) for additional information.\n\n## Installation\n\n```shell\npip install affinda\n```\n\n## API Version Compatibility\n\nThe Affinda API is currently on `v3`, with breaking changes meant the release of new versions of the client library.\nPlease see below for which versions are compatible with which API version.\n\n| Affinda API version | `affinda-python` versions |\n| ------------------- | ------------------------- |\n| v2                  | 0.1.0 - 3.x.x             |\n| v3                  | \\\u003e= 4.x.x                 |\n\n## Quickstart\n\nBefore using the API, you need to create an account, setup a workspace, and obtain an API key.\nFollow the steps in our [documentation](https://docs.affinda.com/docs/getting-started-with-affinda).\n\n```python\nfrom pathlib import Path\nfrom affinda import AffindaAPI, TokenCredential\n\nAPI_KEY = \"YOUR_API_KEY\"                      # replace with your actual key\nWORKSPACE_ID = \"YOUR_WORKSPACE_IDENTIFIER\"    # e.g. \"vBAdDBer\"\nFILE_PATH = Path(\"resume.pdf\")                # path to the résumé you want to parse\n\n# Set up the client\ncredential = TokenCredential(token=API_KEY)\nclient = AffindaAPI(credential=credential)\n\n# Upload the document and wait until processing finishes\nwith FILE_PATH.open(\"rb\") as f:\n    doc = client.create_document(\n        file=f,\n        workspace=WORKSPACE_ID,\n    )\n\n# Access parsed data\nprint(doc.data)\n```\n\n## Pydantic models\n\nYou can generate pydantic models to help with validating and consuming the API response in a type-safe way.\n\nUse the `generate_models` command to auto-generate pydantic models from your document type configuration.\nFor example, this will generate pydantic models for your \"Resume Parser\" document type:\n\n```bash\n# Assuming your Resume Parser document type ID is \"rLERIsHk\"\npython -m affinda generate_models --document-type-id=rLERIsHk\n```\n\nYou will be prompted for your API key, unless you already have the `AFFINDA_API_KEY` environment variable set.\n\nThe generated pydantic model(s) will be in `./affinda_models` by default.\n\nFor all the options you can use, run:\n\n```bash\npython -m affinda generate_models --help\n```\n\nExample of using the generated pydantic models:\n\n```python\nfrom pathlib import Path\nfrom affinda import AffindaAPI, TokenCredential\nfrom affinda_models.resume_parser import ResumeParser\n\nAPI_KEY = \"YOUR_API_KEY\"                      # replace with your actual key\nWORKSPACE_ID = \"YOUR_WORKSPACE_IDENTIFIER\"    # e.g. \"vBAdDBer\"\nFILE_PATH = Path(\"resume.pdf\")                # path to the résumé you want to parse\n\n# Set up the client\ncredential = TokenCredential(token=API_KEY)\nclient = AffindaAPI(credential=credential)\n\n# This will raise `pydantic_core.ValidationError` if the API response does not validate against ResumeParser\nwith FILE_PATH.open(\"rb\") as f:\n    doc = client.create_document(\n        file=f,\n        workspace=WORKSPACE_ID,\n        data_model=ResumeParser,\n    )\n\n# Access parsed data\nprint(doc.parsed)  # This is a ResumeParser instance\nprint(doc.data)  # This is the raw JSON response\n\n# This will NOT raise `pydantic_core.ValidationError` if the API response does not validate against ResumeParser.\n# Instead `parsed` will be None if the API response is not compatible.\nwith FILE_PATH.open(\"rb\") as f:\n    doc = client.create_document(\n        file=f,\n        workspace=WORKSPACE_ID,\n        data_model=ResumeParser,\n        ignore_validation_errors=True,\n    )\n\nif doc.parsed:\n    print(\"API response is valid.\")\n    print(doc.parsed)\nelse:\n    print(\"API response is invalid.\")\n    print(doc.data)  # The raw JSON response is still available\n```\n\n## Samples\n\nSamples for all operations using the client can be [found here.](./docs/samples_python.md)\n\n## API reference\n\n-   [API operations can be found here](./docs/sync_operations.md)\n-   [API models and objects](./docs/models.md)\n-   [Exceptions](./docs/exceptions.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faffinda%2Faffinda-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faffinda%2Faffinda-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faffinda%2Faffinda-python/lists"}