A package for interacting with Major Tom's Scripting API.
Project description
Major Tom Script API Package
Python Package for interacting with Major Tom's Scripting API.
The Package contains both a high-level and low-level API.
High-Level API
This API is in alpha. Please use with caution.
The new high-level API aims to make the user experience easier by providing canned methods and models for common operations. We trade both customizability and efficiency for ease-of-use. For example, to schedule a command on an upcoming pass, it is only a few lines of code:
# Customize these to your mission
token = "your script token"
host = "your_instance.majortom.cloud"
satellite_name = "your already-created satellite"
command_name = "your already-created command"
#-------------------------------------------------
api = ModelingAPI(host=host, token=token) # Create the API
AQUA = api.satellite(name=satellite_name) # Get the satellite
aPass = AQUA.next_pass() # Get the next pass
definition = AQUA.get_command_definition(command_name) # Get a specific command
aPass.schedule_command(definition) # Schedule it on a pass
More examples are available on in our demo repo.
Low-Level API
The low-level API provides direct access to the GraphQL query and mutation methods. Users will have to construct a GraphQL query and provide the correct variables in order to use the API. Although it requires more upfront work, the low-level API is the most efficient and customizable way to interact with Major Tom.
Here is an example of retrieving all TLEs from all satellites whose name includes the string "v2" from within a particular mission.
# Customize these to your mission
token = "your script token"
host = "your_instance.majortom.cloud"
mission_id = 1
#-------------------------------------------------
api = ScriptingAPI(host=host, token=token)
graphql = """
query GetSystems (
$missionId: ID!,
$systemFilters: SystemFilter,
) {
mission(id: $missionId) {
id
systems(filters: $systemFilters, orderBy: { sort: NAME, direction: ASC }) {
edges {
node {
id
tle
}
}
}
}
}
"""
response = api.query(graphql,
variables={
'missionId': mission_id,
'systemFilters': {
"type": "Satellite",
"nameSubstring": "v2"}
},
path='data.mission.systems.edges')
print(response)
The GraphQL schema and documentation can be found inside Major Tom on the same page where a Script Token is available. Look for the button labelled "GraphQL Playground".
Examples
Example scripts can be found in our demo repo.
Development
The Scripting API Package is currently in Beta, so please give us feedback or come talk to us!
Testing
To run all tests, execute ./bin/docker_testw.sh
.
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
Built Distribution
File details
Details for the file majortom_scripting-1.0.1.tar.gz
.
File metadata
- Download URL: majortom_scripting-1.0.1.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 001f5dc726ed0202894e94ba73dfb8d739c903a53574e993f5b2a7808e4bcf1b |
|
MD5 | 3e5737d734d94f4d4559e0c7f44e644d |
|
BLAKE2b-256 | 6160ce264f85ea7a3bb53b69406ca6340571a6fabaf2b2b47734f93c580183ae |
File details
Details for the file majortom_scripting-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: majortom_scripting-1.0.1-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ebce41d4842ddde34f981fa64956b57b3f1f284cdc903b0b8500c58bb7702a6 |
|
MD5 | c19c59472d1085d279421f630ca221f9 |
|
BLAKE2b-256 | 4ec4ddd472e4f16edd588e7a716641d50a6506d4f07ad87673f694f229a39f10 |