Sync all content from Medium with local folder via API
Export a single medium post to local
medup https://medium.com/notes-and-tips-in-full-stack-development/medup-backups-articles-8bf90179b094
Export all articles written by single author to special folder posts/miry
medium -u miry -d posts/miry
Export all articles recommended by miry
:
medium -u miry -d posts/recommendations -r
- Discover all articles from user account available in public
- Allow to download all recommended articles by user
- Download images used inside article
- Save posts in markdown format
- Convert a single article in markdown format
Install medup
tool to the MacOS or Linux via Hombrew:
$ brew tap miry/medup
$ brew install medup
Run export command for Medium author miry and save articles to local folder:
$ medup -u miry -d .
$ medup -d . https://medium.com/notes-and-tips-in-full-stack-development/medup-backups-articles-8bf90179b094
Docker way to make same job:
$ docker run -v <path to local articles folder>:/posts -it miry/medup -u <user>
Download all articles that user has recommended:
$ docker run -v <path to local articles folder>:/posts -it miry/medup -u <user> --recommended -d posts/recommended
Run dumping with source code
$ shards install
$ crystal run src/cli.cr -- -u <medium user> -d <destination folder>
Example download all posts from author https://medium.com/@miry to local folder posts/miry
$ crystal run src/cli.cr -- -u miry -d posts/miry
Build a application binary and execute:
$ shards install
$ rake build
$ _output/medup -u <medium user> -d <destination folder>
By default all articles destination folder is posts
.
In the directory, you can find 2 format of files: .json
and .md
.
- JSON format is the raw, what Medium returns.
- Markdown format is simple implementation of block formated text.
Images encoded in the result document.
IFRAME
content are located in posts/assets
.
Example of exported document (Original Medium post vs Exported Markdown):
- Fork it ( https://github.com/miry/medup/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- @miry Michael Nikitochkin - creator, maintainer
- @alexanderadam Alexander - supporter
This project is under the LGPL-3.0 license.
-
Generate token on the page https://medium.com/me/settings
-
Create environment variable
MEDIUM_TOKEN=<token>
-
Verify token with sample query:
$ curl -H "Authorization: Bearer <token>" https://api.medium.com/v1/me
{"data":{"id":"number","username":"miry","name":"Michael Nikitochkin","url":"https://medium.com/@miry","imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/0*KgbjgGnH-csHuB8j."}}
- Check public information not covered by API
$ curl "https://medium.com/@miry?format=json" | cut -c17- && : Remove in the front from response some strange JS code.
- Pagination
$ curl "https://medium.com/@miry/latest?format=json&limit=100" | cut -c17- && : Remove in the front from response some strange JS code.
- Post info
curl -s -H "Content-Type: application/json" https://medium.com/@miry/c35b40c499e\?format\=json\&limit\=100
- Stream
$ curl -s -H "Content-Type: application/json" "https://medium.com/_/api/users/fdf238948af6/profile/stream?source=overview" | cut -c17-
$ curl -s -H "Content-Type: application/json" "https://medium.com/_/api/users/fdf238948af6/profile/stream?limit=100&page=3" | cut -c17- > stream.json
$ cat stream.json| jq ".payload.references.Post[].title"
$ cat stream.json| jq ".payload.paging.next"
- Recommendations
$ curl -s -H "Content-Type: application/json" https://medium.com/@miry/has-recommended | cut -c17-
$ curl -s -H "Content-Type: application/json" "https://medium.com/_/api/users/fdf238948af6/profile/stream?source=has-recommended" | cut -c17-