EU Parliament Monitor — API Documentation - v0.8.48
    Preparing search index...

    Direct HTTP client for EP Open Data Portal roll-call vote data.

    Queries GET /api/v2/decision with date-of-vote-start and date-of-vote-end parameters. The response is JSON-LD; we extract the data array and normalise each entry to the same votes[] shape that the MCP get_voting_records tool returns, augmented with _source and _attribution metadata.

    const client = new EPOpenDataClient();
    const result = await client.getVotingRecords({
    dateFrom: '2026-03-01',
    dateTo: '2026-04-01',
    });
    Index

    Constructors

    Methods

    • Base URL currently in use (set at construction time).

      Returns string

      The fully-qualified EP Open Data Portal base URL (no trailing slash).

    • Per-request timeout in milliseconds.

      Returns number

      The timeout applied to every fetch() call.

    • Mark the client as ready (HTTP is stateless; validates URL shape only).

      Returns Promise<void>

      A resolved promise; never throws for valid URLs.

      When the base URL is malformed (e.g. missing protocol).

    • Fetch roll-call voting records from the EP Open Data Portal.

      Virtual tool: ep-get-voting-records (see EP_GET_VOTING_RECORDS_TOOL).

      Queries /decision?date-of-vote-start=<dateFrom>&date-of-vote-end=<dateTo> and normalises the JSON-LD response to a { votes: VoteEntry[] } envelope whose shape mirrors get_voting_records from the EP MCP server, augmented with _source and _attribution metadata.

      Returns the EMPTY_VOTES_FALLBACK envelope on any error so callers can safely chain the result through EPOpenDataClient.isVotingDataEmpty without defensive try/catch.

      Parameters

      • options: Pick<VotingRecordsFallbackOptions, "dateFrom" | "dateTo" | "limit" | "offset">

        Query options. dateFrom and dateTo are required and must be non-empty YYYY-MM-DD strings.

      Returns Promise<MCPToolResult>

      MCP-shaped result with votes[] array (possibly empty on error).

    • Return true when a get_voting_records (or fallback) result carries zero votes. Used to decide whether to proceed to the next fallback tier.

      Handles both the {"votes":[]} MCP empty shape and the plain {"votes":null} edge case.

      Parameters

      Returns boolean

      true when the votes array is absent or empty.

    • Build the canonical 🔴 voting data unavailable marker emitted when both MCP and the EP Open Data Portal fallback return empty.

      The returned payload remains a normal MCP JSON envelope containing an empty votes array plus human-readable marker metadata (_marker, _reason, _unavailable). This preserves compatibility with consumers that parse response.content[0]?.text as JSON, while still exposing a clear alert message for downstream display or diagnostics.

      Parameters

      • dateFrom: string

        Analysis period start (YYYY-MM-DD).

      • dateTo: string

        Analysis period end (YYYY-MM-DD).

      Returns MCPToolResult

      MCP-shaped result containing the 🔴 unavailability marker.

    • Internal

      Build a full URL and GET it as text, enforcing the client-wide timeout.

      Parameters

      • path: string

        Path (already URL-encoded) to append to the base URL.

      Returns Promise<string>

      Response body as a string.

      When the HTTP status is not 2xx, the request times out, or the network layer raises.

    • Internal

      GET a URL and parse the response body as JSON.

      Type Parameters

      • T

        Narrow response type declared by the caller.

      Parameters

      • path: string

        Path to append to the base URL.

      Returns Promise<T>

      Parsed JSON value.

      When the response is not JSON, not 2xx, or the request fails.

    Properties

    _apiBaseUrl: string
    _timeoutMs: number
    _fetchImpl: {
        (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
        (input: string | URL | Request, init?: RequestInit): Promise<Response>;
    }

    Type Declaration

      • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
      • Parameters

        • input: URL | RequestInfo
        • Optionalinit: RequestInit

        Returns Promise<Response>

      • (input: string | URL | Request, init?: RequestInit): Promise<Response>
      • Parameters

        • input: string | URL | Request
        • Optionalinit: RequestInit

        Returns Promise<Response>

    _connected: boolean = false