# Class DocumentClient

Sub-client for document EP API endpoints.

#### Hierarchy (View Summary)

- BaseEPClient
  - DocumentClient

- Defined in clients/ep/documentClient.ts:34

##### Index

### Constructors

constructor

### Properties

baseURL
cache
enableRetry
maxResponseBytes
maxRetries
rateLimiter
timeoutMs

### Methods

buildDocumentSearchParams
clearCache
evictFromCache
filterDocuments
get
getCacheStats
getCommitteeDocumentById
getCommitteeDocuments
getCommitteeDocumentsFeed
getDocumentById
getDocumentsFeed
getExternalDocumentById
getExternalDocuments
getExternalDocumentsFeed
getPlenaryDocumentById
getPlenaryDocuments
getPlenaryDocumentsFeed
getPlenarySessionDocumentById
getPlenarySessionDocumentItems
getPlenarySessionDocuments
getPlenarySessionDocumentsFeed
searchDocuments
transformDocument

## Constructors

### constructor

- new DocumentClient(
  config?: EPClientConfig,
  shared?: EPSharedResources,
  ): DocumentClient

  #### Parameters

  - config: EPClientConfig = {}
  - `Optional` shared: EPSharedResources

  #### Returns DocumentClient

  Overrides BaseEPClient.constructor

  - Defined in clients/ep/documentClient.ts:35

## Properties

### `Protected` `Readonly` baseURL

baseURL: string

European Parliament API base URL.

Inherited from BaseEPClient.baseURL

- Defined in clients/ep/baseClient.ts:217

### `Protected` `Readonly` cache

cache: LRUCache<string, Record<string, unknown>>

LRU cache for API responses.

Inherited from BaseEPClient.cache

- Defined in clients/ep/baseClient.ts:215

### `Protected` `Readonly` enableRetry

enableRetry: boolean

Enable automatic retry on transient failures.

Inherited from BaseEPClient.enableRetry

- Defined in clients/ep/baseClient.ts:223

### `Protected` `Readonly` maxResponseBytes

maxResponseBytes: number

Maximum allowed response body size in bytes.

Inherited from BaseEPClient.maxResponseBytes

- Defined in clients/ep/baseClient.ts:227

### `Protected` `Readonly` maxRetries

maxRetries: number

Maximum number of retry attempts.

Inherited from BaseEPClient.maxRetries

- Defined in clients/ep/baseClient.ts:225

### `Protected` `Readonly` rateLimiter

rateLimiter: RateLimiter

Token bucket rate limiter.

Inherited from BaseEPClient.rateLimiter

- Defined in clients/ep/baseClient.ts:219

### `Protected` `Readonly` timeoutMs

timeoutMs: number

Request timeout in milliseconds.

Inherited from BaseEPClient.timeoutMs

- Defined in clients/ep/baseClient.ts:221

## Methods

### `Private` buildDocumentSearchParams

- buildDocumentSearchParams(
  params: {
  dateFrom?: string;
  documentType?: string;
  limit?: number;
  offset?: number;
  },
  ): Record<string, unknown>

  Builds EP API parameters for document search.

  #### Parameters

  - params: { dateFrom?: string; documentType?: string; limit?: number; offset?: number }

  #### Returns Record<string, unknown>

  #### Private

  - Defined in clients/ep/documentClient.ts:47

### clearCache

- clearCache(): void

  Clears all entries from the LRU cache.

  #### Returns void

  Inherited from BaseEPClient.clearCache

  - Defined in clients/ep/baseClient.ts:666

### `Protected` evictFromCache

- evictFromCache(endpoint: string, params?: Record<string, unknown>): void

  Evicts a single cache entry matching the given endpoint and params. Sub-clients use this when they detect that a successfully-fetched payload is a content-pending sentinel that must not be served from cache for the remainder of the TTL — eviction lets availability recover as soon as the upstream document is enriched.

  #### Parameters

  - endpoint: string

    API endpoint path (same value passed to get)

  - `Optional` params: Record<string, unknown>

    Optional query parameters (same value passed to get)

  #### Returns void

  #### Protected

  Inherited from BaseEPClient.evictFromCache

  - Defined in clients/ep/baseClient.ts:681

### `Private` filterDocuments

- filterDocuments(
  documents: LegislativeDocument[],
  params: { committee?: string; dateTo?: string; keyword?: string },
  ): LegislativeDocument[]

  Applies client-side keyword, committee, and date-range filters to documents.

  #### Parameters

  - documents: LegislativeDocument[]
  - params: { committee?: string; dateTo?: string; keyword?: string }

  #### Returns LegislativeDocument[]

  #### Private

  - Defined in clients/ep/documentClient.ts:80

### `Protected` get

- get<T extends Record<string, unknown>>(
  endpoint: string,
  params?: Record<string, unknown>,
  minimumTimeoutMs?: number,
  ): Promise<T>

  Executes a cached, rate-limited GET request to the EP API.

  #### Type Parameters

  - T extends Record<string, unknown>

    Expected response type (extends `Record<string, unknown>`)

  #### Parameters

  - endpoint: string

    API endpoint path (relative to `baseURL`)

  - `Optional` params: Record<string, unknown>

    Optional query parameters

  - `Optional` minimumTimeoutMs: number

    Optional per-request minimum timeout in milliseconds. When provided, the effective timeout is `Math.max(minimumTimeoutMs, this.timeoutMs)`, so the global timeout (set via `--timeout` or `EP_REQUEST_TIMEOUT_MS`) can still extend it beyond the per-endpoint minimum. Use for known slow EP API endpoints such as `procedures/feed`.

  #### Returns Promise<T>

  Promise resolving to the typed API response

  #### Throws

  On HTTP errors, network failures, or parse failures

  #### Protected

  Inherited from BaseEPClient.get

  - Defined in clients/ep/baseClient.ts:606

### getCacheStats

- getCacheStats(): {
  hitRate: number;
  hits: number;
  maxSize: number;
  misses: number;
  size: number;
  }

  Returns cache statistics for monitoring and debugging.

  #### Returns { hitRate: number; hits: number; maxSize: number; misses: number; size: number }

  `{ size, maxSize, hitRate, hits, misses }`

  Inherited from BaseEPClient.getCacheStats

  - Defined in clients/ep/baseClient.ts:690

### getCommitteeDocumentById

- getCommitteeDocumentById(docId: string): Promise<LegislativeDocument>

  Returns a single committee document by ID. EP API Endpoint: `GET /committee-documents/{doc-id}`

  #### Parameters

  - docId: string

  #### Returns Promise<LegislativeDocument>

  - Defined in clients/ep/documentClient.ts:409

### getCommitteeDocuments

- getCommitteeDocuments(
  params?: { limit?: number; offset?: number },
  ): Promise<PaginatedResponse<LegislativeDocument>>

  Returns committee documents. EP API Endpoint: `GET /committee-documents`

  Note: The EP API `/committee-documents` endpoint does not support a `year` query parameter per the OpenAPI spec. Only pagination (limit/offset) is supported.

  #### Parameters

  - params: { limit?: number; offset?: number } = {}

  #### Returns Promise<PaginatedResponse<LegislativeDocument>>

  - Defined in clients/ep/documentClient.ts:197

### getCommitteeDocumentsFeed

- getCommitteeDocumentsFeed(): Promise<JSONLDResponse<Record<string, unknown>>>

  Retrieves recently updated committee documents via the feed endpoint. EP API Endpoint: `GET /committee-documents/feed`

  Fixed-window feed — no `timeframe` parameter. Extended timeout applied (120 s minimum).

  #### Returns Promise<JSONLDResponse<Record<string, unknown>>>

  - Defined in clients/ep/documentClient.ts:323

### getDocumentById

- getDocumentById(docId: string): Promise<LegislativeDocument>

  Returns a single document by ID. EP API Endpoint: `GET /documents/{doc-id}`

  #### Parameters

  - docId: string

  #### Returns Promise<LegislativeDocument>

  - Defined in clients/ep/documentClient.ts:370

### getDocumentsFeed

- getDocumentsFeed(): Promise<JSONLDResponse<Record<string, unknown>>>

  Retrieves recently updated documents via the feed endpoint. EP API Endpoint: `GET /documents/feed`

  This is a fixed-window feed — the EP API does NOT accept a `timeframe` parameter. It returns updates from a server-defined default window (typically one month). Response times can exceed 120 s, so an extended minimum timeout is applied automatically.

  #### Returns Promise<JSONLDResponse<Record<string, unknown>>>

  - Defined in clients/ep/documentClient.ts:297

### getExternalDocumentById

- getExternalDocumentById(docId: string): Promise<LegislativeDocument>

  Returns a single external document by ID. EP API Endpoint: `GET /external-documents/{doc-id}`

  #### Parameters

  - docId: string

  #### Returns Promise<LegislativeDocument>

  - Defined in clients/ep/documentClient.ts:422

### getExternalDocuments

- getExternalDocuments(
  params?: { limit?: number; offset?: number },
  ): Promise<PaginatedResponse<LegislativeDocument>>

  Returns all External Documents. EP API Endpoint: `GET /external-documents`

  Note: The EP API `/external-documents` endpoint does not support a `year` query parameter per the OpenAPI spec. Only pagination (limit/offset) is supported.

  #### Parameters

  - params: { limit?: number; offset?: number } = {}

  #### Returns Promise<PaginatedResponse<LegislativeDocument>>

  - Defined in clients/ep/documentClient.ts:269

### getExternalDocumentsFeed

- getExternalDocumentsFeed(
  params?: { startDate?: string; timeframe?: string; workType?: string },
  ): Promise<JSONLDResponse<Record<string, unknown>>>

  Retrieves recently updated external documents via the feed endpoint. EP API Endpoint: `GET /external-documents/feed`

  This is a configurable-window feed that accepts `timeframe`, `start-date`, and `work-type` parameters. Extended timeout applied for `one-month` timeframe.

  #### Parameters

  - params: { startDate?: string; timeframe?: string; workType?: string } = {}

  #### Returns Promise<JSONLDResponse<Record<string, unknown>>>

  - Defined in clients/ep/documentClient.ts:350

### getPlenaryDocumentById

- getPlenaryDocumentById(docId: string): Promise<LegislativeDocument>

  Returns a single plenary document by ID. EP API Endpoint: `GET /plenary-documents/{doc-id}`

  #### Parameters

  - docId: string

  #### Returns Promise<LegislativeDocument>

  - Defined in clients/ep/documentClient.ts:383

### getPlenaryDocuments

- getPlenaryDocuments(
  params?: { limit?: number; offset?: number; year?: number },
  ): Promise<PaginatedResponse<LegislativeDocument>>

  Returns plenary documents. EP API Endpoint: `GET /plenary-documents`

  #### Parameters

  - params: { limit?: number; offset?: number; year?: number } = {}

  #### Returns Promise<PaginatedResponse<LegislativeDocument>>

  - Defined in clients/ep/documentClient.ts:168

### getPlenaryDocumentsFeed

- getPlenaryDocumentsFeed(): Promise<JSONLDResponse<Record<string, unknown>>>

  Retrieves recently updated plenary documents via the feed endpoint. EP API Endpoint: `GET /plenary-documents/feed`

  Fixed-window feed — no `timeframe` parameter. Extended timeout applied (120 s minimum).

  #### Returns Promise<JSONLDResponse<Record<string, unknown>>>

  - Defined in clients/ep/documentClient.ts:310

### getPlenarySessionDocumentById

- getPlenarySessionDocumentById(docId: string): Promise<LegislativeDocument>

  Returns a single plenary session document by ID. EP API Endpoint: `GET /plenary-session-documents/{doc-id}`

  #### Parameters

  - docId: string

  #### Returns Promise<LegislativeDocument>

  - Defined in clients/ep/documentClient.ts:396

### getPlenarySessionDocumentItems

- getPlenarySessionDocumentItems(
  params?: { limit?: number; offset?: number },
  ): Promise<PaginatedResponse<LegislativeDocument>>

  Returns all Plenary Session Document Items. EP API Endpoint: `GET /plenary-session-documents-items`

  #### Parameters

  - params: { limit?: number; offset?: number } = {}

  #### Returns Promise<PaginatedResponse<LegislativeDocument>>

  - Defined in clients/ep/documentClient.ts:243

### getPlenarySessionDocuments

- getPlenarySessionDocuments(
  params?: { limit?: number; offset?: number },
  ): Promise<PaginatedResponse<LegislativeDocument>>

  Returns plenary session documents. EP API Endpoint: `GET /plenary-session-documents`

  #### Parameters

  - params: { limit?: number; offset?: number } = {}

  #### Returns Promise<PaginatedResponse<LegislativeDocument>>

  - Defined in clients/ep/documentClient.ts:220

### getPlenarySessionDocumentsFeed

- getPlenarySessionDocumentsFeed(): Promise<
  JSONLDResponse<Record<string, unknown>>,
  >

  Retrieves recently updated plenary session documents via the feed endpoint. EP API Endpoint: `GET /plenary-session-documents/feed`

  Fixed-window feed — no `timeframe` parameter. Extended timeout applied (120 s minimum).

  #### Returns Promise<JSONLDResponse<Record<string, unknown>>>

  - Defined in clients/ep/documentClient.ts:336

### searchDocuments

- searchDocuments(
  params: {
  keyword: string;
  committee?: string;
  dateFrom?: string;
  dateTo?: string;
  documentType?: string;
  limit?: number;
  offset?: number;
  },
  ): Promise<PaginatedResponse<LegislativeDocument>>

  Searches legislative documents by keyword, type, date, and committee.

  EP API Endpoint: `GET /documents`

  #### Parameters

  - params: {
    keyword: string;
    committee?: string;
    dateFrom?: string;
    dateTo?: string;
    documentType?: string;
    limit?: number;
    offset?: number;
    }

    keyword, documentType, dateFrom, dateTo, committee, limit, offset

  #### Returns Promise<PaginatedResponse<LegislativeDocument>>

  Paginated legislative documents list

  #### Security

  Audit logged per GDPR Article 30

  - Defined in clients/ep/documentClient.ts:116

### `Private` transformDocument

- transformDocument(apiData: Record<string, unknown>): LegislativeDocument

  #### Parameters

  - apiData: Record<string, unknown>

  #### Returns LegislativeDocument

  - Defined in clients/ep/documentClient.ts:39