The `osm-api` package provides a robust JavaScript/TypeScript wrapper for interacting with the OpenStreetMap API, designed for both Node.js (requiring Node.js >=18) and browser environments. Currently stable at version 4.0.0 (last published February 2026), the library facilitates common OSM operations such as fetching map features, managing changesets, user data, messaging, and notes. It automatically converts OSM's XML responses into JSON format, simplifying data handling for developers. A key differentiator is its use of OAuth 2 for authentication, enhancing security by avoiding the direct exposure of OAuth `client_secret`s. The library is lightweight (24 kB gzipped) and offers a simpler API and TypeScript support compared to older alternatives like `osm-request`. While a specific fixed release cadence is not explicitly stated, updates are released to address critical changes, such as the security patches to OSM's authentication flow, requiring timely library updates (e.g., v3.0.0 for a specific popup mode authentication fix).
npm install osm-apiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates fetching a public OSM feature and outlines the pattern for authenticated API calls using OAuth 2, including necessary placeholders.
Update `osm-api` to version 3.0.0 or higher. Additionally, update the code snippet in your `land.html` file to the latest version as per the popup documentation.
Ensure your Node.js environment is updated to version 18 or newer. Use a version manager like `nvm` or `volta` to manage Node.js versions.
Familiarize yourself with the OSM API usage policy and guidelines for imports/automated edits. Consult the local community for significant automated operations.
Ensure `client_id` and `redirect_uri` are correctly registered with OpenStreetMap and precisely match the values used in your application's `login` configuration. Never expose your `client_secret` in client-side code.
Implement robust error handling, retry mechanisms with exponential backoff, and consider caching strategies for read-only data. For heavy usage or large data needs, consider using Planet.osm data or commercial providers, or hosting your own tiles.
For browsers, ensure `<script src="https://unpkg.com/osm-api@latest"></script>` is included before your script. For modern Node.js/bundled environments, use `import * as OSM from 'osm-api';`.
Change your import statement to `import * as OSM from 'osm-api';` to correctly import the namespace.
Upgrade `osm-api` to version 3.0.0 or newer via `npm install osm-api@latest` and ensure your `land.html` file includes the latest required code snippet for popup authentication.
Verify your OAuth 2 `client_id`, `redirect_uri`, and requested `scope` are correct and that the user has successfully completed the authentication flow and granted necessary permissions. Ensure your tokens are fresh if managing them manually.
No dependency data recorded yet.