PHPackages                             anomaly/streams-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. anomaly/streams-api

ActiveStreams-addon[API Development](/categories/api)

anomaly/streams-api
===================

A RESTful API for Laravel Streams.

1.0.x-dev(4w ago)1582MITPHP

Since Jun 3Pushed 4w ago3 watchersCompare

[ Source](https://github.com/laravel-streams/streams-api)[ Packagist](https://packagist.org/packages/anomaly/streams-api)[ RSS](/packages/anomaly-streams-api/feed)WikiDiscussions 1.0 Synced 3w ago

READMEChangelogDependencies (5)Versions (1)Used By (0)

Streams API
===========

[](#streams-api)

A powerful, flexible RESTful API package for the Laravel Streams platform. Get instant CRUD endpoints for all your streams with extensive customization options.

Features
--------

[](#features)

- 🚀 **Automatic REST Endpoints** - Instant CRUD operations for all streams
- 🔍 **Advanced Querying** - Filtering, pagination, and custom query methods
- 🎯 **Custom Interfaces** - Multiple API configurations with different prefixes and middleware
- 🛠️ **Custom Endpoints** - Easy to add your own routes and logic
- 🔐 **Middleware Support** - Authentication, rate limiting, and more
- 📚 **OpenAPI/Swagger** - Auto-generate interactive API documentation
- ⚡ **Response Formatting** - Standardized JSON responses
- 💾 **HTTP Caching** - Built-in caching with ETag support

Installation
------------

[](#installation)

```
composer require streams/api:1.0.x-dev
```

Quick Start
-----------

[](#quick-start)

Enable the API in your `.env`:

```
STREAMS_API_ENABLED=true
```

Routes register automatically when the package boots. Enable access in `.env`:

```
STREAMS_API_ENABLED=true
```

Extend the API gate middleware in your application (like Laravel's `VerifyCsrfToken`):

```
// app/Http/Middleware/EnsureApiIsEnabled.php
namespace App\Http\Middleware;

use Streams\Api\Http\Middleware\EnsureApiIsEnabled as Middleware;

class EnsureApiIsEnabled extends Middleware
{
    protected function shouldEnable(\Illuminate\Http\Request $request): bool
    {
        return parent::shouldEnable($request);
    }
}
```

Point `gate_middleware` in `config/streams/api.php` to your class.

Routes are registered only for interfaces you define. Opt into built-in stream/entry CRUD explicitly:

```
use Streams\Api\ApiInterface;
use Streams\Api\Resources\EntriesResource;
use Streams\Api\Resources\StreamsResource;
use Streams\Api\Support\Facades\API;

API::interface(
    ApiInterface::make('api')
        ->path('api')
        ->resources([StreamsResource::class, EntriesResource::class])
);

// Or use helpers on the default interface:
API::routeCrud(); // both StreamsResource + EntriesResource
API::routeEntries(); // entries only
API::routeStreams(); // streams only
```

Documentation
-------------

[](#documentation)

**📖 [Full Documentation](https://streams.dev/docs/api/introduction)**

- [Introduction](https://streams.dev/docs/api/introduction) - Overview and quick start
- [Configuration](https://streams.dev/docs/api/configuration) - Configure the API
- [Query Parameters](https://streams.dev/docs/api/query-parameters) - Filter and paginate data
- [Custom Interfaces](https://streams.dev/docs/api/custom-interfaces) - Multiple API configurations
- [Custom Endpoints](https://streams.dev/docs/api/custom-endpoints) - Add your own routes
- [Responses](https://streams.dev/docs/api/responses) - Format API responses
- [OpenAPI](https://streams.dev/docs/api/openapi) - Generate Swagger documentation
- [Testing](https://streams.dev/docs/api/testing) - Test your API

**Note**: Documentation URLs like `/docs/api/introduction` correspond to `docs/introduction.md` in this repository.

Default Endpoints
-----------------

[](#default-endpoints)

### Stream Management

[](#stream-management)

```
GET    /api/streams              # List all streams
POST   /api/streams              # Create a stream
GET    /api/streams/{stream}     # Get a stream
PUT    /api/streams/{stream}     # Update a stream
PATCH  /api/streams/{stream}     # Partially update a stream
DELETE /api/streams/{stream}     # Delete a stream

```

### Entry Management

[](#entry-management)

```
GET    /api/streams/{stream}/entries           # List entries
POST   /api/streams/{stream}/entries           # Create an entry
GET    /api/streams/{stream}/entries/{entry}   # Get an entry
PUT    /api/streams/{stream}/entries/{entry}   # Update an entry
PATCH  /api/streams/{stream}/entries/{entry}   # Partially update an entry
DELETE /api/streams/{stream}/entries/{entry}   # Delete an entry

```

### Query Endpoint

[](#query-endpoint)

```
POST   /api/streams/{stream}/query   # Advanced queries

```

Usage Examples
--------------

[](#usage-examples)

### Filtering &amp; Pagination

[](#filtering--pagination)

```
GET /api/streams/posts/entries?where[status]=published&per_page=10&page=1
```

### Advanced Queries

[](#advanced-queries)

```
POST /api/streams/posts/query
Content-Type: application/json

{
    "parameters": [
        {"where": ["status", "published"]},
        {"where": ["views", ">", 100]},
        {"orderBy": ["created_at", "desc"]},
        {"limit": [20]}
    ]
}
```

### Custom Interface

[](#custom-interface)

```
use Streams\Api\ApiInterface;
use Streams\Api\Support\Facades\API;

$api = ApiInterface::make('v1')
    ->path('api/v1')
    ->middleware(['auth:sanctum', 'throttle:60,1']);

API::interface($api);
```

### Custom Endpoint Builder

[](#custom-endpoint-builder)

```
use Streams\Api\Builders\Endpoints\ApiEndpoint;
use Streams\Api\ApiResponse;

class FeaturedPosts extends ApiEndpoint
{
    public function __invoke()
    {
        return ApiResponse::make(
            Streams::entries('posts')->where('featured', true)->get()
        );
    }
}

$api->resources([
    PostsResource::class, // getEndpoints() returns FeaturedPosts::route('featured', 'get')
]);
```

Configuration
-------------

[](#configuration)

Publish configuration file:

```
php artisan vendor:publish --provider=Streams\\Api\\ApiServiceProvider --tag=config
```

```
// config/streams/api.php
return [
    'enabled' => env('STREAMS_API_ENABLED', false),
    'prefix' => env('STREAMS_API_PREFIX', 'api'),
    'middleware' => env('STREAMS_API_MIDDLEWARE', 'api'),
    'gate_middleware' => \App\Http\Middleware\EnsureApiIsEnabled::class,
    'default_interface' => env('STREAMS_API_DEFAULT_INTERFACE', 'api'),
];
```

Generate Documentation
----------------------

[](#generate-documentation)

Create OpenAPI schema:

```
php artisan api:schema
```

Generate Swagger UI:

```
php artisan api:documentation
```

Visit `/docs/api/index.html` to view interactive API documentation.

Testing
-------

[](#testing)

Run tests:

```
php vendor/bin/phpunit
```

Generate coverage report:

```
XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-html=./coverage
```

Current test suite: **142 tests**, **394 assertions** ✅

Security
--------

[](#security)

⚠️ **Important**: The API is disabled by default and all endpoints are public. Enable authentication:

```
// config/streams/api.php
'middleware' => ['api', 'auth:sanctum', 'throttle:60,1'],
```

Or per-interface:

```
$api->middleware(['auth:sanctum']);
```

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10.0+
- Streams Core 1.0+

License
-------

[](#license)

The Streams API is open-source software licensed under the [MIT license](LICENSE.md).

Support
-------

[](#support)

- 📖 [Documentation](https://streams.dev/docs/api/introduction)
- 💬 [Discussions](https://github.com/laravel-streams/streams-api/discussions)
- 🐛 [Issues](https://github.com/laravel-streams/streams-api/issues)
- 🌐 [Website](https://streams.dev)

Roadmap
-------

[](#roadmap)

- Gates based on Core/Laravel Gates for authorization
- API versioning helpers
- Rate limiting per endpoint
- API key authentication
- Webhook support
- GraphQL support
- Real-time subscriptions
- Batch operations
- API analytics/metrics

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance94

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

Top contributor holds 82.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

29d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3dc718dba9317e897b74dcb30e5c06bd106e1ad72b2df5242b66bcc28053fbf3?d=identicon)[anomaly](/maintainers/anomaly)

---

Top Contributors

[![RyanThompson](https://avatars.githubusercontent.com/u/1099967?v=4)](https://github.com/RyanThompson "RyanThompson (144 commits)")[![RobinRadic](https://avatars.githubusercontent.com/u/754732?v=4)](https://github.com/RobinRadic "RobinRadic (27 commits)")[![BubeCPH](https://avatars.githubusercontent.com/u/63174222?v=4)](https://github.com/BubeCPH "BubeCPH (3 commits)")[![mustafa-online](https://avatars.githubusercontent.com/u/5323832?v=4)](https://github.com/mustafa-online "mustafa-online (1 commits)")

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/anomaly-streams-api/health.svg)

```
[![Health](https://phpackages.com/badges/anomaly-streams-api/health.svg)](https://phpackages.com/packages/anomaly-streams-api)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k196.2M3.1k](/packages/composer-composer)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k28.9M2.3k](/packages/infection-infection)[paycore/openfintech-data

Openfintech data

22110.1k](/packages/paycore-openfintech-data)[nfephp-org/sped-nfe

API para geração e comunicação da NFe e NFCe com as SEFAZ autorizadoras.

1.5k1.6M16](/packages/nfephp-org-sped-nfe)[php-opencloud/openstack

PHP SDK for OpenStack APIs. Supports BlockStorage, Compute, Identity, Images, Networking and Metric Gnocchi

2312.4M25](/packages/php-opencloud-openstack)[cebe/php-openapi

Read and write OpenAPI yaml/json files and make the content accessable in PHP objects.

49916.1M107](/packages/cebe-php-openapi)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
