You can now build a custom leaderboard for your event or challenge with help of the Mapillary API. Here's how.

The Mapillary community has sported a number of events throughout the globe, such as the Lesotho competition, mapping the common spaces in Ahmedabad, and a photo walk around the canals in Amsterdam. Recently, a Youthmappers challenge was launched in Uganda, for which we have built a leaderboard and an accompanying map for tracking coverage.

Uganda Mapillary challenge coverage

Whether we are directly or indirectly involved in the event, we’ve seen a demand for custom leaderboards to track progress and foster competition. In response, we have expanded the Mapillary API to support building your own leaderboard. The workflow for this involves a few simple steps.

  1. Get a client ID by registering an application called “My Leaderboard” here:

  2. Make a list of usernames (as many as you like!) to be involved in your competition, best stored in both a comma-separated value list:

  3. Use our API to build an initial leaderboard list. The call will be like this:,gyllen,quicksand&client_id=YOURCLIENTID
  4. The output of this API call is a JSON that looks like this:


  5. In this output, you can see that each username has the user_key as well as image_count inside curly brackets. If we had some dates in mind, we can filter by date by adding &start_time= and &end_time= to the URL, with dates in ISO 8601 format.

  6. For a leaderboard between April 1, 2017 and April 30, 2017, we can use:,gyllen,quicksand&client_id=YOURCLIENTID&start_time=2017-04-01&end_time=2017-04-30
  7. The results of this second call will look different when inspecting the image counts. This is because we just narrowed down the leaderboard to show only the specified date range:


  8. We can put this into an HTML document to start making a table with the help of Javascript. In the <head></head> section of your HTML document, let’s make a script that compiles these results into table rows. It will first require that we reference jQuery, then access the API call using jQuery.ajax() method with our API call as the url parameter.

      <script src=></script>

    The actual jQuery.ajax() method will go in the <body></body> tags of our HTML document.

        type: "get",
        dataType: "json",
        url: ",gyllen,katrinhumal,quicksand&client_id=YOURCLIENTID&start_time=2017-04-01&end_time=2017-04-30",
        success: function(data) {
  9. In the above, we have accessed the API call, and the JSON we get back—showing user info in curly brackets—is contained in the data variable on the same line as success. This is asking us what we want to do with the JSON once we have it, and I’ve currently put doSomething() as our function. We’ll change this to actually build a leaderboard. The next steps involve pushing the data into an HTML table.

  10. Let’s first add a table with an id="table" between the opening <body> tag and the opening <script> tag (line 2), then make our code push to that table (line 9). The convenient part of this is that the leaderboard already returns the users with the highest number of images first, so we don’t need to sort. We do need to run a for loop, to ensure that we add users from the leaderboard to the table.

  11. If you now preview this HTML document, the output looks like this:

    Mapillary leaderboard preview

  12. To see a complete code example of this, visit the Mapillary leaderboard Github repo. You can also add some styling to the table to make it look more traditional, using CSS.

With these basics, you can go your own direction, including building this into your own web page, or making a much more expanded leaderboard like the Uganda one above. It’s also possible to use JavaScript to associate each username with a team, and similarly build a second table to get team totals—however, that’s beyond the scope of the Mapillary API and a tutorial for another day.

Uganda leaderboard

Hopefully, this guide has sparked your interest in making custom leaderboards and will help you with your own Mapillary-themed events and competitions! Feel free to reach out to us with additional questions and take a look at our tips on events.


Tags for this post: tutorials community
comments powered by Disqus