diff --git a/README.md b/README.md index 9f93c50..5c93e5b 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,22 @@ with Actual( print(t.date, account_name, t.notes, t.amount, category) ``` +The `file` will be matched to either one of the following: + +- The name of the budget, found top the top left cornet +- The ID of the budget, a UUID that is only available if you inspect the result of the method `list_user_files` +- The Sync ID of the budget, a UUID available on the frontend on the "Advanced options" +- If none of those options work for you, you can search for the file manually with `list_user_files` and provide the +object directly: + +```python +from actual import Actual + +with Actual("http://localhost:5006", password="mypass") as actual: + actual.set_file(actual.list_user_files().data[0]) + actual.download_budget() +``` + ## Adding new transactions After you created your first budget (or when updating an existing budget), you can add new transactions by adding them diff --git a/actual/__init__.py b/actual/__init__.py index 385059e..3ae112c 100644 --- a/actual/__init__.py +++ b/actual/__init__.py @@ -103,8 +103,11 @@ def session(self) -> Session: return self._session def set_file(self, file_id: Union[str, RemoteFileListDTO]) -> RemoteFileListDTO: - """Sets the file id for the class for further requests. The file_id argument can be either a name or remote - id from the file. If the name is provided, only the first match is taken.""" + """ + Sets the file id for the class for further requests. The file_id argument can be either the name, the remote + id or the group id (also known as sync_id) from the file. If there are duplicates for the name, this method + will raise `UnknownFileId`. + """ if isinstance(file_id, RemoteFileListDTO): self._file = file_id return file_id @@ -112,7 +115,7 @@ def set_file(self, file_id: Union[str, RemoteFileListDTO]) -> RemoteFileListDTO: selected_files = [] user_files = self.list_user_files() for file in user_files.data: - if (file.file_id == file_id or file.name == file_id) and file.deleted == 0: + if (file.file_id == file_id or file.name == file_id or file.group_id == file_id) and file.deleted == 0: selected_files.append(file) if len(selected_files) == 0: raise UnknownFileId(f"Could not find a file id or identifier '{file_id}'")