Publish R Markdown to Medium via An RStudio Addin

October 26, 2017 by Hiroaki Yutani

I created an experimental package to work with Medium API.

mediumr: https://github.com/yutannihilation/mediumr/

mediumr allows you to knit and post R Markdown to Medium.

Installation

You can install mediumr from github with:

devtools::install_github("yutannihilation/mediumr")

Authentication

Medium API requires a self-issued API token. (While they provide OAuth method, it’s hard for R users to use it since localhost is not allowed to specify in the callback URL.) Please issue a token in “Integration tokens” section of settings and set it as a environmental variable MEDIUM_API_TOKEN. If you use .Renviron, add this line:

MEDIUM_API_TOKEN='<your api token here>'

Usage

The usage is quite simple. Focus on the Rmd file that you want to publish and choose “Post to Medium” from Addins menu (Or, you can execute mediumr::medium_create_post_from_Rmd("path/to/file.Rmd") in your console.):

The addin knits the Rmd and shows the preview dialog. If it looks ok, click “Publish”:

After successfully uploading the content to Medium, the addin launches a web browser and jumps to the post:

Other usages

mediumr also provides simple bindings for Medium API. Please, read the “Usage” section of the README.

Contribution

If you find any problems, please let me know on GitHub, Twitter, or comment here!