Skip to main content

MapLarge REST API Python Client

Project description

MapLarge REST API Python Client

MapLarge is a platform for analysing and visualizing geospatial data. The maplargerest Python library enables Python applications to communicate with MapLarge servers via their Rest API.

Supported Python Versions

The MapLarge REST API Python Client is supported on the latest patch version of Python 3.9 through 3.13, the versions officially supported by the Python Software Foundation. See https://devguide.python.org/versions/ for more information.

Development Environment Creation

Developing with the MapLarge Python REST client is as simple as setting up the your development environment, installing the client library, and being coding.

1. Create Virtual Environment

Create a Python environment for building and testing this project.

Windows PowerShell

python -m venv .venv
.venv\Scripts\activate.ps1

Windows Command Line

python -m venv .venv
.venv\Scripts\activate.bat

Linux or Mac

python3 -m venv .venv
source .venv/bin/activate

2. Install Dependencies

Install REST client, as awll as any python packages needed for subsequent work.

If you add maplargerest to your local requirements.txt, you can install everything at once with the standard command:

pip install -r requirements.txt

Alternatively, you can install the REST client alone:

pip install maplargerest

Using the MapLarge REST client

The python client is built to work against the standard REST API the are building into a MapLarge.Server deployment. To view the documentation for these REST endpoints, simply visit the Swagger endpoint at your local installation:

https://<hostname>/swagger

Usage Example

Typical usage of the REST client starts with setting up a REST client with the proper credentials.

from maplargerest.endpoints import RestClient, items

client = RestClient(
	url="https://my.maplarge.com",
	username="user@example.com",
	password="password")

# Get a list of tables in the 'test' account
tables = items(client.tables.list(account="test"))

The same pattern is used for importing data, setting up the OGC catalog, or other administrative tasks:

Importing table data from remote sources:

def clear_progress() -> None:
    """Erase the previous import progress."""
    m['prev_message'] = None


def print_progress(imp: Import) -> None:
    """Display the import progress."""
    if m['prev_message'] != imp.message:
        print(f'\t\t{imp.message}')
        m['prev_message'] = imp.message

"""Create required table """
import_ = client.tables.post(
    account=acct,
    name=tblname,
    body=CreateTableRequest(
        file_url=tblurl,
        options=impopts)
)
clear_progress()
print_progress(import_)
tables = items(client.follow(import_, 
    "result",
    result_type=RestList,
    item_type=TableVersion,
    status_update=print_progress
))
return tables[0]        

Adding entries to the OGC catalog:

try:
  # create the entry
  newEntry: CatalogEntry = CatalogEntry()
  newEntry.group = entry['group']
  newEntry.name = entry['name']
  newEntry.active = True
  newEntry.title = entry['title']
  newEntry.description = entry['description']
  newEntry.data_source = entry['dataSource']
  newEntry.source_type = entry['type']
  created = self.create_entry(newEntry)
except Exception as ex:
  print(ex)

Adding a series of accounts:

accts = items(client.accounts.list())
for idx, acct in enumerate(req_accts):
    if any(a for a in accts if a.code == acct['name']):
        print("Account exists: ", acct)
    else:
        print("Account does not exist: ", acct)
        name = acct['name']
        descr = acct['description']
        client.accounts.post(
        body=CreateAccountRequest(
            code=name,
            name=name,
            description=descr)
        )

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maplargerest-4.110.dev20250730195004.tar.gz (228.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maplargerest-4.110.dev20250730195004-py3-none-any.whl (220.4 kB view details)

Uploaded Python 3

File details

Details for the file maplargerest-4.110.dev20250730195004.tar.gz.

File metadata

File hashes

Hashes for maplargerest-4.110.dev20250730195004.tar.gz
Algorithm Hash digest
SHA256 98691956f0ffa7874523eb35112270d8f2ffe39be4512a4fc169289e47bf08b8
MD5 64c2e8e879868e0b193df2255a9190f1
BLAKE2b-256 ad52b49ccbde0aa29507719b8a5f38f23a984558aa931e8b340807eaf5ae45dc

See more details on using hashes here.

File details

Details for the file maplargerest-4.110.dev20250730195004-py3-none-any.whl.

File metadata

File hashes

Hashes for maplargerest-4.110.dev20250730195004-py3-none-any.whl
Algorithm Hash digest
SHA256 7ecc9e55a275794fbaacabeb6a418123a3801edfa6271580d3667c656cf4f6dc
MD5 cd2a99430e44f4cc7b2f027270dde1f9
BLAKE2b-256 8cf8b5ef947d57d8294cbc504c64d69fe4a11976d3ce3decb18ca5316c88cd00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page