barikoiapis
Version:
Official TypeScript/JavaScript SDK for Barikoi Location Services
1,010 lines (998 loc) • 30.4 kB
TypeScript
type AuthToken = string | undefined;
interface Auth {
/**
* Which part of the request do we use to send the auth?
*
* @default 'header'
*/
in?: 'header' | 'query' | 'cookie';
/**
* A unique identifier for the security scheme.
*
* Defined only when there are multiple security schemes whose `Auth`
* shape would otherwise be identical.
*/
key?: string;
/**
* Header or query parameter name.
*
* @default 'Authorization'
*/
name?: string;
scheme?: 'basic' | 'bearer';
type: 'apiKey' | 'http';
}
interface SerializerOptions<T> {
/**
* @default true
*/
explode: boolean;
style: T;
}
type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
type ObjectStyle = 'form' | 'deepObject';
type QuerySerializer = (query: Record<string, unknown>) => string;
type BodySerializer = (body: unknown) => unknown;
type QuerySerializerOptionsObject = {
allowReserved?: boolean;
array?: Partial<SerializerOptions<ArrayStyle>>;
object?: Partial<SerializerOptions<ObjectStyle>>;
};
type QuerySerializerOptions = QuerySerializerOptionsObject & {
/**
* Per-parameter serialization overrides. When provided, these settings
* override the global array/object settings for specific parameter names.
*/
parameters?: Record<string, QuerySerializerOptionsObject>;
};
type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
/**
* Returns the final request URL.
*/
buildUrl: BuildUrlFn;
getConfig: () => Config;
request: RequestFn;
setConfig: (config: Config) => Config;
} & {
[K in HttpMethod]: MethodFn;
} & ([SseFn] extends [never] ? {
sse?: never;
} : {
sse: {
[K in HttpMethod]: SseFn;
};
});
interface Config$1 {
/**
* Auth token or a function returning auth token. The resolved value will be
* added to the request payload as defined by its `security` array.
*/
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
/**
* A function for serializing request body parameter. By default,
* {@link JSON.stringify()} will be used.
*/
bodySerializer?: BodySerializer | null;
/**
* An object containing any HTTP headers that you want to pre-populate your
* `Headers` object with.
*
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
*/
headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
/**
* The request method.
*
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
*/
method?: Uppercase<HttpMethod>;
/**
* A function for serializing request query parameters. By default, arrays
* will be exploded in form style, objects will be exploded in deepObject
* style, and reserved characters are percent-encoded.
*
* This method will have no effect if the native `paramsSerializer()` Axios
* API function is used.
*
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
*/
querySerializer?: QuerySerializer | QuerySerializerOptions;
/**
* A function validating request data. This is useful if you want to ensure
* the request conforms to the desired shape, so it can be safely sent to
* the server.
*/
requestValidator?: (data: unknown) => Promise<unknown>;
/**
* A function transforming response data before it's returned. This is useful
* for post-processing data, e.g., converting ISO strings into Date objects.
*/
responseTransformer?: (data: unknown) => Promise<unknown>;
/**
* A function validating response data. This is useful if you want to ensure
* the response conforms to the desired shape, so it can be safely passed to
* the transformers and returned to the user.
*/
responseValidator?: (data: unknown) => Promise<unknown>;
}
type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & {
/**
* Fetch API implementation. You can use this option to provide a custom
* fetch instance.
*
* @default globalThis.fetch
*/
fetch?: typeof fetch;
/**
* Implementing clients can call request interceptors inside this hook.
*/
onRequest?: (url: string, init: RequestInit) => Promise<Request>;
/**
* Callback invoked when a network or parsing error occurs during streaming.
*
* This option applies only if the endpoint returns a stream of events.
*
* @param error The error that occurred.
*/
onSseError?: (error: unknown) => void;
/**
* Callback invoked when an event is streamed from the server.
*
* This option applies only if the endpoint returns a stream of events.
*
* @param event Event streamed from the server.
* @returns Nothing (void).
*/
onSseEvent?: (event: StreamEvent<TData>) => void;
serializedBody?: RequestInit['body'];
/**
* Default retry delay in milliseconds.
*
* This option applies only if the endpoint returns a stream of events.
*
* @default 3000
*/
sseDefaultRetryDelay?: number;
/**
* Maximum number of retry attempts before giving up.
*/
sseMaxRetryAttempts?: number;
/**
* Maximum retry delay in milliseconds.
*
* Applies only when exponential backoff is used.
*
* This option applies only if the endpoint returns a stream of events.
*
* @default 30000
*/
sseMaxRetryDelay?: number;
/**
* Optional sleep function for retry backoff.
*
* Defaults to using `setTimeout`.
*/
sseSleepFn?: (ms: number) => Promise<void>;
url: string;
};
interface StreamEvent<TData = unknown> {
data: TData;
event?: string;
id?: string;
retry?: number;
}
type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
};
type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
/** response may be undefined due to a network error where no response object is produced */
response: Res | undefined,
/** request may be undefined, because error may be from building the request object itself */
request: Req | undefined, options: Options) => Err | Promise<Err>;
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
declare class Interceptors<Interceptor> {
fns: Array<Interceptor | null>;
clear(): void;
eject(id: number | Interceptor): void;
exists(id: number | Interceptor): boolean;
getInterceptorIndex(id: number | Interceptor): number;
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
use(fn: Interceptor): number;
}
interface Middleware<Req, Res, Err, Options> {
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
request: Interceptors<ReqInterceptor<Req, Options>>;
response: Interceptors<ResInterceptor<Res, Req, Options>>;
}
type ResponseStyle = 'data' | 'fields';
interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
/**
* Base URL for all requests made by this client.
*/
baseUrl?: T['baseUrl'];
/**
* Fetch API implementation. You can use this option to provide a custom
* fetch instance.
*
* @default globalThis.fetch
*/
fetch?: typeof fetch;
/**
* Please don't use the Fetch client for Next.js applications. The `next`
* options won't have any effect.
*
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
*/
next?: never;
/**
* Return the response data parsed in a specified format. By default, `auto`
* will infer the appropriate method from the `Content-Type` response header.
* You can override this behavior with any of the {@link Body} methods.
* Select `stream` if you don't want to parse response data at all.
*
* @default 'auto'
*/
parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
/**
* Should we return only data or multiple fields (data, error, response, etc.)?
*
* @default 'fields'
*/
responseStyle?: ResponseStyle;
/**
* Throw an error instead of returning it in the response?
*
* @default false
*/
throwOnError?: T['throwOnError'];
}
interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
responseStyle: TResponseStyle;
throwOnError: ThrowOnError;
}>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
/**
* Any body that you want to add to your request.
*
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
*/
body?: unknown;
path?: Record<string, unknown>;
query?: Record<string, unknown>;
/**
* Security mechanism(s) to use for the request.
*/
security?: ReadonlyArray<Auth>;
url: Url;
}
interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
headers: Headers;
serializedBody?: string;
}
type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
request: Request;
response: Response;
}> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
error: undefined;
} | {
data: undefined;
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
}) & {
/** request may be undefined, because error may be from building the request object itself */
request?: Request;
/** response may be undefined, because error may be from building the request object itself or from a network error */
response?: Response;
}>;
interface ClientOptions {
baseUrl?: string;
responseStyle?: ResponseStyle;
throwOnError?: boolean;
}
type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
type BuildUrlFn = <TData extends {
body?: unknown;
path?: Record<string, unknown>;
query?: Record<string, unknown>;
url: string;
}>(options: TData & Options<TData>) => string;
type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
};
interface TDataShape {
body?: unknown;
headers?: unknown;
path?: unknown;
query?: unknown;
url: string;
}
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
type ReverseGeocodeSuccess = {
place?: {
id?: string | number;
distance_within_meters?: number;
address?: string;
area?: string;
city?: string;
postCode?: string;
address_bn?: string;
area_bn?: string;
city_bn?: string;
country?: string;
division?: string;
district?: string;
sub_district?: string;
pauroshova?: string | null;
union?: string | null;
location_type?: string;
address_components?: {
place_name?: string | null;
house?: string | null;
road?: string | null;
} | null;
area_components?: {
area?: string | null;
sub_area?: string | null;
} | null;
thana?: string;
thana_bn?: string;
};
status?: number;
};
type AutocompleteSuccess = {
places?: Array<{
id?: number;
longitude?: string | number;
latitude?: string | number;
address?: string;
address_bn?: string;
city?: string;
city_bn?: string;
area?: string;
area_bn?: string;
postCode?: string | number;
pType?: string;
uCode?: string;
}>;
status?: number;
};
type GeocodeSuccess = {
given_address?: string;
fixed_address?: string;
bangla_address?: string;
address_status?: 'complete' | 'incomplete';
geocoded_address?: {
id?: string | number;
Address?: string;
address?: string;
address_bn?: string;
alternate_address?: string;
area?: string;
area_bn?: string;
bounds?: string | null;
business_name?: string | null;
city?: string;
city_bn?: string;
created_at?: string;
district?: string;
geo_location?: Array<number>;
holding_number?: string | null;
latitude?: string;
location?: string;
location_shape?: string;
longitude?: string;
match_freq?: number;
match_fuzzy?: number;
matching_diff?: number;
new_address?: string;
pType?: string;
place_code?: string;
place_name?: string | null;
popularity_ranking?: number;
postCode?: string | number;
postcode?: string | number;
road_name_number?: string | null;
score?: number;
subType?: string;
sub_area?: string | null;
sub_district?: string;
sub_type?: string;
super_sub_area?: string | null;
thana?: string;
type?: string;
uCode?: string;
union?: string | number | null;
unions?: string | number | null;
updated_at?: string;
user_id?: number;
};
confidence_score_percentage?: number;
status?: number;
};
type RouteOverviewSuccess = {
code?: string;
routes?: Array<{
/**
* Encoded polyline (string) or GeoJSON (object)
*/
geometry?: string | {
[key: string]: unknown;
};
legs?: Array<{
steps?: Array<{
[key: string]: unknown;
}>;
/**
* Distance in meters
*/
distance?: number;
/**
* Duration in seconds
*/
duration?: number;
summary?: string;
weight?: number;
}>;
distance?: number;
duration?: number;
weight_name?: string;
weight?: number;
}>;
waypoints?: Array<{
hint?: string;
distance?: number;
name?: string | null;
location?: [number, number];
}>;
};
type SearchPlaceSuccess = {
places?: Array<{
address?: string;
place_code?: string;
}>;
session_id?: string;
status?: number;
};
type PlaceDetailsSuccess = {
place?: {
address?: string;
place_code?: string;
latitude?: string;
longitude?: string;
};
session_id?: string;
status?: number;
};
type SnapToRoadSuccess = {
coordinates?: [number, number];
/**
* Distance in meters
*/
distance?: number;
type?: 'Point';
};
type NearbySuccess = {
places?: Array<{
id?: number;
name?: string;
distance_in_meters?: string | number;
longitude?: string;
latitude?: string;
pType?: string;
Address?: string;
area?: string;
city?: string;
postCode?: string;
subType?: string;
uCode?: string;
}>;
status?: number;
};
type CalculateRouteSuccess = {
hints?: {
'visited_nodes.sum'?: number;
'visited_nodes.average'?: number;
};
info?: {
copyrights?: Array<string>;
took?: number;
road_data_timestamp?: string;
};
paths?: Array<{
/**
* Distance in meters
*/
distance?: number;
weight?: number;
/**
* Time in milliseconds
*/
time?: number;
transfers?: number;
points_encoded?: boolean;
bbox?: [number, number, number, number];
/**
* GeoJSON LineString with route coordinates
*/
points?: {
type?: 'LineString';
coordinates?: Array<[number, number]>;
};
instructions?: Array<{
distance?: number;
heading?: number;
sign?: number;
interval?: [number, number];
text?: string;
time?: number;
street_name?: string;
}>;
legs?: Array<{
[key: string]: unknown;
}>;
details?: Array<{
[key: string]: unknown;
}>;
ascend?: number;
descend?: number;
snapped_waypoints?: {
type?: 'LineString';
coordinates?: Array<[number, number]>;
};
}>;
};
type CheckNearbySuccess = {
message?: string;
status?: number;
data?: {
id?: string;
name?: string;
radius?: string;
latitude?: string;
longitude?: string;
user_id?: number;
};
};
type MissingParameter = {
message?: string;
status?: number;
};
type NoRegisteredKey = {
message?: string;
status?: number;
};
type PaymentException = {
message?: string;
status?: number;
};
type ApiLimitExceeded = {
message?: string;
status?: number;
};
/**
* Reverse Geocoding Parameters
* Convert coordinates to address
*/
type ReverseGeocodeParams = {
/** Longitude coordinate (required)
* @minimum -180
* @maximum 180
*/
longitude: number;
/** Latitude coordinate (required)
* @minimum -90
* @maximum 90
*/
latitude: number;
/** Country code (ISO Alpha-2 format, e.g., 'BD')
* @default 'BD'
*/
country_code?: string;
country?: boolean;
district?: boolean;
post_code?: boolean;
sub_district?: boolean;
union?: boolean;
pauroshova?: boolean;
location_type?: boolean;
division?: boolean;
address?: boolean;
area?: boolean;
bangla?: boolean;
thana?: boolean;
};
/**
* Autocomplete Parameters
* Search for places with autocomplete suggestions
*/
type AutocompleteParams = {
/** Search query string (required)
* @minLength 1
*/
q: string;
/** Include Bangla language fields
* @default true
*/
bangla?: boolean;
};
/**
* Geocode (Rupantor) Parameters
* Format and geocode addresses
*/
type GeocodeParams = {
/** Address to geocode (required)
* @minLength 1
*/
q: string;
thana?: 'yes' | 'no';
district?: 'yes' | 'no';
bangla?: 'yes' | 'no';
};
/**
* Search Place Parameters
* Search for places and get session IDs
*/
type SearchPlaceParams = {
/** Search query string (required)
* @minLength 1
*/
q: string;
};
/**
* Place Details Parameters
* Get detailed information about a specific place
*/
type PlaceDetailsParams = {
/** Place code from search place results (required)
* @minLength 1
*/
place_code: string;
/** Session ID from search place results (required)
* @minLength 1
*/
session_id: string;
};
/**
* Nearby Parameters
* Find places within a specified radius
*/
type NearbyParams = {
/** Longitude coordinate (required)
* @minimum -180
* @maximum 180
*/
longitude: number;
/** Latitude coordinate (required)
* @minimum -90
* @maximum 90
*/
latitude: number;
/** Search radius in kilometers
* @minimum 0.1
* @maximum 100
* @default 0.5
*/
radius?: number;
/** Maximum number of results
* @minimum 1
* @maximum 100
* @default 10
*/
limit?: number;
};
/**
* Check Nearby Parameters
* Verify if a destination is within a specified radius of current location
*/
type CheckNearbyParams = {
/** Destination latitude coordinate (required)
* @minimum -90
* @maximum 90
*/
destination_latitude: number;
/** Destination longitude coordinate (required)
* @minimum -180
* @maximum 180
*/
destination_longitude: number;
/** Radius in meters (required)
* @minimum 1
* @maximum 1000
*/
radius: number;
/** Current latitude coordinate (required)
* @minimum -90
* @maximum 90
*/
current_latitude: number;
/** Current longitude coordinate (required)
* @minimum -180
* @maximum 180
*/
current_longitude: number;
};
/**
* Snap to Road Parameters
* Snap GPS coordinates to the nearest road segment
*/
type SnapToRoadParams = {
/** Point coordinates in format "latitude,longitude" (required)
* @format "latitude,longitude"
* @example "23.8103,90.4125"
*/
point: string;
};
/**
* Route Overview Parameters
* Get basic route information between two points
*/
type RouteOverviewParams = {
/** Coordinates in format "lon,lat;lon,lat" (required)
* @format "lon,lat;lon,lat"
* @example "90.4125,23.8103;90.3742,23.7461"
*/
coordinates: string;
/** Geometry format for the route
* @default 'polyline'
*/
geometries?: 'polyline' | 'polyline6' | 'geojson';
/** Transportation profile
* @default 'car'
*/
profile?: 'car' | 'foot';
};
/**
* Calculate Route Parameters
* Calculate detailed route between two points
*/
type CalculateRouteParams = {
/** Start point coordinates (required) */
start: {
/** Start latitude
* @minimum -90
* @maximum 90
*/
latitude: number;
/** Start longitude
* @minimum -180
* @maximum 180
*/
longitude: number;
};
/** Destination point coordinates (required) */
destination: {
/** Destination latitude
* @minimum -90
* @maximum 90
*/
latitude: number;
/** Destination longitude
* @minimum -180
* @maximum 180
*/
longitude: number;
};
/** Route calculation type
* @default 'gh'
*/
type: 'gh';
/** Transportation profile */
profile?: 'car' | 'motorcycle' | 'bike';
};
interface BarikoiConfig {
apiKey: string;
baseUrl?: string;
timeout?: number;
allowBrowser?: boolean;
/** Allow http:// baseUrl (default: false, requires https://). Use only for local dev. */
allowInsecure?: boolean;
}
/**
* Barikoi API Client
* A TypeScript SDK for Barikoi Location APIs
*/
declare class BarikoiClient {
private apiKey;
private timeout;
private static warnedBrowser;
/** @internal reset for tests */
static _resetBrowserWarnFlagForTests(): void;
constructor(config: BarikoiConfig);
private resolveBaseUrl;
/**
* Creates a fetch function with timeout support
*/
private createFetchWithTimeout;
/**
* Set API key
*/
setApiKey(apiKey: string): void;
/**
* Get current API key
*/
getApiKey(): string;
/**
* Set timeout for API requests
* @param timeout - Timeout in milliseconds
*/
setTimeout(timeout: number): void;
/**
* Get current timeout setting
*/
getTimeout(): number;
/**
* Reverse Geocoding - Convert coordinates to address
*/
reverseGeocode(params: ReverseGeocodeParams): Promise<({
data: ReverseGeocodeSuccess;
error: undefined;
} | {
data: undefined;
error: MissingParameter | NoRegisteredKey | PaymentException | ApiLimitExceeded;
}) & {
request?: Request;
response?: Response;
}>;
/**
* Autocomplete - Search for places
*/
autocomplete(params: AutocompleteParams): Promise<({
data: AutocompleteSuccess;
error: undefined;
} | {
data: undefined;
error: MissingParameter | NoRegisteredKey | PaymentException | ApiLimitExceeded;
}) & {
request?: Request;
response?: Response;
}>;
/**
* Geocode - Format and geocode addresses
*/
geocode(params: GeocodeParams): Promise<({
data: GeocodeSuccess;
error: undefined;
} | {
data: undefined;
error: MissingParameter | NoRegisteredKey | PaymentException | ApiLimitExceeded;
}) & {
request?: Request;
response?: Response;
}>;
/**
* Search Place
*/
searchPlace(params: SearchPlaceParams): Promise<({
data: SearchPlaceSuccess;
error: undefined;
} | {
data: undefined;
error: MissingParameter | NoRegisteredKey | PaymentException | ApiLimitExceeded;
}) & {
request?: Request;
response?: Response;
}>;
/**
* Place Details - get place info
*/
placeDetails(params: PlaceDetailsParams): Promise<({
data: PlaceDetailsSuccess;
error: undefined;
} | {
data: undefined;
error: MissingParameter | NoRegisteredKey | PaymentException | ApiLimitExceeded;
}) & {
request?: Request;
response?: Response;
}>;
/**
* Nearby - Find nearby places
*/
nearby(params: NearbyParams): Promise<({
data: NearbySuccess;
error: undefined;
} | {
data: undefined;
error: MissingParameter | NoRegisteredKey | PaymentException | ApiLimitExceeded;
}) & {
request?: Request;
response?: Response;
}>;
/**
* Check nearby - verify proximity
*/
checkNearby(params: CheckNearbyParams): Promise<({
data: CheckNearbySuccess;
error: undefined;
} | {
data: undefined;
error: MissingParameter | NoRegisteredKey | PaymentException | ApiLimitExceeded;
}) & {
request?: Request;
response?: Response;
}>;
/**
* Calculate Route
*/
calculateRoute(params: CalculateRouteParams): Promise<({
data: CalculateRouteSuccess;
error: undefined;
} | {
data: undefined;
error: MissingParameter | NoRegisteredKey | PaymentException | ApiLimitExceeded;
}) & {
request?: Request;
response?: Response;
}>;
/**
* Snap to Road
*/
snapToRoad(params: SnapToRoadParams): Promise<({
data: SnapToRoadSuccess;
error: undefined;
} | {
data: undefined;
error: MissingParameter | NoRegisteredKey | PaymentException | ApiLimitExceeded;
}) & {
request?: Request;
response?: Response;
}>;
/**
* Optimize Route - optimize waypoints
*/
/**
* Route Overview - basic route info
*/
routeOverview(params: RouteOverviewParams): Promise<({
data: RouteOverviewSuccess;
error: undefined;
} | {
data: undefined;
error: MissingParameter | NoRegisteredKey | PaymentException | ApiLimitExceeded;
}) & {
request?: Request;
response?: Response;
}>;
/**
* Get client instance with API key pre-configured
*/
getConfiguredClient(): Client;
}
/**
* Create a new Barikoi client instance
*
* @example
* ```typescript
* const barikoi = createBarikoiClient({
* apiKey: 'your-api-key'
* })
*
* const result = await barikoi.autocomplete({
* q: 'Dhaka',
* bangla: true
* })
* ```
*/
declare function createBarikoiClient(config: BarikoiConfig): BarikoiClient;
declare class BarikoiError extends Error {
readonly statusCode?: number | undefined;
readonly code?: string | undefined;
readonly details?: unknown | undefined;
constructor(message: string, statusCode?: number | undefined, code?: string | undefined, details?: unknown | undefined);
isAuthError(): boolean;
isRateLimitError(): boolean;
isServerError(): boolean;
}
declare class ValidationError extends BarikoiError {
constructor(message: string, details?: unknown);
}
declare class TimeoutError extends BarikoiError {
constructor(message?: string);
}
export { BarikoiClient, BarikoiError, TimeoutError, ValidationError, createBarikoiClient };
export type { AutocompleteParams, BarikoiConfig, CalculateRouteParams, CheckNearbyParams, GeocodeParams, NearbyParams, PlaceDetailsParams, ReverseGeocodeParams, RouteOverviewParams, SearchPlaceParams, SnapToRoadParams };