@maschinenlesbar.org/autobahn-cli
    Preparing search index...

    Interface ServiceResource<K>

    One Autobahn service (roadworks, webcam, ...). list(roadId) returns the items along a motorway; get(id) returns one item's full details.

    interface ServiceResource<K extends string> {
        get(identifier: string): Promise<JsonObject>;
        list(
            roadId: string,
            options?: { knownRoads?: () => Promise<string[]> },
        ): Promise<AutobahnServiceItem[]>;
    }

    Type Parameters

    • K extends string

      the envelope key the listing endpoint wraps its array in.

    Index
    • Fetch one item's details by its identifier (an opaque string; the format varies by service). It is sent trimmed and in composed Unicode, NFC (normalizeToken), as list() does for road ids: no identifier the API issues has surrounding whitespace, so a stray space from a copy-paste would otherwise read as "not found". A blank one, one with a control, format or invisible character or half a character (a lone surrogate), and one containing "/" are rejected like such a road id (idProblem): "x/../<id>" would otherwise resolve to <id>. A 2xx body that is not a JSON object, or one whose identifier is not the one asked for, raises AutobahnParseError.

      Parameters

      • identifier: string

      Returns Promise<JsonObject>

    • List the service's items along a motorway, e.g. roadId "A1". Road ids are case-sensitive. The API answers an unknown id (A999, a1) exactly like a road without items, so an empty listing is checked against roads(): an id not in that list raises AutobahnNotFoundError (with a did-you-mean for a case slip, a space or dash, or a leading zero) instead of returning []. That check is a second request (with its own timeout and retries); if it fails, list() throws an AutobahnError naming the check, with the original error as cause. options.knownRoads replaces the road-list lookup: a caller listing several services of one road passes one shared lookup, so the road list is fetched once, not once per empty listing (checkRoad does).

      Parameters

      • roadId: string
      • options: { knownRoads?: () => Promise<string[]> } = {}

      Returns Promise<AutobahnServiceItem[]>