polysource/adapter-http

Polysource — HTTP REST API adapter: list, browse, write external API resources through the admin (with cursor or page-based pagination strategies).

Maintainers

Package info

github.com/polysource/adapter-http

Homepage

Issues

Type:symfony-bundle

pkg:composer/polysource/adapter-http

Transparency log

Statistics

Installs: 9

Dependents: 0

Suggesters: 0

Stars: 0

v1.1.1 2026-08-07 15:15 UTC

README

HTTP REST API adapter for Polysource — admin Stripe, GitHub, internal microservices, any external REST API you operate but don't own the schema of.

Part of the Polysource monorepo. MIT-licensed.

What it ships

  • HttpDataSource — implements WritableDataSourceInterface over Symfony HttpClientInterface.
  • PaginationStrategyInterface — pluggable pagination protocol with two built-in implementations:
    • PageNumberPaginationStrategy?page=N style (Stripe-like)
    • CursorPaginationStrategy — opaque cursor in response (GitHub-like)
  • defaultHeaders constructor arg for injecting auth headers (Bearer tokens, API keys).
  • HttpResource — non-final convenience base.
  • Tested with Symfony's MockHttpClient so no live API calls in CI.

Install

composer require polysource/adapter-http symfony/http-client

Register the bundle:

return [
    Polysource\Adapter\Http\PolysourceAdapterHttpBundle::class => ['all' => true],
];

Extend it

For an API that paginates in an unusual way (link headers, X-Pagination, RFC 5988…), implement PaginationStrategyInterface (2 methods):

final class LinkHeaderPaginationStrategy implements PaginationStrategyInterface
{
    /** @return array<string, scalar|list<scalar>> query params to add to the request URI */
    public function buildQueryParams(DataQuery $query): array { /* … */ }

    /** @return array{items: list<array<string, mixed>>, total: ?int, nextCursor: ?string, prevCursor: ?string} */
    public function parseResponse(array $body, array $headers): array { /* parse the Link header */ }
}

Inject into HttpDataSource. No fork needed. See extensibility map.

Documentation