How to get author information from Medium.com posts
Given a JSON payload that resembles this:
{
"payload": {
"posts": [
{
"creatorId": "foobar",
"title": "How to foo your bars"
}
],
"references": {
"User": {
"foobar": {
"userId": "foobar",
"name": "Senor Foobar",
"imageId": "baz.jpg"
}
}
}
}
}
creatorId
for the message also exists in references
User
. In this example, I used id foobar
. With this key, you can get the author name and file name for the author's photo.
Translating the file name of the author's photo into a URL may require additional work. Current CDN https://cdn-images-1.medium.com/fit/c/60/60/
, so the full url will be https://cdn-images-1.medium.com/fit/c/60/60/foobar.jpg
. This CDN is likely to change over time, so this URL is not absolute.
CDN information is not available in the JSON payload and was found by checking the source for the sample average article.
source to share