0.0.8 • Published 2 months ago

@chaingpt/ainews v0.0.8

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

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.rows);
}

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.rows);
  } catch(error) {
    if (error instanceof Errors.AINewsError) {
      console.log(error.message)    
    }
  }
}

main();
0.0.8

2 months ago

0.0.7

4 months ago

0.0.5

4 months ago

0.0.6

4 months ago

0.0.4

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago