opencage-api-client
Version:
An OpenCageData Geocoder API client library for node (ESM, CJS) and browsers (UMD)
123 lines (122 loc) • 5.5 kB
TypeScript
/**
* GeocodingRequest and related request parameters for the OpenCage API.
*/
export type GeocodingRequest = {
/**
* a 30 character long, alphanumeric string. The API Key is required when used in a browser. In a Node environment, it is optional, as it will be added automatically from the environment variable OPENAI_API_KEY, and a `.env` file can also be used.
*/
key?: string;
/**
* the query string to be geocoded: a latitude, longitude or a place name/address.
*/
q: string;
/**
* When set to 1 we attempt to abbreviate and shorten the formatted string we return. Learn more about formatted placename.
*/
abbrv?: number;
/**
* When set to 1 the various request parameters are added to the response for ease of debugging.
*/
add_request?: number;
/**
* Used only for forward geocoding. This value will restrict the possible results to a defined bounding box.
* The value of the bounds parameter should be specified as two coordinate points forming the south-west and north-east corners of a bounding box (min lon, min lat, max lon, max lat).
*
* Example usage:
* bounds=-0.563160,51.280430,0.278970,51.683979
*/
bounds?: string;
/**
* Used only for forward geocoding. Restricts results to the specified country/territory or countries.
*
* Example usage:
* countrycode=de
*
* The country code is a two letter code as defined by the ISO 3166-1 Alpha 2 standard. E.g. gb for the United Kingdom, fr for France, us for United States.
* Non-two letter country codes are ignored.
* You can specify multiple country codes by supplying a comma separated list. For example countrycode=ca,us would limit results to either the United States or Canada.
*/
countrycode?: string;
/**
* Wraps the returned JSON with a function name.
*/
jsonp?: string;
/**
* An IETF format language code (such as es for Spanish or pt-BR for Brazilian Portuguese), or native in which case we will attempt to return the response in the local language(s).
*
* Example usage:
* language=de
*
* If no language is explicitly specified, we will then look for an HTTP Accept-Language header like those sent by a browser and use highest quality language specified (please see RFC 4647 for details). If the request did not specify a valid header, then en (English) will be assumed.
*/
language?: string;
/**
* The maximum number of results we should return. Default is 10. Maximum allowable value is 100.
*
* Example usage:
* limit=1
*/
limit?: number;
/**
* An integer from 1-10. Only results with at least this confidence will be returned. Learn more about our confidence score on API documentation.
*
* Example usage:
* min_confidence=3
*/
min_confidence?: number;
/**
* When set to 1 results will not contain annotations.
*
* Example usage:
* no_annotations=1
*
* The only exception is if the optional roadinfo parameter is set (see below).
*/
no_annotations?: number;
/**
* When set to 1 results will not be deduplicated.
*/
no_dedupe?: number;
/**
* When set to 1 the query contents are not logged. Please use this parameter if you have concerns about privacy and want us to have no record of your query.
*/
no_record?: number;
/**
* When set to 1 results are 'pretty' printed for easier reading. Useful for debugging.
*/
pretty?: number;
/**
* Used only for forward geocoding. Provides the geocoder with a hint to bias results in favour of those closer to the specified location. Please note though, this is just one of many factors in the internal scoring we use for ranking results.
* The value is a point with latitude, longitude coordinates in decimal format.
*
* Example usage:
* proximity=51.952659,7.632473
*
* Values that are not valid coordinates are ignored.
*/
proximity?: string;
/**
* When set to 1 the behavior of the geocoder is changed to attempt to match the nearest road (as opposed to address). If possible we also fill additional information in the roadinfo annotation. Please see details API Documentation.
*/
roadinfo?: number;
/**
* When set to 1 we include only the address (excluding POI names) in the formatted string we return.
*
* Example usage: address_only=1
*
* As an example, by default a reverse geocoding request for the coordinates 50.976004, 11.336753 returns a formatted value of Goethes Gartenhaus, Corona-Schröter-Weg 1, 99425 Weimar, Germany, but if address_only=1 is specified the value would be simply Corona-Schröter-Weg 1, 99425 Weimar, Germany. This can be particularly useful when there are many stores/restaurants/whatever at a single location (for example a multi-story building).
*/
address_only?: number;
/**
* @deprecated Use `GeocodingOptions.proxyURL` instead.
* The URL of a proxy server to use for the request. This is useful if you want to hide your API Key.
*/
proxyURL?: string;
};
/**
* GeocodeRequest type is an alias for GeocodingRequest.
* @deprecated Use GeocodingRequest instead.
* This type is kept for backward compatibility, but it is recommended to use GeocodingRequest
* for new code.
*/
export type GeocodeRequest = GeocodingRequest & {};