This tutorial covers a MapBox API Upload uploading GeoJSON data to MapBox using Node.js and MapBox’s mapbox-sdk-js.

MapBox Demo Image

I love MapBox

First let me say, MapBox is my favourite software right now. Everything is well thought out, looks great and produces slick looking products. If you haven’t seen them already, head over to the site to see how fluid and powerful the demos are. P.s. check out how cool GitHub’s formatting of GeoJSON data is below!

MapBox API Upload

This walkthrough will cover the following steps:

  • Create a MapBox Account
  • Create an API Access token
  • Install Node.js
  • Download sample code
  • Upload the GeoJSON sample to your MapBox account

MapBox account and API Access Token

First Sign up for a MapBox account. Next, in the Account Settings, create an API Access Token. The API Access Token system enables individual read/write conditions for various concerns.

Copy the security settings in the image below and make note of the Private Token ID.

MapBox Access Token Settings

Node.js Installation and configuration

  • Install Node.js if you don’t have it installed already
  • Clone the code held in Gist. This will create a folder called upload-to-mapbox (this is a single line to copy and paste)
    git clone upload-to-mapbox
  • Replace the accessToken in index.js that you downloaded with your own Private Token ID that you made in the previous step
  • Now run the following commands:
    npm install
    node index.js

The application takes the following steps:

  • Ask CloudFront to get some temporary credentials for Amazon S3 file storage
  • Use the credentials to connect, then upload the test.geojson file
  • Ask MapBox to convert the test.geojson DataSet into a Vector Tile


If all goes well, you will see a bunch of output in your Terminal window. You will also see some confirmation in MapBox as a notification.

Upload successful


Keep in mind that MapBox has an asynchronous architecture meaning that you won’t always see immediate results. Processing and transformations occur in their own time.

Cloning the GIT repository will include the files below.  See the full Gist here

Please follow and like us: