This repository demonstrates 6 different ways to interact with the geocat API using Python scripts.
- Logs in to geocat using credentials from
config.py
. - Retrieves and prints the XSRF token.
- Shows how to authenticate and make authorized requests.
- Performs a metadata search using a JSON query.
- Prints out the UUID and title of each found record.
- Demonstrates how to use the
/search/records/_search
endpoint.
- Downloads a metadata record as XML using its UUID.
- Saves or prints the XML content.
- Uses the
/records/{uuid}/formatters/xml
endpoint.
- Downloads a metadata record as a MEF (Metadata Exchange Format) ZIP file.
- Saves the MEF file locally.
- Uses the
/records/{uuid}/formatters/zip
endpoint.
- Demonstrates how to batch edit metadata records.
- Prepares a payload to update or delete metadata fields using XPath.
- Previews and applies changes using the
/records/batchediting
endpoints.
- Uploads a new metadata record as XML or MEF.
- Shows how to set parameters for publishing and validation.
- Uses the
/records
endpoint for file uploads.
- Install dependencies:
pip install requests
- Create a
config.py
file with your credentials:GEOCAT_USERNAME = "your_username" GEOCAT_PASSWORD = "your_password"
Run any script with:
python <script_name.py>
For example, to upload a record:
python 6_upload_record.py
See each script for more details and endpoint references.