WK API Timestamp

Just curious who is familiar with the WK API and if you know how they generate timestamps. I was able to create reviews earlier using my current timestamp in their format, but now trying to send the same requests is giving me a 422 with the following explanation: {‘error’: ‘created_at must be in the acceptable time range’, ‘code’: 422}

The interesting thing is that I can submit those reviews through the website or through other apps so I’m guessing it’s most likely an issue with my timestamp (crazy assumption I know). If you want a million brownie points maybe you could tell me how to generate the correct timestamp in Python.


1 Like

Sounds like the timestamp itself is valid, in ISO format? Are you making sure that the date is after the assignment’s available_at date?

It seems like it’s after the assignments available at date yeah, I’ll try it again later after the review period has elapsed I’m just getting some strange behavior.

Did you do any time zone conversion or did you generate it in UTC time directly? If the time zone specifier is off somehow you might accidentally end up generating time points in the future.

Do you have an example of a timestamp your current script generates (preferably with the actual time with it)? That way we can compare it a bit more easily.

1 Like

assigned_at: 2021-02-18 21:00:00+00:00
my generated timestamp: 2021-02-19T11:03:57.378784
<Response [201]>
{‘id’: 1690313652, ‘object’: ‘review’, ‘url’: ‘https://api.wanikani.com/v2/reviews/1690313652’, ‘data_updated_at’: ‘2021-02-19T18:03:57.708250Z’, ‘data’: {‘created_at’: ‘2021-02-19T11:03:57.378784Z’, ‘assignment_id’: 221729231, ‘subject_id’: 8760, ‘spaced_repetition_system_id’: 1, ‘starting_srs_stage’: 2, ‘ending_srs_stage’: 3, ‘incorrect_meaning_answers’: 0, ‘incorrect_reading_answers’: 0}, ‘resources_updated’: {‘assignment’: {‘id’: 221729231, ‘object’: ‘assignment’, ‘url’: ‘https://api.wanikani.com/v2/assignments/221729231’, ‘data_updated_at’: ‘2021-02-19T18:03:57.701351Z’, ‘data’: {‘created_at’: ‘2021-02-12T01:55:15.812977Z’, ‘subject_id’: 8760, ‘subject_type’: ‘vocabulary’, ‘srs_stage’: 3, ‘unlocked_at’: ‘2021-02-12T01:55:15.800450Z’, ‘started_at’: ‘2021-02-12T17:15:16.823969Z’, ‘passed_at’: None, ‘burned_at’: None, ‘available_at’: ‘2021-02-20T10:00:00.000000Z’, ‘resurrected_at’: None, ‘hidden’: False}}, ‘review_statistic’: {‘id’: 207461349, ‘object’: ‘review_statistic’, ‘url’: ‘https://api.wanikani.com/v2/review_statistics/207461349’, ‘data_updated_at’: ‘2021-02-19T18:03:57.717974Z’, ‘data’: {‘created_at’: ‘2021-02-12T17:15:16.849102Z’, ‘subject_id’: 8760, ‘subject_type’: ‘vocabulary’, ‘meaning_correct’: 5, ‘meaning_incorrect’: 3, ‘meaning_max_streak’: 3, ‘meaning_current_streak’: 3, ‘reading_correct’: 5, ‘reading_incorrect’: 3, ‘reading_max_streak’: 4, ‘reading_current_streak’: 4, ‘percentage_correct’: 63, ‘hidden’: False}}}}

The response you sent looks like a response the API would give you if you successfully create a review. I’m more curious as to what your request was when you got the error.

yeah like I said I sent the failed request with the same exact format after the review became available that had been reviewed with my previous API request, that’s why I was a little confused.

The only thing I can really see from your timestamp is that you’re missing the zone identifier at the end. It’s a bit hard to tell what caused the call to fail though. If you get the error again see if you can log the exact request, it’s hard to tell what went wrong this time.

Just got the error again,

available_at: 2021-02-19 21:00:00+00:00
my generated timecode and actual time: 2021-02-19T14:03:49.866335
<Response [422]>
{‘error’: ‘created_at must be in the acceptable time range’, ‘code’: 422}

The reviews are available right now though.

Actually I got it, turns out it was the time zone, appended my time zone gave me a 201. Thanks for your help!

1 Like

Is there a timezone issue? If I go with the timestamps assuming they are in the same timezones your timecode is earlier than the avalable_at timestamp.

Yep it was the timezone.

1 Like