Client: Installation
Installing and setting up the Streams API Client
Requirements
- Node.js 14.0 or higher
- npm, yarn, or pnpm
Installing via NPM
Install the package using your preferred package manager:
NPM
npm install @laravel-streams/api-client
Yarn
yarn add @laravel-streams/api-client
PNPM
pnpm add @laravel-streams/api-client
Installing from Source
Cloning with Git
git clone [email protected]:laravel-streams/api-client.git
cd api-client
npm install
npm run build
Building from Source
# Install dependencies
npm install
# Build the distribution files
npm run build
# Run tests to verify
npm test
Package Contents
After installation, the package includes:
node_modules/@laravel-streams/api-client/
├── dist/
│ ├── index.js # CommonJS build
│ └── module.js # ES Module build
├── src/
│ ├── Client.js
│ ├── Criteria.js
│ ├── Entries.js
│ ├── Streams.js
│ └── middleware/
└── package.json
Importing the Client
ES Modules (Recommended)
import { Client, Criteria } from '@laravel-streams/api-client';
CommonJS
const { Client, Criteria } = require('@laravel-streams/api-client');
Browser (ES Modules)
<script type="module">
import { Client } from './node_modules/@laravel-streams/api-client/dist/module.js';
const client = new Client({
baseURL: 'http://localhost/api'
});
</script>
Updating
Update to the latest version:
npm update @laravel-streams/api-client
Or update to a specific version:
npm install @laravel-streams/[email protected]
Verifying Installation
Create a simple test file to verify the installation:
// test-install.mjs
import { Client, Criteria } from '@laravel-streams/api-client';
console.log('✓ Client imported:', typeof Client);
console.log('✓ Criteria imported:', typeof Criteria);
const client = new Client({ baseURL: 'http://localhost/api' });
console.log('✓ Client created successfully');
Run it:
node test-install.mjs
Expected output:
✓ Client imported: function
✓ Criteria imported: function
✓ Client created successfully
Next Steps
- Quick Start Guide - Get up and running quickly
- Client Configuration - Configure the client for your needs
- Working with Entries - Start interacting with your data