Package: affinda
Python Client Library for Affinda Document Parser APIThis is a python client for the Affinda document parsing API which wraps all available endpoints
and handles authentication and signing. You may also want to refer to the fullAPI documentationfor additional information.InstallationpipinstallaffindaAPI Version CompatibilityThe Affinda API is currently onv3, with breaking changes meant the release of new versions of the client library.
Please see below for which versions are compatible with which API version.Affinda API versionaffinda-pythonversionsv20.1.0 - 3.x.xv3>= 4.x.xQuickstartIf you don't have an API token, obtain one fromaffinda.com.frompathlibimportPathfrompprintimportpprintfromaffindaimportAffindaAPI,TokenCredentialfromaffinda.modelsimportWorkspaceCreate,CollectionCreatetoken="REPLACE_API_TOKEN"file_pth=Path("PATH_TO_DOCUMENT.pdf")credential=TokenCredential(token=token)client=AffindaAPI(credential=credential)# First get the organisation, by default your first one will have free creditsmy_organisation=client.get_all_organizations()[0]# And within that organisation, create a workspace, for example for Recruitment:workspace_body=WorkspaceCreate(organization=my_organisation.identifier,name="My Workspace",)recruitment_workspace=client.create_workspace(body=workspace_body)# Finally, create a collection that will contain our uploaded documents, for example resumes, by selecting the# appropriate extractorcollection_body=CollectionCreate(name="Resumes",workspace=recruitment_workspace.identifier,extractor="resume")resume_collection=client.create_collection(collection_body)# Now we can upload a resume for parsingwithopen(file_pth,"rb")asf:resume=client.create_document(file=f,file_name=file_pth.name,collection=resume_collection.identifier)pprint(resume.as_dict())SamplesSamples for all operations using the client can befound here.API referenceAPI operations can be found hereAPI models and objectsExceptionsChangelogAll notable changes to this project will be documented in this file.The format is based onKeep a Changelog,
and this project adheres toSemantic Versioning.[Unreleased][4.18.0] - 2024-01-31AddedAdd sourceEmailAddress to DocumentMeta modelAdd tablesBeta to InvoiceData modelAdd sourceEmailAddress to document meta[4.17.0] - 2024-01-16AddedAdded "website" data point typeAdd mapping and dataSource to the field endpointsAdd list mapping data sources endpointRemovedRemoved "cell" data point typeChangedAdd URL annotation type[4.16.0] - 2023-12-04AddedAdd data mappingAdd dropNullEnums to FieldAdded AnnotationContentTypeAdded show_custom_field_creation to OrganizationIntroduce endpoints to deal with data sources that can be created by customers, and used to map data onto a picklist, or lookup values for downstream validation[4.15.0] - 2023-11-14AddedAdd PATCH /index/ endpointAdd user to Index objectAdd "compact" query parameter to GET /documents/ endpointAdd "compact" query parameter to POST /documents endpoint[4.14.0] - 2023-11-08AddedAddparentfield toAnnotationFixedMakeAnnotation.rectanglesfield non-nullableMakeAnnotation.documentfield requiredChangedRemove enum constraint fromorderingon thegetAllDocumentsoperation[4.13.0] - 2023-10-24AddedAdd display_enum_value config to Collection field configChangedMigrate display_enum_value from DataPoint to Collection field configRemovedRemove display_enum_value from DataPoint[4.12.0] - 2023-10-19AddedAdd disableEditDocumentMetadata option to validation tool configAdd field custom_identifier to DocumentMeta modelAllow specifying custom_identifier when create/update documentDeprecatedDeprecate writing to identifier when creating/updating document[4.11.0] - 2023-10-03AddedAdd SOC group codes to classification[4.10.0] - 2023-09-21AddedAllow creating workspace-scope webhookAdd "document.rejected" webhook event[4.9.0] - 2023-07-26AddedAllow create and enable/disable child fields in Collection.fieldsLayoutDeprecatedDeprecatefieldsin favor ofenabledChildFieldsanddisabledChildFieldsin Collection.fieldsLayout[4.8.1] - 2023-07-19FixedSerialisation of Document to Invoice, Resume etc in async get_document()[4.8.0] - 2023-07-19ChangedMake Field.slug nullable and not requiredDeprecatedDeprecate Field.slugAddedSupport for custom base URL and http scheme in async client[4.7.2] - 2023-07-07ChangedSet CustomFieldConfig default to 0.5FixedFixed serialisation of Document to Invoice, Resume etc in get_document()[4.7.1] - 2023-06-28AddedAdd xml response to api spec to GET /v3/documenets to match existing functionality[4.7.0] - 2023-06-27AddedAllow create/update data point'sparentanddisplayEnumValuepropertyAllow explicitly set a document as low_priorityChangedMakeslugandorganizationrequired when creating data pointRemovedRemove data point'ssimilarToproperty[4.6.0] - 2023-06-16AddedAddtailoredExtractorRequestedto CollectionAdd endpoint for update resumes and JD data[4.5.1] - 2023-06-14AddedAddrawTextto invoice data[4.5.0] - 2023-06-09AddedAbility to post/patch languages for resumes in v2Addinclude_publicparameter to /data_points endpointAddbase_extractorparameter to collection creation endpointChangedMakeextractora non required field (internal use)[4.4.0] - 2023-06-07AddedEndpoints for add/remove tag for documentsIdentifier field in DocumentUpdate modelAllow settingregion_biaswhen uploading documentrawText field to JobDescription ModelRequired fields for resthook subscriptionsAddfieldsLayouttoCollectionschemaDeprecatedDeprecateCollection.fieldsin favor ofCollection.fieldsLayout[4.3.5] - 2023-05-09ChangedNest line item table rows correctly.[4.3.4] - 2023-05-09ChangedNest line item table rows correctly.[4.3.3] - 2023-05-09AddedAddOrganization.validationToolConfigfor configuration of the embeddable validation toolPhone number details to Resume Candidate infoAdd some filters toGET /documentsendpoint:failed,ready,validatableCustom fields to Job DescriptionsAdd custom data to job description search resultsAdd international_country_code to phone number detailsChangedProvide additional filters for data point choices, and allow data point choices to be specified for any existing text field.Allow custom resume fields to be nullableAllow custom job description fields to be nullableMake "pdf" property in SearchResults nullableRemovedRemoveinclude_childfilter from/data_pointsendpointFixedUpdate python_requires to be PEP compliant[4.3.2] - 2023-04-20ChangedrawText is now not nullableOccupationGroupSearchResult.children is now optionalFixedAllow rejectDuplicates to be null[4.3.1] - 2023-03-29AddedAddwhitelistIngestAddressesto WorkspaceFixedMake search config action fields required[4.3.0] - 2023-03-28AddedAdding group annotation content typeAdd rejectDuplicates setting to workspaceAddhideToolbarto resume & JD search configAdd ExtractorConfig object to Collection[4.2.0] - 2023-03-20Fixedfixed - Use OccupationGroupResult for v3 SearchAndMatch detailFixed return type for InvoiceData.currencyCodeChangedDon't require Field.slugAddedAdd redactedText field to ResumeData[4.1.0] - 2023-03-15FixedFixed type and path of data_point and data_point_choicesFixed missing data field on base Document typeFixed search and match return typesfixed document error return typesEnsure list endpoints have 'results' and 'count' properties requiredChangedMinor re-ordering of API spec pathsChange Document API tag from Document API - Upload Documents to Document API - Document[4.0.1] - 2023-03-10FixedFixed resume search response object[4.0.0] - 2023-03-09AddedAdd resthook subscription endpointsAdd py.typed marker fileAdd link to affinda help docs for resthook creationChangedRemove extractor'sidfield, useidentifierfield insteadRemovedRemove extractor'sidfieldRemoved v2 endpoints[2.1.0] - 2023-02-06AddedAdd document.collection.extractor.identifier to DocumentMetaAdd cell to valid content typesAdd EU API server to api docsAdd latitude and longtitude to LocationAdd expectedremuneration, jobtitle, language, skill and yearsexperience to AnnotationContentTypere-add DataPoint.simlarToAddexcludeparameter to /documents queryadd ingest email to Workspace and CollectionChangedUpdated endpoints for old v2 and newer v3 to point to the correct places.Changed Document top level structure to more closely resemble api v2 with top level keys of meta, data and errorResumeSearchParamaters.resume, ResumeSearchParameters.jobdescription, JobDescriptionSearchParameters.resume, DataPoint.organizationUpdate azure-core version in setup.cfg and pin setuptools as latest version doens't buldFixedFixed various nullable fields not being nullable, and vice versaRemovedMaster/child accounts endpoints[2.0.0] - 2023-01-13AddedAdded endpoints: Organization, Membership, Invitation, tagsAdded name, organization to DataPoint, change id to identifierAdd new objects schemas Organization, OrganizationMembership, InvitationChangedIdentifier instead of id as URL paramUpdate data point filtersAllow unlimited nesting in field configChange document state from "export" to "archive"FixedCollection identifier should be nullableDon't paginate extractors endpointFix avatar uploadsAllow writing resthookSignatureKey[1.9.0] - 2023-01-12Yanked as this was a breaking release, see newer release for more info[1.8.0] - 2023-01-12ChangedAllow non TLS http requests[1.7.0] - 2023-01-10AddedAdd rectangles to Annotation, add position to referee, add actions to JobDescriptionSearchConfig[1.6.0] - 2023-01-09FixedBump version to force new release[1.5.1] - 2023-01-08ChangedAllowing a few more fields in ResumeData to be null[1.5.0] - 2022-11-17FixedDocument meta pages without images should be nullableSmall fixes for accreditiation and education return objectsVarious nullable fields in the API specSecurityBumped package versions for patch reasonsAddedAdd reject_duplicates to document upload endpointXML 404 response schemaCustomData to resume search specsuggest skills and job titles endpointsChangedUpdate spec to allow XML content-type return from resumes, make totalYearsExperience nullableAllow additonalproperties for custom data upload (resumes) and search[1.4.2] - 2022-09-23ChangedUpdate API spec to match API response.[1.4.1] - 2022-09-23AddedAdd job description search config and embed endpointsUpdate index endpoint with document type parameterFixedFix casing of some properties to match API response.[1.4.0] - 2022-08-25ChangedUpdate modelerfour version to latestUpdate types of objects for some endpoints using AllOf attributes for better client library generationChanged and updated tag order to better match documentation needsUpdated autorest client versionDeprecatedDepreciated resume_formats and reformatted_resumes endpointsAddedReverse match functionality - search job descriptions with a resume, or with a set of parameters.[1.3.1] - 2022-08-10AddedAdd search expression to 1v1 match[1.3.0] - 2022-07-27AddedAdd ability to find other candidates that have similar attributes to a resumeAdd an endpoint to get the matching score between a resume and a job description[1.2.0] - 2022-07-04Addedadd "tables" property to InvoiceData[1.1.0] - 2022-07-03AddedAbility to update resume data in the search systemNew endpoint for creating and managing users within a master account[1.0.2] - 2022-05-07FixedMake expiry time native date time[1.0.1] - 2022-05-01AddedAdd review URL in the invoice response that allows embedding of the Affinda Invoice Review UI[1.0.0] - 2022-04-28Addedadded confidenceChangedchanged strings to objects[0.4.1] - 2022-04-19FixedFixes bug in create_invoice when URL is not specified[0.4.0] - 2022-04-13ChangedUpdate autorest depedencies[0.3.0] - 2022-04-06AddedResume search[0.2.2] - 2022-03-25AddedAdd iso 3166 country code to locations[0.2.1] - 2021-12-09AddedBump version[0.2.0] - 2021-10-06AddedInvoices endpointRemovedRemoved 'url' format from url strings in api spec[0.1.13] - 2021-10-05ChangedPin azure-core to 1.18.0[0.1.12] - 2021-10-05ChangedPin azure-core[0.1.11] - 2021-10-05ChangedPinning azure-core dependency due to incompatible changes in 1.19[0.1.10] - 2021-09-30AddedAdding LinkedIn to ResumeDataChangedReformatted code with blackMinor changesVery minor formatting changes[0.1.9] - 2021-09-08AddedProfession in ResumeData modelUnified Error models[0.1.8] - 2021-09-06Fixedwait=true in API spec[0.1.7] - 2021-09-05FixedCode samples naming conversion[0.1.6] - 2021-09-05ChangedDescription of some endpoints to match updats in API specMoved samples to their own./docs/samples_python.mdfile[0.1.5] - 2021-08-25AddedAdded flake, editorconfig, tox.ini etc files to match best practices for existing Draftable/Affinda projects (thanks@ralish!)[0.1.4] - 2021-08-18FixedUpdate README.md to fix install instructions[0.1.3] - 2021-08-18FixedUpdate README.md to hard link to github hosted logo to fix display on PyPi[0.1.2] - 2021-08-18Initial releaseThe MIT License (MIT)Copyright (c) AffindaPermission 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.