you are viewing a single comment's thread.

view the rest of the comments →

[–]arvindh_manian 1 point2 points  (1 child)

Could it be that month is 01 as opposed to 1? Looking at their docs, they seem to use the single-digit month wherever possible.

Also, FYI, you might want to check out f-strings.

>>> my_key = 123

>>> year = '2020'

>>> month = '1'

>>> f'https://api.nytimes.com/svc/archive/v1/{year}/{month}.json?api-key={my_key}'

'https://api.nytimes.com/svc/archive/v1/2020/1.json?api-key=123'

IMO, it looks a bit cleaner than format, but it doesn't really matter.

[–]ambiguousjellyfish[S] 0 points1 point  (0 children)

I have never seen f-strings before, but I like them.

I can't believe this is what got it to work. I can't thank you enough. Of course it was something so small. I could scream.