Medium REST API Example Calls with Python Requests
--
A tutorial showing how to get an integration token, set headers, and retrieve and post data from the Medium REST API.
Author’s Note
Up front, I’m the reason this repo was archived. I’d almost finished this post when I emailed the Medium customer support team and asked for clarification on the repo.
And, uh…
The repo was archived before I finished the last available endpoint in the API, /images. I don’t know if these endpoints are still available, and I don’t know if that last endpoint would even work. (I do remember being able to upload images and search for them based on file name.) Regardless, I didn’t include it in the post here.
I’m still posting this because I feel like it’s a good resource for folks looking to do simple Medium automation, but be warned. Thar be unmaintained dragons.
Medium has a REST API! Documentation exists online on GitHub here.
The documentation hasn’t been updated since September 2020, though, so it may have been abandoned. In the meantime, I was curious about what endpoints still work. Let’s explore!
Prerequisites:
- Medium account
- Python3
- requests (Python library)
Auth with Integration/Access Token
According to the documentation, all calls to their API resources require OAuth2 authentication. There are two ways to accomplish this: create an integration token for your account, or retrieve an access token for existing integrations. The first option is significantly easier, especially since I don’t have any third parties associated with my account, so I’ll walk through how to do that.
First, navigate to https://www.medium.com/me/settings. You can do this either through entering that directly in your search bar, or when logged in you can click on your icon in the top right corner of the screen. Click the Settings link in the drop down menu.