npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dishistech/blogs-sdk

v1.0.4

Published

Official SDK for the blogs.dishis.tech API

Readme

DITBlogs API SDK - @dishistech/blogs-sdk

NPM Version License

Official, lightweight, and type-safe TypeScript SDK for the blogs.dishis.tech API.

This SDK provides a simple, promise-based interface to interact with all API endpoints. It can be used in any JavaScript or TypeScript environment, including Node.js backends, serverless functions, or even in the browser.

Features

  • Type-Safe: Fully written in TypeScript to provide excellent autocompletion and prevent common errors.
  • Lightweight: No external dependencies, keeping your project lean.
  • Promise-Based: Uses modern async/await syntax for clean, readable code.
  • Isomorphic: Works seamlessly in both Node.js and browser environments.
  • Comprehensive: Covers all available API endpoints.

Installation

npm install @dishistech/blogs-sdk
# or
yarn add @dishistech/blogs-sdk
# or
pnpm add @dishistech/blogs-sdk

Quick Start

Instantiate the client with your API key and start making requests.

import { DITBlogsClient } from '@dishistech/blogs-sdk';

// It's recommended to store your API key in environment variables
const client = new DITBlogsClient(process.env.DITBLOGS_API_KEY!);

async function fetchRecentPosts() {
  try {
    console.log('Fetching the 5 most recent posts...');
    const response = await client.getPosts({ limit: 5 });

    console.log(`Found ${response.pagination.total} total posts.`);
    response.posts.forEach(post => {
      console.log(`- ${post.title} (slug: ${post.slug})`);
    });
  } catch (error) {
    console.error('Failed to fetch posts:', error.message);
  }
}

fetchRecentPosts();

API Reference

All methods return a Promise that resolves with the data from the API.

new DITBlogsClient(apiKey)

Creates a new API client instance.

  • apiKey (string, required): Your secret API key from the DITBlogs dashboard.

Posts

client.getPosts(params)

Retrieves a paginated list of published posts.

  • params (object, optional):
    • category?: string - Filter by category slug.
    • tag?: string - Filter by tag slug.
    • page?: number - The page number to retrieve. Defaults to 1.
    • limit?: number - The number of posts per page. Defaults to 10.
  • Returns: Promise<PostsResponse>

client.getPost(slug)

Retrieves a single published post by its unique slug.

  • slug (string, required): The slug of the post.
  • Returns: Promise<Post>

Categories

client.getCategories()

Retrieves a list of all categories.

  • Returns: Promise<Category[]>

client.getCategory(slug, params)

Retrieves a single category and a paginated list of its posts.

  • slug (string, required): The slug of the category.
  • params (object, optional):
    • page?: number
    • limit?: number
  • Returns: Promise<CategoryResponse>

Tags

client.getTags()

Retrieves a list of all tags.

  • Returns: Promise<Tag[]>

client.getTag(slug, params)

Retrieves a single tag and a paginated list of its posts.

  • slug (string, required): The slug of the tag.
  • params (object, optional):
    • page?: number
    • limit?: number
  • Returns: Promise<TagResponse>

Comments

client.getComments(postSlug)

Retrieves all comments for a post, structured hierarchically.

  • postSlug (string, required): The slug of the post.
  • Returns: Promise<Comment[]>

client.postComment(params)

Submits a new comment or a reply.

  • params (object, required):
    • postSlug: string - The slug of the post being commented on.
    • content: string - The text content of the comment.
    • userToken: string - The authentication token (e.g., JWT) of the end-user posting the comment.
    • parentId?: string - The ID of the parent comment if this is a reply.
  • Returns: Promise<Comment>

Error Handling

If the API returns an error (any non-2xx status code), the promise will be rejected. You should wrap your API calls in a try...catch block to handle failures gracefully.

async function fetchInvalidPost() {
  try {
    const post = await client.getPost('this-slug-does-not-exist');
    console.log(post);
  } catch (error) {
    // error.message will contain the JSON error response from the API
    console.error(error.message); 
    // Example output: API Error (404): "{\"error\":\"Post not found.\"}"
  }
}

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.

License

MIT