Upload your map from a command line using API

Published March 25th, 2022

Admin API for map developers

One of the main challenges while working with GIS is the publication of maps and data on the internet. With the MapTiler Cloud API, you can automate these tasks from the terminal without using a browser. 

START NOW FOR FREE

New MapTiler Cloud Admin API

We have developed a new Admin API that allows you to change the metadata of already created tiles, add new ones, update or delete them. The API specification for it is located on MapTiler API Documentation Page.

API Authorization

Together with the admin API we have created the Service Credentials, a new way of authentication to sign the requests made to the API. While API Keys are used to accessing your maps, tiles, and data from your applications` frontend. The credentials are used to access the administration API. You can manage your credentials on your account credentials page.

2022-03-25-admin-api-2.jpg

Upload your geodata to the Cloud

There are numerous ways to send your requests to the API; whether you are a fan of API clients or go with the good old curl, don’t forget to set the Authorization header in the form of Token {YOUR_TOKEN} so we know it’s you making the requests. To make your life easier, we have also created a CLI utility to upload the tilesets.

The new admin API base URL is https://service.maptiler.com/v1

Doing the whole process manually via curl involves making multiple API calls. For example, calling the Admin API to start the ingest. The Admin API returns a Google Drive URL to upload the file. Then call the Google Drive API to upload the file and finally call the Admin API to process the file.

Example of ingest tileset container into a new tileset

curl -X POST -H 'Authorization: Token YOUR_CREDENTIAL_TOKEN' -H 'Content-Type: application/json' -d '{"filename":"YOUR_DATA.mbtiles","size":"DATA_FILE_SIZE_BYTES"}' https://service.maptiler.com/v1/tiles/ingest

Open-source MapTiler Cloud CLI

To make your life easier, we have developed the MapTiler Cloud CLI utility to upload the tilesets. This open-source tool is developed in Python and allows you to automate the process of uploading data to the cloud. You can access the code in the MapTiler Cloud CLI GitHub repository.

Once the application is installed, the process of uploading the data is as easy as typing the following command in a terminal.

maptiler-cloud --token=YOUR_CREDENTIAL_TOKEN tiles ingest YOUR_DATA.mbtiles

Check out the article How to upload MBTiles or GeoPackage to MapTiler Cloud using the API for more details on how to install and use the CLI tool.

If you don’t have a MapTiler Cloud account, you can create an account for FREE

Useful links

Share
Wladimir Szczerban

Wladimir Szczerban

Senior Developer Advocate
Published on March 25th, 2022
notification