1.0.4 • Published 7 months ago

gestjs v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Gest.js

GitHub Workflow Status (with event) License Version TypeScript npm

SDK for working with openStreetMap REST API

You can read more in here: https://wiki.openstreetmap.org/wiki/API_v0.6

⚠️⚠️⚠️ Some of functions need authentication. Please make sure that you signed up in the webiste (main and dev) and use you auth1.0 or auth2.0 method to access these functions. ⚠️⚠️⚠️

Installation

Fitst install lib: npm install gestjs

Import and create an object. You can pass the API url that you want to use it with specific version. The default api url is Dev url and version is 0.6

import Gestjs from 'gestjs'

// With default url and api version
// devUrl: https://master.apis.dev.openstreetmap.org/api
// apiVersion: 0.6
const gestjs = new Gestjs();

// With specific url and api version
const apiUrl = 'https://api.openstreetmap.org/api'
const apiVersion = '0.6'
const gestjs = new Gestjs(apiUrl,apiVersion);

Usage

After making object, you can use functions in object and get result in XML and JSON fromat.

Versions

The versions function is used to retrieve a list of API versions supported by this instance.

ParameterTypeDescription
returnMethod"xml" | "json"(optional) Choose return method, default is "json".
Return TypeDescription
Promise\<XMLDocument | JSON | Error>Returns a list of API versions supported by this instance.

Capabilities

The capabilities function is meant to provide information about the capabilities and limitations of the current API.

ParameterTypeDescription
returnMethod"xml" | "json"(optional) Choose return method, default is "json".
Return TypeDescription
Promise\<XMLDocument | JSON | Error>Returns an XML document (content type text/xml) or JSON describing the capabilities and limitations of the current API.

Map

The map function is retrieving map data by bounding box: GET /api/0.6/map

ParameterTypeDescription
boxObjboxTObject containing bounding box coordinates:
- left: Longitude of the left (westernmost) side of the bounding box.
- bottom: Latitude of the bottom (southernmost) side of the bounding box.
- right: Longitude of the right (easternmost) side of the bounding box.
- top: Latitude of the top (northernmost) side of the bounding box.
Return TypeDescription
Promise\<XMLDocument | Error>Returns an XML document containing all nodes that are inside the given bounding box, any relations that reference them, all ways that reference at least one node inside the bounding box, any relations that reference those ways, and any nodes outside the bounding box that the ways may reference. This does not apply recursively.

Permissions

The permissions function is retrieving permissions: GET /api/0.6/permissions or /api/0.6/permissions.json

ParameterTypeDescription
returnMethod"json" | "xml"(optional) Choose return method, default is "json".
Return TypeDescription
Promise\<XMLDocument | JSON | Error>Returns information about permissions:
- If the API client is not authorized, an empty list of permissions will be returned.
- If the API client uses Basic Auth, the list of permissions will contain all permissions.
- If the API client uses OAuth 1.0a, the list will contain the permissions actually granted by the user.
- If the API client uses OAuth 2.0, the list will be based on the granted scopes. Note that for compatibility reasons, all OAuth 2.0 scopes will be prefixed by "allow_", e.g. scope "read_prefs" will be shown as permission "allow_read_prefs".

Changeset create

The changesetCreate function creates: PUT /api/0.6/changeset/create

ParameterTypeDescription
xmlBodystring(optional) The XML body for the changeset creation.
Return TypeDescription
Promise\<XMLDocument | Error>Returns the ID of the newly created changeset with a content type of text/plain.

Changeset get

The changesetGet function reads: GET /api/0.6/changeset/#id?include_discussion=true or /api/0.6/changeset/#id.json?include_discussion=true

ParameterTypeDescription
idstrOrNumThe ID of the changeset to retrieve.
include_discussionbooleanIndicates whether the result should contain the changeset discussion or not. If set to true, the discussion is returned; if empty or omitted, the discussion will not be in the result.
returnMethod"json" | "xml"(optional) Choose return method, default is "json".
Return TypeDescription
Promise\<XMLDocument | JSON | Error>Returns the changeset with the given ID in OSM-XML format.

Changeset update

The changesetUpdate function is for updating tags on the changeset, e.g. changeset comment=foo

ParameterTypeDescription
idstrOrNumThe ID of the changeset to update. The user issuing this API call has to be the same that created the changeset.
xmlBodystringText/xml data for the update.
Return TypeDescription
Promise\<XMLDocument | Error>Returns an OSM document containing the new version of the changeset with a content type of text/xml.

Changeset close

The changesetClose function closes a changeset. A changeset may already have been closed without the owner issuing this API call. In this case an error code is returned.

ParameterTypeDescription
idstrOrNumThe ID of the changeset to close. The user issuing this API call has to be the same as the one who created the changeset.
Return TypeDescription
Promise\<XMLDocument | Error>Upon successful closing of a changeset (HTTP status code 200), nothing is returned.

Changeset download

The changesetDownload function returns the OsmChange document describing all changes associated with the changeset.

ParameterTypeDescription
idstrOrNumThe ID of the changeset for which the OsmChange is requested.
Return TypeDescription
Promise\<XMLDocument | Error>Returns the OsmChange document describing all changes associated with the specified changeset with a content type of text/xml.

Changeset get query

The changesetGetQuery function is for querying changesets. It supports querying by different criteria.

ParameterTypeDescription
inputDatachangesetGetQueryTAn object containing various query parameters for filtering changesets:
- box: Bounding box in the format bbox=min_lon,min_lat,max_lon,max_lat (W,S,E,N) to find changesets within the given bounding box.
- user: User ID or display name to find changesets by the user with the given user ID or display name (providing both is an error).
- display_name: Display name to find changesets by the user with the given display name.
- time: Time range for finding changesets. Can be a single timestamp T1 or a range T1,T2.
- open: Set to true to find only open changesets that are not closed or have not reached the element limit.
- closed: Set to true to find only closed changesets or those that have reached the element limit.
- changesets: Find changesets with specific IDs (comma-separated).
- limit: Maximum number of changesets to return (1 to maximum limit value).
Return TypeDescription
Promise\<XMLDocument | Error>Returns a list of all changesets ordered by creation date. The <osm> element may be empty if there were no results for the query. The response is sent with a content type of text/xml.

Changeset diff upload

The changesetGetQuery function calls files in the OsmChange format can be uploaded to the server. This is guaranteed to be running in a transaction. So either all the changes are applied or none.

ParameterTypeDescription
idstrOrNumThe ID of the changeset this diff belongs to.
bodyanyThe OsmChange file data to be uploaded to the server.
Return TypeDescription
Promise\<XMLDocument | Error>If a diff is successfully applied, an XML document (content type text/xml) is returned in a specific format.

Changeset comment

The changesetComment function adds a comment to a changeset. The changeset must be closed.

⚠️ Auth needed

ParameterTypeDescription
idstrOrNumThe ID of the changeset this comment belongs to.
commentstringThe comment text to be added. The content type is "application/x-www-form-urlencoded".
Return TypeDescription
Promise\<XMLDocument | Error>This request needs to be done as an authenticated user.

Changeset subscribe

The changesetSubscribe function subscribes to the discussion of a changeset to receive notifications for new comments.

⚠️ Auth needed

ParameterTypeDescription
idstrOrNumThe ID of the changeset to which the subscription belongs.
Return TypeDescription
Promise\<XMLDocument | Error>This request needs to be done as an authenticated user.

Changeset unsubscribe

The changesetUnsubscribe function unsubscribe from the discussion of a changeset to stop receiving notifications.

⚠️ Auth needed

ParameterTypeDescription
idstrOrNumThe ID of the changeset from which to unsubscribe.
Return TypeDescription
Promise\<XMLDocument | Error>This request needs to be done as an authenticated user.

Changeset hide comment

The changesetHideComment function sets visible flag on changeset comment to false.

⚠️ Auth needed

ParameterTypeDescription
idstrOrNumThe ID of the changeset comment to flag as not visible.
Return TypeDescription
Promise\<XMLDocument | Error>This request needs to be done as an authenticated user with moderator role. Note that the changeset comment ID differs from the changeset ID.

Changeset unhide comment

The changesetUnhideComment function sets visible flag on changeset comment to true.

⚠️ Auth needed

ParameterTypeDescription
idstrOrNumThe ID of the changeset comment to flag as visible.
Return TypeDescription
Promise\<XMLDocument | Error>This request needs to be done as an authenticated user with moderator role. Note that the changeset comment ID differs from the changeset ID.

Create node

The createNode function creates a new element of the specified type. Note that the entire request should be wrapped in a <osm>...</osm> element.

ParameterTypeDescription
xmlBodystringThe data of the node to be created.
Return TypeDescription
Promise\<XMLDocument | Error>Returns the ID of the newly created element with a content type of text/plain.

Create way

The createWay function creates a new element of the specified type. Note that the entire request should be wrapped in a <osm>...</osm> element.

ParameterTypeDescription
xmlBodystringThe data of the way to be created.
Return TypeDescription
Promise\<XMLDocument | Error>Returns the ID of the newly created element with a content type of text/plain.

Create relation

The createRelation function creates a new element of the specified type. Note that the entire request should be wrapped in a <osm>...</osm> element.

ParameterTypeDescription
xmlBodystringThe data of the relation to be created.
Return TypeDescription
Promise\<XMLDocument | Error>Returns the ID of the newly created element with a content type of text/plain.

Get node

The getNode function reads: GET /api/0.6/node/#id or /api/0.6/node/#id.json

ParameterTypeDescription
idstrOrNumThe ID of the node to retrieve.
returnMethod"json" | "xml"(optional) Choose return method, default is "json".
Return TypeDescription
Promise\<XMLDocument | JSON | Error>Returns the XML representation of the element.

Get way

The getWay function reads: GET /api/0.6/way/#id or /api/0.6/way/#id.json

ParameterTypeDescription
idstrOrNumThe ID of the way to retrieve.
returnMethod"json" | "xml"(optional) Choose return method, default is "json".
Return TypeDescription
Promise\<XMLDocument | JSON | Error>Returns the XML representation of the element.

Get relation

The getRelation function reads: GET /api/0.6/relation/#id or /api/0.6/relation/#id.json

ParameterTypeDescription
idstrOrNumThe ID of the relation to retrieve.
returnMethod"json" | "xml"(optional) Choose return method, default is "json".
Return TypeDescription
Promise\<XMLDocument | JSON | Error>Returns the XML representation of the element.

Update node

The updateNode function updates data from a preexisting element. A full representation of the element as it should be after the update has to be provided. Any tags, way-node refs, and relation members that remain unchanged must be in the update as well. A version number must be provided as well, it must match the current version of the element in the database.

ParameterTypeDescription
idstrOrNumThe ID of the node to update.
xmlBodystringThe full representation of the node after the update. It should include any unchanged tags, way-node refs, and relation members. A version number must be provided, matching the current version of the element in the database.
Return TypeDescription
Promise\<XMLDocument | Error>Returns the new version number of the updated node with a content type of text/plain.

Update way

The updateWay function updates data from a preexisting element. A full representation of the element as it should be after the update has to be provided. Any tags, way-node refs, and relation members that remain unchanged must be in the update as well. A version number must be provided as well, it must match the current version of the element in the database.

ParameterTypeDescription
idstrOrNumThe ID of the way to update.
xmlBodystringThe full representation of the way after the update. It should include any unchanged tags, way-node refs, and relation members. A version number must be provided, matching the current version of the element in the database.
Return TypeDescription
Promise\<XMLDocument | Error>Returns the new version number of the updated way with a content type of text/plain.

Update relation

The updateRelation function updates data from a preexisting element. A full representation of the element as it should be after the update has to be provided. Any tags, way-node refs, and relation members that remain unchanged must be in the update as well. A version number must be provided as well, it must match the current version of the element in the database.

ParameterTypeDescription
idstrOrNumThe ID of the relation to update.
xmlBodystringThe full representation of the relation after the update. It should include any unchanged tags, way-node refs, and relation members. A version number must be provided, matching the current version of the element in the database.
Return TypeDescription
Promise\<XMLDocument | Error>Returns the new version number of the updated relation with a content type of text/plain.

Delete node

The deleteNode function expects a valid XML representation of the element to be deleted.

ParameterTypeDescription
idstrOrNumThe ID of the way to delete.
xmlBodystringA valid XML representation of the way to be deleted.
Return TypeDescription
Promise\<XMLDocument | Error>Returns the new version number with a content type of text/plain.

Delete way

The deleteWay function expects a valid XML representation of the element to be deleted.

ParameterTypeDescription
idstrOrNumThe ID of the node to delete.
xmlBodystringA valid XML representation of the node to be deleted.
Return TypeDescription
Promise\<XMLDocument | Error>Returns the new version number with a content type of text/plain.

Delete relation

The deleteRelation function expects a valid XML representation of the element to be deleted.

ParameterTypeDescription
idstrOrNumThe ID of the relation to delete.
xmlBodystringA valid XML representation of the relation to be deleted.
Return TypeDescription
Promise\<XMLDocument | Error>Returns the new version number with a content type of text/plain.

Get node history

The getNodeHistory function gets node history: GET /api/0.6/way/#id/history

ParameterTypeDescription
idstrOrNumThe ID of the way to retrieve the history for.
Return TypeDescription
Promise\<XMLDocument | Error>Retrieves all old versions of the specified way as an XML document.

Get way history

The getWayHistory function gets way history: GET /api/0.6/way/#id/history

ParameterTypeDescription
idstrOrNumThe ID of the relation to retrieve the history for.
Return TypeDescription
Promise\<XMLDocument | Error>Retrieves all old versions of the specified relation as an XML document.

Get relation history

The getRelationHistory function gets relation history: GET /api/0.6/relation/#id/history

ParameterTypeDescription
idstrOrNumThe ID of the relation to retrieve the history for.
Return TypeDescription
Promise\<XMLDocument | Error>Retrieves all old versions of the specified relation as an XML document.

Get node version

The getNodeVersion function gets node version: GET /api/0.6/node/#id/#version

ParameterTypeDescription
idstrOrNumThe ID of the node to retrieve a specific version for.
versionstrOrNumThe specific version number of the node to retrieve.
Return TypeDescription
Promise\<XMLDocument | Error>Retrieves a specific version of the specified node as an XML document.

Get way version

The getWayVersion function gets way version: GET /api/0.6/way/#id/#version

ParameterTypeDescription
idstrOrNumThe ID of the way to retrieve a specific version for.
versionstrOrNumThe specific version number of the way to retrieve.
Return TypeDescription
Promise\<XMLDocument | Error>Retrieves a specific version of the specified node as an XML document.

Get relation version

The getRelationVersion function gets relation version: GET /api/0.6/relation/#id/#version

ParameterTypeDescription
idstrOrNumThe ID of the relation to retrieve a specific version for.
versionstrOrNumThe specific version number of the relation to retrieve.
Return TypeDescription
Promise\<XMLDocument | Error>Retrieves a specific version of the specified node as an XML document.

Get nodes parameters

The getNodesParameters function allows a user to fetch multiple nodes at once.

ParameterTypeDescription
parametersany[]An array of parameters to specify the nodes to fetch. Each parameter should be the same as in the URL (e.g., 123, 456, 789). Version numbers for each object may be optionally provided following a lowercase "v" character (e.g., 421586779v1, 421586779v2).
Return TypeDescription
Promise\<XMLDocument | Error>Retrieves multiple versions of the specified nodes as an XML document.

Get ways parameters

The getWaysParameters function allows a user to fetch multiple ways at once.

ParameterTypeDescription
parametersany[]An array of parameters to specify the ways to fetch. Each parameter should be the same as in the URL (e.g., 123, 456, 789). Version numbers for each object may be optionally provided following a lowercase "v" character (e.g., 421586779v1, 421586779v2).
Return TypeDescription
Promise\<XMLDocument | Error>Retrieves multiple versions of the specified ways as an XML document.

Get relations parameters

The getRelationsParameters function allows a user to fetch multiple relations at once.

ParameterTypeDescription
parametersany[]An array of parameters to specify the relations to fetch. Each parameter should be the same as in the URL (e.g., 123, 456, 789). Version numbers for each object may be optionally provided following a lowercase "v" character (e.g., 421586779v1, 421586779v2).
Return TypeDescription
Promise\<XMLDocument | Error>Retrieves multiple versions of the specified relations as an XML document.

Get relations for node

The getRelationsForNode function to get relations for node: GET /api/0.6/node/#id/relations

ParameterTypeDescription
idstrOrNumThe ID of the node for which to retrieve relations.
Return TypeDescription
Promise\<XMLDocument | Error>Returns an XML document containing all (not deleted) relations in which the given node is used.

Get relations for way

The getRelationsForWay function to get relations for way: GET /api/0.6/way/#id/relations

ParameterTypeDescription
idstrOrNumThe ID of the way for which to retrieve relations.
Return TypeDescription
Promise\<XMLDocument | Error>Returns an XML document containing all (not deleted) relations in which the given node is used.

Get relations for relation :)

The getRelationsForRelation function to get relations for relation: GET /api/0.6/relation/#id/relations

ParameterTypeDescription
idstrOrNumThe ID of the relation for which to retrieve relations.
Return TypeDescription
Promise\<XMLDocument | Error>Returns an XML document containing all (not deleted) relations in which the given node is used.

Full get way

The fullGetWay function calls retrieves a way and all other elements referenced by it.

ParameterTypeDescription
idstrOrNumThe ID of the way to retrieve, along with all other elements referenced by it.
Return TypeDescription
Promise\<XMLDocument | Error>Retrieves the specified way along with the full XML representation of all nodes referenced by the way.

Full get relation

The fullGetRelation function calls retrieves a relation and all other elements referenced by it.

ParameterTypeDescription
idstrOrNumThe ID of the relation to retrieve, along with all other elements referenced by it.
Return TypeDescription
Promise\<XMLDocument | Error>Retrieves the specified relation along with all nodes, ways, and relations that are members of the relation, plus all nodes used by ways referenced by the relation. The same recursive logic is not applied to relations.

Redaction node

The redactionNode function originally created for the ODbL license change to hide contributions from users that did not accept the new CT/licence. It is now used by the DWG to hide old versions of elements containing data privacy or copyright infringements. All API retrieval request for the element #version will return an HTTP error 403.

ParameterTypeDescription
idstrOrNumThe ID of the node for which to apply redaction.
versionstrOrNumThe specific version number of the node to redact.
redaction_idstrOrNumThe ID of the redaction operation to apply to the node.
Return TypeDescription
Promise\<XMLDocument | Error>Applies redaction to the specified version of the node based on the provided redaction ID. All API retrieval requests for the redacted element will return an HTTP error 403.

Redaction way

The redactionWay function originally created for the ODbL license change to hide contributions from users that did not accept the new CT/licence. It is now used by the DWG to hide old versions of elements containing data privacy or copyright infringements. All API retrieval request for the element #version will return an HTTP error 403.

ParameterTypeDescription
idstrOrNumThe ID of the way for which to apply redaction.
versionstrOrNumThe specific version number of the way to redact.
redaction_idstrOrNumThe ID of the redaction operation to apply to the way.
Return TypeDescription
Promise\<XMLDocument | Error>Applies redaction to the specified version of the way based on the provided redaction ID. All API retrieval requests for the redacted element will return an HTTP error 403.

Redaction relation

The redactionRelation function originally created for the ODbL license change to hide contributions from users that did not accept the new CT/licence. It is now used by the DWG to hide old versions of elements containing data privacy or copyright infringements. All API retrieval request for the element #version will return an HTTP error 403.

ParameterTypeDescription
idstrOrNumThe ID of the relation for which to apply redaction.
versionstrOrNumThe specific version number of the relation to redact.
redaction_idstrOrNumThe ID of the redaction operation to apply to the relation.
Return TypeDescription
Promise\<XMLDocument | Error>Applies redaction to the specified version of the relation based on the provided redaction ID. All API retrieval requests for the redacted element will return an HTTP error 403.

Get GPS point

The getGpsPoint function retrieve the GPS track points that are inside a given bounding box (formatted in a GPX format). The maximal width (right - left) and height (top - bottom) of the bounding box is 0.25 degree.

ParameterTypeDescription
boxObjboxTAn object defining the bounding box coordinates. It includes the left, bottom, right, and top coordinates of the bounding box.
pageNumberstrOrNumThe number of the page to retrieve, specifying which group of 5,000 points to return.
Return TypeDescription
Promise\<XMLDocument | Error>Retrieves GPS track points that are inside the specified bounding box and are formatted in GPX format. The function supports pagination, allowing you to retrieve points in batches of 5,000 based on the page number.

Create gpx

The createGpx function uploads a GPX file or archive of GPX files. Requires authentication.

⚠️ Auth needed

ParameterTypeDescription
bodyanyThe parameters required in a multipart/form-data HTTP message for uploading a GPX file or archive of GPX files.
Return TypeDescription
Promise\<XMLDocument | Error>Uploads a GPX file or archive of GPX files. This function requires authentication and returns a number representing the ID of the new GPX file.

Update gpx

The updateGpx function updates a GPX file. Only usable by the owner account. Requires authentication.

⚠️ Auth needed

ParameterTypeDescription
idstrOrNumThe ID of the GPX file to update. Only usable by the owner account. Requires authentication.
bodyanyThe parameters required in a multipart/form-data HTTP message for updating the GPX file.
Return TypeDescription
Promise\<XMLDocument | Error>Updates a GPX file. This function requires authentication and returns an empty response body.

Delete gpx

The deleteGpx function deletes a GPX file. Only usable by the owner account. Requires authentication.

⚠️ Auth needed

ParameterTypeDescription
idstrOrNumThe ID of the GPX file to delete. Only usable by the owner account. Requires authentication.
bodyanyThe parameters required in a multipart/form-data HTTP message for deleting the GPX file.
Return TypeDescription
Promise\<XMLDocument | Error>Deletes a GPX file. This function requires authentication and returns an empty response body.

Download meta deta gpx

The downloadMetaDetaGpx function has access to the metadata about a GPX file. Available without authentication if the file is marked public. Otherwise only usable by the owner account and requires authentication.

ParameterTypeDescription
idstrOrNumThe ID of the GPX file to access metadata about. Available without authentication if the file is marked public. Otherwise, only usable by the owner account and requires authentication.
Return TypeDescription
Promise\<XMLDocument | Error>Accesses metadata about a GPX file. This function can be used without authentication if the file is marked as public. Otherwise, it requires authentication and returns OSM/XML metadata of the GPX file.

Download data gpx

The downloadDataGpx function downloads the full GPX file. Available without authentication if the file is marked public. Otherwise only usable by the owner account and requires authentication. ' The response will always be a GPX format file if you use a .gpx URL suffix, a XML file in an undocumented format if you use a .xml URL suffix, otherwise the response will be the exact file that was uploaded.

ParameterTypeDescription
idstrOrNumThe ID of the GPX file to download. Available without authentication if the file is marked public. Otherwise, only usable by the owner account and requires authentication.
Return TypeDescription
Promise\<XMLDocument | Error>Downloads the full GPX file. This function can be used without authentication if the file is marked as public. Otherwise, it requires authentication and returns OSM/XML data of the GPX file. The response format depends on the URL suffix used: .gpx for GPX format, .xml for XML format, or the exact uploaded file format.

List gpx files

The listGpxFiles function gets a list of GPX traces owned by the authenticated user: Requires authentication.

⚠️ Auth needed

Return TypeDescription
Promise\<XMLDocument | Error>Retrieves a list of GPX traces owned by the authenticated user. Requires authentication. This call always returns GPX traces for the current authenticated user only.

Get user detail

The getUserDetail function gets details of a user: GET /api/0.6/user/#id or /api/0.6/user/#id.json

ParameterTypeDescription
idstrOrNumThe id of the user.
returnMethod"json" or "xml"(optional) Choose return method, default is "json".
Return TypePromise<XMLDocument \| JSON \| Error>Retrieves user details or an empty file if the user has been deleted.

Get multi users details

The getMultiUsersDetails function gets details of multiple users: GET /api/0.6/users?users=#id1,#id2,...,#idn or /api/0.6/users.json?users=#id1,#id2,...,#idn

ParameterTypeDescription
idsstrOrNum[]An array of user ids.
returnMethod"json" or "xml"(optional) Choose return method, default is "json".
Return TypePromise<XMLDocument \| JSON \| Error>Retrieves user details for the specified user ids or an empty file if any of the users have been deleted.

Get detail of logged in user

The getDetailOfLoggedInUser function gets details of the logged-in user: GET /api/0.6/user/details or /api/0.6/user/details.json

ParameterTypeDescription
1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago