Skip to content

Latest commit

 

History

History
95 lines (68 loc) · 1.77 KB

File metadata and controls

95 lines (68 loc) · 1.77 KB

Installation

Requirements

  • Node.js 16 or higher
  • npm or yarn package manager
  • A Substack account with publication access

NPM Installation

You can install the package using npm:

npm install substack-api

Yarn Installation

If you prefer using yarn:

yarn add substack-api

TypeScript Configuration

The library is written in TypeScript and includes type definitions out of the box. No additional setup is required for TypeScript projects.

For optimal TypeScript integration, ensure your tsconfig.json includes:

{
  "compilerOptions": {
    "esModuleInterop": true,
    "moduleResolution": "node"
  }
}

Verification

To verify the installation, you can create a simple test file:

import { SubstackClient } from 'substack-api';

const client = new SubstackClient({
  token: 'your-connect-sid-cookie-value',
  publicationUrl: 'example.substack.com'
});

async function test() {
  try {
    const isConnected = await client.testConnectivity();
    console.log('Connection status:', isConnected ? 'Connected' : 'Failed');
  } catch (error) {
    console.error('Error:', error.message);
  }
}

test();

Development Installation

If you want to contribute to the library or run it from source:

  1. Clone the repository:

    git clone https://github.com/jakub-k-slys/substack-api.git
    cd substack-api
  2. Install dependencies:

    npm install
  3. Build the project:

    npm run build
  4. Run tests:

    npm test

Next Steps

Once installed, you can: