Overriding Outdated Headers#
You may sometimes encounter issues where the TickTick API returns a 429, similar to sebpretzer/pyticktick#226 or lazeroffmichael/ticktick-py#53. The standard use case for 429 codes is that you are being rate limited. But TickTick also returns a 429 due to outdated headers that are no longer valid.
To work around this, you can override the headers sent by setting the v2_user_agent and v2_x_device settings. For example:
from pyticktick import Client
client = Client(
v2_user_agent="Mozilla/5.0 (rv:145.0) Firefox/145.0",
v2_x_device={
"platform": "web",
"version": 8000,
"id": "694241d132d12fcc26e7a4d8",
},
)
Where do I find valid values for these headers?
In order to find valid values for these headers, you can inspect the network requests made by the TickTick app in your browser's developer tools. Look for requests to https://api.ticktick.com and check the User-Agent and X-Device headers.
Not all values that are specified in your browser's request are required. The following is usually sufficient:
User-Agent: A string that identifies the browser version (e.g.,Mozilla/5.0 (rv:145.0) Firefox/145.0).X-Device: A JSON string with at least theplatform,version, andidfields (e.g.,{"platform":"web", "version":8000, "id":"694241d132d12fcc26e7a4d8"}), whereidis a MongoDB ObjectId-like string.