Socket
Book a DemoInstallSign in
Socket

@chaingpt/ainews

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chaingpt/ainews

SDK for AINews

0.0.9
latest
npmnpm
Version published
Maintainers
4
Created
Source

ChainGPT AI News SDK

This library provides convenient access to the ChainGPT AI News REST API from TypeScript or JavaScript.

Installation

npm install --save @chaingpt/ainews
# or
yarn add ainews

Usage

import { AINews } from '@chaingpt/ainews';

const ainews = new AINews({
  apiKey: 'Your ChainGPT API Key',
});

async function main() {
  const response = await ainews.getNews({});
  console.log(response.data);
}

main();

Handling errors

When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), an error of the class AINewsError will be thrown:

import { Errors } from '@chaingpt/ainews';

async function main() {
  try {
    const response = await ainews.getNews({});
    console.log(response.data);
  } catch(error) {
    if (error instanceof Errors.AINewsError) {
      console.log(error.message)    
    }
  }
}

main();

Keywords

ai

FAQs

Package last updated on 15 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.