Skip to content

Instantly share code, notes, and snippets.

@pH-7
Last active October 20, 2025 22:14
Show Gist options
  • Select an option

  • Save pH-7/aad78d9ae7bb51044a84f616f5aa3301 to your computer and use it in GitHub Desktop.

Select an option

Save pH-7/aad78d9ae7bb51044a84f616f5aa3301 to your computer and use it in GitHub Desktop.
get-medium-publication-ids.sh - https://PierreHenry.dev
# First, set your Medium API token (from https://medium.com/me/settings/security if you do have one)
TOKEN="your-medium-token"
# 1. Get user ID
echo "Getting user ID..."
USER_INFO=$(curl -X GET "https://api.medium.com/v1/me" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Accept-Charset: utf-8")
# Extract user ID using jq (if installed)
USER_ID=$(echo $USER_INFO | jq -r '.data.id')
echo "User ID: $USER_ID"
# 2. Get user's publications
echo "Getting publications..."
curl -X GET "https://api.medium.com/v1/users/$USER_ID/publications" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Accept-Charset: utf-8"
@pH-7
Copy link
Author

pH-7 commented Sep 2, 2025

What you need to do is to replace your-medium-token by your Medium API token. You can find yours at "Integration tokens" in Settings -> Security and apps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment