Async Python client for interacting with the KatapultPro API.
Project description
KatapultAPI
katapultAPI is a Python module designed to handle requests made to the Katapult API.
Installation & Setup
pip install katapult-api
Usage
Getting a Job list and Job Details
import logging.config
import asyncio
# Not required but the client itself has logging functionality to help track requests.
logger = logging.getLogger(__name__)
logging.basicConfig(
level=logging.DEBUG,
format='[%(levelname)s] %(asctime)s - %(name)s - %(message)s'
)
from katapult_api.katapult import Katapult
from katapult_api.utils import task_handler
async def main():
# Sets up the aiohttp session and closes it after finishing.
async with Katapult(api_key="YOURAPIKEY") as katapult:
# Returns a Response object that contains attributes such as return status, content, and even a json() method.
job_lists = await katapult.job_lists()
# Here we build 20 payloads that will be sent out at the same time.
job_ids = [{"job_id":key} for key in list(job_lists.json().keys())[:20]]
# Not required but makes setting up async tasks easy, pass in a job name and a list of dicts that contain
# expected params.
results = await task_handler(katapult.job,job_ids)
return results
if __name__ == '__main__':
logger.info(f"Getting jobs...")
jobs = asyncio.run(main())
logger.info(f"Finished, got {len(jobs)} jobs.")
Creating a Node
import asyncio
# ...possible logging
from katapult_api.katapult import Katapult
async def main():
async with Katapult(api_key="YOURAPIKEY") as katapult:
# get job id from job_lists endpoint...
job_id = "-ABC123"
# create a node by passing job id, lat/long, and a flat dict of attributes to write to the node
results = await katapult.create_node(job_id,30.0817,-97.843,{"OID":123,"my_custom_attr":"howdy partner"})
return results
if __name__ == '__main__':
results = asyncio.run(main())
KatapultNice Usage
import logging.config
import asyncio
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
logger = logging.getLogger(__name__)
from katapult_api.katapult import Katapult
from katapult_api.katapult_nice import KatapultNice
from katapult_api.utils import task_handler
async def main(api_key: str):
async with KatapultNice(api_key=api_key) as nice:
job_lists = await nice.job_lists()
job_ids = [{"job_id": key} for key in list(job_lists.json().keys())[:20]]
results = await task_handler(nice.job_nodes, job_ids)
return results
if __name__ == '__main__':
api_key = "api_key"
logger.info(f"Getting jobs...")
jobs = asyncio.run(main(api_key))
logger.info(f"Finished, got {len(jobs)} jobs.")
Resources
- https://documenter.getpostman.com/view/9081167/SVtVV93W: Katapultpro API V1
- https://github.com/KatapultDevelopment/katapult-pro-api-documentation?tab=readme-ov-file: Katapultpro Github
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file katapult_api-1.2.1.tar.gz.
File metadata
- Download URL: katapult_api-1.2.1.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b8a66daec4c04e426891a12c777b2e352633918ed8e21078b5417c9e58f8a1e
|
|
| MD5 |
6e9847994424afecf98c2e1b9cf46521
|
|
| BLAKE2b-256 |
2780befb8b99265c0b387ae3573624c14f07a4c697c99fed9aae94570a2e9532
|
Provenance
The following attestation bundles were made for katapult_api-1.2.1.tar.gz:
Publisher:
publish.yml on TechServ-Consulting-Training-Ltd/katapult-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
katapult_api-1.2.1.tar.gz -
Subject digest:
8b8a66daec4c04e426891a12c777b2e352633918ed8e21078b5417c9e58f8a1e - Sigstore transparency entry: 194659167
- Sigstore integration time:
-
Permalink:
TechServ-Consulting-Training-Ltd/katapult-api@1690266d5c78f88513ad88e213745d81023c89a7 -
Branch / Tag:
refs/tags/v1.2.1 - Owner: https://github.com/TechServ-Consulting-Training-Ltd
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1690266d5c78f88513ad88e213745d81023c89a7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file katapult_api-1.2.1-py3-none-any.whl.
File metadata
- Download URL: katapult_api-1.2.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0988ad73c40acb6c96ab6f0e081bba5d8148d672f1efd2656306a675862ab96
|
|
| MD5 |
d1f0c1f956b8962b86d9d2789f886571
|
|
| BLAKE2b-256 |
0db686afe30de86ab31b5a8052ac6e7c6a85c685136640b26b6e4e998554761b
|
Provenance
The following attestation bundles were made for katapult_api-1.2.1-py3-none-any.whl:
Publisher:
publish.yml on TechServ-Consulting-Training-Ltd/katapult-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
katapult_api-1.2.1-py3-none-any.whl -
Subject digest:
f0988ad73c40acb6c96ab6f0e081bba5d8148d672f1efd2656306a675862ab96 - Sigstore transparency entry: 194659168
- Sigstore integration time:
-
Permalink:
TechServ-Consulting-Training-Ltd/katapult-api@1690266d5c78f88513ad88e213745d81023c89a7 -
Branch / Tag:
refs/tags/v1.2.1 - Owner: https://github.com/TechServ-Consulting-Training-Ltd
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1690266d5c78f88513ad88e213745d81023c89a7 -
Trigger Event:
release
-
Statement type: