Module crowdin_api.api_resources.source_files.resource
Classes
class SourceFilesResource (requester: APIRequester, project_id: Optional[int] = None, page_size=25)-
Resource for Source Files.
Source files are resources for translation. You can keep files structure using folders or manage different versions of the content via branches.
Use API to keep the source files up to date, check on file revisions, and manage project branches. Before adding source files to the project, upload each file to the Storage first.
Note: If you use branches, make sure your master branch is the first one you integrate with Crowdin.
Link to documentation: https://support.crowdin.com/developer/api/v2/#tag/Source-Files
Ancestors
Methods
def add_asset_reference(self, project_id: int, file_id: int, storage_id: int, name: str)-
Add Asset Reference.
Link to documentation: https://support.crowdin.com/developer/api/v2/#tag/Source-Files/operation/api.projects.files.references.post
def add_branch(self, name: str, projectId: Optional[int] = None, title: Optional[str] = None, exportPattern: Optional[str] = None, priority: Optional[Priority] = None, isProtected: Optional[bool] = None)-
Add Branch.
exportPatternandpriorityare for file-based projects only,isProtectedis for string-based projects only.Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.branches.post
def add_directory(self, name: str, projectId: Optional[int] = None, branchId: Optional[int] = None, directoryId: Optional[int] = None, title: Optional[str] = None, exportPattern: Optional[str] = None, priority: Optional[Priority] = None)-
Add Directory.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.directories.post
def add_file(self, storageId: int, name: str, projectId: Optional[int] = None, branchId: Optional[int] = None, directoryId: Optional[int] = None, title: Optional[str] = None, context: Optional[str] = None, type: Optional[FileType] = FileType.AUTO, importOptions: Union[SpreadsheetImportOptions, XmlImportOptions, WebXmlFileImportOptions, DocxFileImportOptions, VsdxFileImportOptions, IdmlFileImportOptions, HtmlFileImportOptions, HtmlWithFrontMatterFileImportOptions, MdFileImportOptions, MdxV1FileImportOptions, MdxV2FileImportOptions, StringCatalogFileImportOptions, AdocFileImportOptions, VdfFileImportOptions, OtherImportOptions, None] = None, exportOptions: Union[GeneralExportOptions, PropertyExportOptions, JavascriptExportOptions, MdFileExportOptions, MdxFileExportOptions, DocxFileExportOptions, None] = None, excludedTargetLanguages: Optional[Iterable[str]] = None, attachLabelIds: Optional[Iterable[int]] = None, parserVersion: Optional[int] = None, fields: Optional[Dict[str, Union[str, int, bool, Iterable[str]]]] = None)-
Add File.
parserVersionmust be used together withtype.fieldsis Enterprise only.Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.post
def check_branch_deletion_status(self, branchId: int, jobIdentifier: str, projectId: Optional[int] = None)-
Check Branch Deletion Status.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.branches.jobs.get
def check_directory_deletion_status(self, directoryId: int, jobIdentifier: str, projectId: Optional[int] = None)-
Check Directory Deletion Status.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.directories.jobs.get
def check_file_deletion_status(self, fileId: int, jobIdentifier: str, projectId: Optional[int] = None)-
Check File Deletion Status.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.jobs.get
def delete_asset_reference(self, project_id: int, file_id: int, reference_id: int)-
Delete Asset Reference.
Link to documentation: https://support.crowdin.com/developer/api/v2/#tag/Source-Files/operation/api.projects.files.references.delete
def delete_branch(self, branchId: int, projectId: Optional[int] = None, prefer: Optional[str] = None)-
Delete Branch.
Pass
prefer="respond-async"to delete the branch asynchronously (recommended); the API then returns a job to poll viacheck_branch_deletion_status.Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.branches.delete
def delete_directory(self, directoryId: int, projectId: Optional[int] = None, prefer: Optional[str] = None)-
Delete Directory.
Pass
prefer="respond-async"to delete the directory asynchronously (recommended); the API then returns a job to poll viacheck_directory_deletion_status.Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.directories.delete
def delete_file(self, fileId: int, projectId: Optional[int] = None, prefer: Optional[str] = None)-
Delete File.
Pass
prefer="respond-async"to delete the file asynchronously (recommended); the API then returns a job to poll viacheck_file_deletion_status.Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.delete
def download_file(self, fileId: int, projectId: Optional[int] = None)-
Download File.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.download.get
def download_file_preview(self, fileId: int, projectId: Optional[int] = None)-
Download File Preview.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.preview.get
def edit_branch(self, branchId: int, data: Iterable[BranchPatchRequest], projectId: Optional[int] = None)-
Edit Branch.
/exportPatternis for file-based projects only,/isProtectedis for string-based projects only.Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.branches.patch
def edit_directory(self, directoryId: int, data: Iterable[DirectoryPatchRequest], projectId: Optional[int] = None)-
Edit Directory.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.directories.patch
def edit_file(self, fileId: int, data: Iterable[FilePatchRequest], projectId: Optional[int] = None)-
Edit File.
/fieldsand/fields/{fieldSlug}paths are Enterprise only. For/fields/{fieldSlug}pass the path as a string, e.g."/fields/some-field".Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.patch
def get_asset_reference(self, project_id: int, file_id: int, reference_id: int)-
Get Asset Reference.
Link to documentation: https://support.crowdin.com/developer/api/v2/#tag/Source-Files/operation/api.projects.files.references.get
def get_asset_references_path(self, project_id: int, file_id: int, reference_id: Optional[int] = None)def get_branch(self, branchId: int, projectId: Optional[int] = None)-
Get Branch.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.branches.get
def get_branch_path(self, projectId: int, branchId: Optional[int] = None)def get_directory(self, directoryId: int, projectId: Optional[int] = None)-
Get Directory.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.directories.get
def get_directory_path(self, projectId: int, directoryId: Optional[int] = None)def get_file(self, fileId: int, projectId: Optional[int] = None)-
Get File.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.get
def get_file_path(self, projectId: int, fileId: Optional[int] = None)def get_file_revision(self, fileId: int, revisionId: int, projectId: Optional[int] = None)-
Get File Revision.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.revisions.get
def get_file_revisions_path(self, projectId: int, fileId: int, revisionId: Optional[int] = None)def list_asset_references(self, project_id: int, file_id: int, limit: Optional[int] = None, offset: Optional[int] = None)-
List Asset References.
Link to documentation: https://support.crowdin.com/developer/api/v2/#tag/Source-Files/operation/api.projects.files.references.getMany
def list_directories(self, projectId: Optional[int] = None, orderBy: Optional[Sorting] = None, branchId: Optional[int] = None, directoryId: Optional[int] = None, filter: Optional[str] = None, recursion=None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)-
List Directories.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.directories.getMany
def list_file_revisions(self, fileId: int, projectId: Optional[int] = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)-
List File Revisions.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.revisions.getMany
def list_files(self, projectId: Optional[int] = None, orderBy: Optional[Sorting] = None, branchId: Optional[int] = None, directoryId: Optional[int] = None, filter: Optional[str] = None, recursion: Any = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)-
List Files.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.getMany
def list_project_branches(self, projectId: Optional[int] = None, orderBy: Optional[Sorting] = None, name: Optional[str] = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)-
List Branches.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.branches.getMany
def restore_file(self, fileId: int, revisionId: int, projectId: Optional[int] = None)-
Restore File.
Restore the file to one of the previous revisions.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.put
def search_branches(self, filter: str, projectIds: Optional[Iterable[int]] = None, userId: Optional[int] = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)-
Search Branches.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.branches.getMany https://support.crowdin.com/developer/enterprise/api/v2/#operation/api.branches.getMany
def search_directories(self, filter: str, projectIds: Optional[Iterable[int]] = None, userId: Optional[int] = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)-
Search Directories.
Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.directories.getMany https://support.crowdin.com/developer/enterprise/api/v2/#operation/api.directories.getMany
def search_files(self, filter: str, projectIds: Optional[Iterable[int]] = None, userId: Optional[int] = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)def update_file(self, fileId: int, storageId: int, projectId: Optional[int] = None, updateOption: Optional[FileUpdateOption] = None, importOptions: Union[SpreadsheetImportOptions, XmlImportOptions, WebXmlFileImportOptions, DocxFileImportOptions, VsdxFileImportOptions, IdmlFileImportOptions, HtmlFileImportOptions, HtmlWithFrontMatterFileImportOptions, MdFileImportOptions, MdxV1FileImportOptions, MdxV2FileImportOptions, StringCatalogFileImportOptions, AdocFileImportOptions, VdfFileImportOptions, OtherImportOptions, None] = None, exportOptions: Union[GeneralExportOptions, PropertyExportOptions, JavascriptExportOptions, MdFileExportOptions, MdxFileExportOptions, DocxFileExportOptions, None] = None, attachLabelIds: Optional[Iterable[int]] = None, detachLabelIds: Optional[Iterable[int]] = None, name: Optional[str] = None, replaceModifiedContext: Optional[bool] = None)-
Update File.
Replace the file with a new one from the Storage.
importOptionsis sent to the API as-is (e.g.{"importTranslations": True}for spreadsheet files). Note thatimportOptions.importTranslationsin the API response for spreadsheet files is marked as deprecated by the API and may not reflect the value sent in the request.Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.put