A Node.js package for interacting with the dev.to API to retrieve and post blog articles.
npm install @arindam1729/devtoblog
const { getBlog, postBlog } = require('@arindam1729/devtoblog');
// Retrieve a list of published blog articles
const apiKey = 'YOUR_API_KEY';
getBlog(apiKey)
.then((articles) => {
console.log(articles);
})
.catch((error) => {
console.error(error);
});
// Post a blog article
const article: {
body_markdown: "### content for the body markdown. It can contain various details, sections, and formatting like headers, lists, and more.",
description: "A brief overviecontent and its purpose",
published: true,
title: "Publishing Article on DevTo | by Arindam",
canonical_url: "https://arindam1729.hashnode.dev",
tags: ["DevTo", "Arindam", "Test","Blog"]
}
postBlog(article, apiKey)
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Retrieves a list of published blog articles from the dev.to API.
-
apiKey
- The API key required to access the dev.to API.
Returns a promise that resolves to an array of blog articles.
Posts a blog article to the dev.to API.
-
article
- The article object to be posted. -
apiKey
- The API key required to access the dev.to API.
Returns a promise that resolves to the response data from the API.
This project is licensed under the MIT License - see the LICENSE file for details.