@hasadna/open-bus-api-client
Version:
A client library for interacting with the Open-Bus API.
185 lines (184 loc) • 8.3 kB
TypeScript
/**
* Open Bus Stride API
* ### Follow planned and real-time bus statistics 🚌 Welcome to The Public Knowledge Workshop\'s Stride project. We provide usable and accurate data about the Israeli public transportation system. For background on the project and some more detailed documentation and usage guides, see [STRIDE.md](https://github.com/hasadna/open-bus-pipelines/blob/main/STRIDE.md). Looking for a specific use-case? * Take a look at the **user cases** APIs below. * Try one of our existing [jupyter notebooks](https://github.com/hasadna/open-bus-stride-client/blob/main/README.md#using-the-interactive-jupyter-notebooks). * Don\'t see your use-case covered here? Please [open us a ticket](https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fhasadna%2Fopen-bus%2Fissues%2Fnew)! Queries are by default limited to 100 results per query, this limit can be increased up to 500,000 results. Please try to set appropriate query parameters to limit the results to reduce load on our DB. If you do need to get large number of results (up to 500,000) it\'s recommended to use one of these methods: 1. Use HTTP streaming and JSON streaming decoder, this method is most efficient and provide accurate results. Our [Stride Python Client iterate method](https://github.com/hasadna/open-bus-stride-client#usage) uses this method. 2. Use combination of limit / offset parameters to get results by page. This method may be less accurate because it depends on data remaining unchanged between requests. For more advanced usage- * Use **gtfs** for data about the planned lines timetables. * Use **siri** for data about lines real-time * See [Open Bus Stride Data Model](https://github.com/hasadna/open-bus-stride-db/blob/main/DATA_MODEL.md) for description of field and table names. * See [Open Bus Stride ETL Processes](https://github.com/hasadna/open-bus-pipelines/blob/main/STRIDE_ETL_PROCESSES.md) for description of the ETL processes which fetch and aggregate the data. * See [MOT Developer Information](https://www.gov.il/BlobFolder/generalpage/gtfs_general_transit_feed_specifications/he/GTFS%20-%20Developer%20Information.pdf) for description of the source fields as published by the Israel Ministry of Transportation.
*
* The version of the OpenAPI document: 6909b3db7b8bfa5ac3f3c4aeb3de80d2a2c75810
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export declare const BASE_PATH: string;
export interface ConfigurationParameters {
basePath?: string;
fetchApi?: FetchAPI;
middleware?: Middleware[];
queryParamsStringify?: (params: HTTPQuery) => string;
username?: string;
password?: string;
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>);
headers?: HTTPHeaders;
credentials?: RequestCredentials;
}
export declare class Configuration {
private configuration;
constructor(configuration?: ConfigurationParameters);
set config(configuration: Configuration);
get basePath(): string;
get fetchApi(): FetchAPI | undefined;
get middleware(): Middleware[];
get queryParamsStringify(): (params: HTTPQuery) => string;
get username(): string | undefined;
get password(): string | undefined;
get apiKey(): ((name: string) => string | Promise<string>) | undefined;
get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined;
get headers(): HTTPHeaders | undefined;
get credentials(): RequestCredentials | undefined;
}
export declare const DefaultConfig: Configuration;
/**
* This is the base class for all generated API classes.
*/
export declare class BaseAPI {
protected configuration: Configuration;
private static readonly jsonRegex;
private middleware;
constructor(configuration?: Configuration);
withMiddleware<T extends BaseAPI>(this: T, ...middlewares: Middleware[]): T;
withPreMiddleware<T extends BaseAPI>(this: T, ...preMiddlewares: Array<Middleware['pre']>): T;
withPostMiddleware<T extends BaseAPI>(this: T, ...postMiddlewares: Array<Middleware['post']>): T;
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
protected isJsonMime(mime: string | null | undefined): boolean;
protected request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise<Response>;
private createFetchParams;
private fetchApi;
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
private clone;
}
export declare class ResponseError extends Error {
response: Response;
name: "ResponseError";
constructor(response: Response, msg?: string);
}
export declare class FetchError extends Error {
cause: Error;
name: "FetchError";
constructor(cause: Error, msg?: string);
}
export declare class RequiredError extends Error {
field: string;
name: "RequiredError";
constructor(field: string, msg?: string);
}
export declare const COLLECTION_FORMATS: {
csv: string;
ssv: string;
tsv: string;
pipes: string;
};
export type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
export type Json = any;
export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
export type HTTPHeaders = {
[key: string]: string;
};
export type HTTPQuery = {
[key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery;
};
export type HTTPBody = Json | FormData | URLSearchParams;
export type HTTPRequestInit = {
headers?: HTTPHeaders;
method: HTTPMethod;
credentials?: RequestCredentials;
body?: HTTPBody;
};
export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
export type InitOverrideFunction = (requestContext: {
init: HTTPRequestInit;
context: RequestOpts;
}) => Promise<RequestInit>;
export interface FetchParams {
url: string;
init: RequestInit;
}
export interface RequestOpts {
path: string;
method: HTTPMethod;
headers: HTTPHeaders;
query?: HTTPQuery;
body?: HTTPBody;
}
export declare function querystring(params: HTTPQuery, prefix?: string): string;
export declare function exists(json: any, key: string): boolean;
export declare function mapValues(data: any, fn: (item: any) => any): {
[key: string]: any;
};
export declare function canConsumeForm(consumes: Consume[]): boolean;
export interface Consume {
contentType: string;
}
export interface RequestContext {
fetch: FetchAPI;
url: string;
init: RequestInit;
}
export interface ResponseContext {
fetch: FetchAPI;
url: string;
init: RequestInit;
response: Response;
}
export interface ErrorContext {
fetch: FetchAPI;
url: string;
init: RequestInit;
error: unknown;
response?: Response;
}
export interface Middleware {
pre?(context: RequestContext): Promise<FetchParams | void>;
post?(context: ResponseContext): Promise<Response | void>;
onError?(context: ErrorContext): Promise<Response | void>;
}
export interface ApiResponse<T> {
raw: Response;
value(): Promise<T>;
}
export interface ResponseTransformer<T> {
(json: any): T;
}
export declare class JSONApiResponse<T> {
raw: Response;
private transformer;
constructor(raw: Response, transformer?: ResponseTransformer<T>);
value(): Promise<T>;
}
export declare class VoidApiResponse {
raw: Response;
constructor(raw: Response);
value(): Promise<void>;
}
export declare class BlobApiResponse {
raw: Response;
constructor(raw: Response);
value(): Promise<Blob>;
}
export declare class TextApiResponse {
raw: Response;
constructor(raw: Response);
value(): Promise<string>;
}