medium-api-npm
v2.0.0
Published
Get all your medium articles and display in your website or create an article and post it from your website and many more awesome stuff
Downloads
7
Maintainers
Readme
medium-api-npm
Get your medium articles and display in your website or write an article and post it from your website.
0. To get auth-code:
Go to your medium account -> profile icon -> settings -> integration tokens -> generate token
1. To fetch user data, posts, publications from medium:
const { getMediumArticles } = require("medium-api-npm");
getMediumArticles({
auth: "auth-code",
}).then((data) => console.log(data));
2. To add a post to medium:
const { addPost } = require("medium-api-npm");
addPost({
auth: "auth-code",
title: "test",
html: "<p>test</p>",
canonicalUrl: "https://medium.com/@test",
tags: ["test"],
publishStatus: "draft",
}).then((data) => console.log(data));
| Parameter | Type | Required? | Description |
| ------------- |--------------|------------|-------------------------------------------------|
| title | string | required | The title of the post. Note that this title is used for SEO and when rendering the post as a listing, but will not appear in the actual post—for that, the title must be specified in the content
field as well. Titles longer than 100 characters will be ignored. In that case, a title will be synthesized from the first content in the post when it is published. |
| contentFormat | string | required | The format of the "content" field. There are two valid values, "html", and "markdown" |
| content | string | required | The body of the post, in a valid, semantic, HTML fragment, or Markdown. Further markups may be supported in the future. For a full list of accepted HTML tags, see here. If you want your title to appear on the post page, you must also include it as part of the post content. |
| tags | string array | optional | Tags to classify the post. Only the first three will be used. Tags longer than 25 characters will be ignored. |
| canonicalUrl | string | optional | The original home of this content, if it was originally published elsewhere. |
| publishStatus | enum | optional | The status of the post. Valid values are “public”, “draft”, or “unlisted”. The default is “public”. |
| license | enum | optional | The license of the post. Valid values are “all-rights-reserved”, “cc-40-by”, “cc-40-by-sa”, “cc-40-by-nd”, “cc-40-by-nc”, “cc-40-by-nc-nd”, “cc-40-by-nc-sa”, “cc-40-zero”, “public-domain”. The default is “all-rights-reserved”. |
| notifyFollowers | bool | optional | Whether to notifyFollowers that the user has published. |