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:
-
Clone the repository:
bash git clone https://github.com/jakub-k-slys/substack-api.git cd substack-api -
Install dependencies:
bash npm install -
Build the project:
bash npm run build -
Run tests:
bash npm test
Next Steps
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