Programmatically syncing

Hello Everyone!

I’m a geek. I want to programmatically change a field in my Anki db and sync it.

I know how to load a collection:

from anki.collection import Collection
collection = Collection(collection_path)

And I know how to edit a collection:

new_note = collection.get_note(1699500453684)
new_note.__setitem__('Target', 'new value')

This also works:

auth_key = collection.sync_login('user', 'password', 'https://self-hosted-dot-com')

However, when I try to sync:

collection.sync_collection(auth_key, sync_media=False)

It defaults to synching with ankiweb-dot-net (I can’t create links on this forum)

I have searched and searched and searched, and I can’t find where the sync server URL is stored / loaded. The rust backend (I think) is the part that confuses me.

So close, but so far.

the SyncAuth returned by sync_login() includes the endpoint you provide. You should be able to confirm this by printing the value returned from sync_login(). Make sure you’re using the latest Anki version.

Whoop whoop!
Upgrading to the latest version of Anki helped.

Thank you :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.