Access with Python

Using the Integration API via Python

The Integration API can be access from python for automation of tasks such as updating data. In the example below we:

  • Login using OAuth2 to the Mapspeople autorization server

  • Define a GeoData object we want to change

  • Send the updated GeoData to the integration API using the access token

Note For this example to work you'll need to insert you own username and password in the second line of code

Login

There are two authentication flows you can use: username/password and Client Id/Secret. The difference boils down to the payload you will be sending to the authorization server. For User/Pass the payload should be formatted like this:

grant_type=password&client_id=client&[email protected]&password=your_password_here

For Client Id/Secret the payload should be formatted like this:

grant_type=client_credentials&client_id=your_client&client_secret=your_secret'

For more information about client Id/Secret you can read about it here:\

Client credentials flow

Example script

The code below is meant as an example, not final production code. Eg. storing username/password in code is not recommended; It's only done here to keep things short and easy to read. Also do note that the example here tries to change data in the read-only demo solution which will fail - it's just an example. Change the solution ID, username password and json content to something in your solution and it will work though.

With this in mind, here is the example:

Last updated

Was this helpful?