Testing out the Buttondown API

We should be able to fairly easily list subscribers with the button down API.

I'm going to try to use the requests API, as a sanity check, to see that I'm using the correct token and headers, as part of my work to replace the CAT import andnewsletter tooling with buttondown.

! pip install httpx
5.3s
import os
secret_token = os.getenv("BUTTONDOWN_TOKEN")
0.0s

OK, now we have our token, lets import our HTTP client

import httpx
0.4s

And set our header that we want to send along

headers = {"Authorization": f"Token {secret_token}"}
0.0s

This returns a json list of our subscribers

httpx.get("https://api.buttondown.email/v1/subscribers", headers=headers)
1.1s

And we can see the info about specific subscribers too:

httpx.get("https://api.buttondown.email/v1/subscribers/81254e3a-80cc-40b1-a363-5905a640a168", headers=headers).json()
0.7s

We should be able to update them with patch or put.

httpx.patch("https://api.buttondown.email/v1/subscribers/81254e3a-80cc-40b1-a363-5905a640a168", headers=headers, json={'subscriber_type': "regular"}).json()
1.0s

... hmm, looks like I'm patching it wrong.

Runtimes (1)