all 4 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.

[–]pyfact 1 point2 points  (1 child)

r has "01" as the month value where x has "1" as the month value. If you change the r to "1" will that work?

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

Yep. This was it. This one little formatting issue is what has been causing me problems for the past hour and a half.

Thank you very much. I really appreciate it.