- Node.js 16 or higher
- npm or yarn package manager
- A Substack account with publication access
You can install the package using npm:
npm install substack-apiIf you prefer using yarn:
yarn add substack-apiThe 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"
}
}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();If you want to contribute to the library or run it from source:
-
Clone the repository:
git clone https://github.com/jakub-k-slys/substack-api.git cd substack-api -
Install dependencies:
npm install
-
Build the project:
npm run build
-
Run tests:
npm test
Once installed, you can:
- Follow the Quickstart guide to begin using the library
- Check out the Examples for common use cases
- Read the API Reference for detailed API documentation