Giter VIP home page Giter VIP logo

hashnode-sdk-js's Introduction

๐Ÿ“ฆ hashnode-sdk-js

npm version GitHub license

Hashnode SDK for JavaScript/TypeScript (unofficial).

What is this?

This is a library for working with Hashnode programmatically in JavaScript/TypeScript, it's built around Hashnode API.

Key concepts

  • Opinionated, has its own interfaces focusing on common blogging features, e.g. CRUD articles, comments, etc (what you usually do on Hashnode).

  • Abstracts away Hashnode API, which is currently in alpha and subject to breaking changes. Whereas, this SDK's API is considerably stable, its API won't change without a major release. As soon as Hashnode API changes, it will be updated to keep its API remain unchanged and function correctly.

  • Not flexible by design, you can't query less or more fields, these use cases are covered by Hashnode GraphQL API.

How & why?

I (@phuctm97) is actively using this SDK in my website to implement an auto-crosspost workflow, which runs daily. Hence, as soon as something breaks, I'll recognize and fix as soon as possible. Check out this workflow run to see how it is used in practice.

Usage

Install

yarn add hashnode-sdk-js

API

Configure API key

Go to Hashnode account settings, create an API key and set it as environment variable HASHNODE_API_KEY at where you run your application, the SDK will automatically use it.

Find a user by username

import hashnode from "hashnode-sdk-js";

hashnode.findUser("phuctm97").then((data) => console.log(data));
{
  id: '5fa3f68b47631a19e811f076',
  username: 'phuctm97',
  name: 'Minh-Phuc Tran',
  tagline: 'Engineer ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป. Building open-source tools and tutorials โžก๏ธ twitter.com/phuctm97',
  publication: {
    id: '5fa565080163314ab6d7deab',
    name: "Minh-Phuc Tran's Blog",
    domain: 'blog.phuctm97.com'
  }
}

Other examples

See examples.

Types

export type Publication = {
  id: string;
  name: string;
  domain: string;
};

export type User = {
  id: string;
  username: string;
  name: string;
  tagline: string;
  publication: Publication;
};

export type Article = {
  id: string;
  title: string;
  slug: string;
  url: string;
  canonicalURL?: string;
  contentMarkdown: string;
};

Features

  • Find user.

  • Get a user's publication.

  • Create an article in a publication.

  • Update an article in a publication.

  • Delete an article.

  • Get feed.

  • ... (contributions are welcome)


Made by @phuctm97.

hashnode-sdk-js's People

Contributors

phuctm97 avatar dependabot[bot] avatar t-rekttt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.