MGX Enterprise API
Project description
mgx
Official Python client for the MGX Enterprise API.
pip install mgx
Quickstart
The ergonomic client lives in mgx.overlay:
import os
from mgx.overlay import MgxClient, MgxApiError
mgx = MgxClient(
client_id=os.environ["MGX_CLIENT_ID"],
client_secret=os.environ["MGX_CLIENT_SECRET"],
scopes=["inventory.read", "market.read"],
# base_url="https://dashboard.mgx.test/v1", # for local development
)
# Auto-paginates the { items, limit, offset, next } envelope.
for lot in mgx.inventory.list(commodity="wheat", min_quantity=50):
print(lot.id, lot.quantity_mt, lot.asking_price.amount if lot.asking_price else None)
Authentication
- Client credentials (read-only data) — pass
client_id+client_secret+scopes; the SDK acquires and refreshes the token for you. - Login with MGX (user-context: bids, trades, teams, cash bids, webhooks) — complete the authorization-code + PKCE flow, then pass the resulting
access_token(and optionallyrefresh_token) toMgxClient.
Features
- Resource namespaces —
inventory,market,bids,trades,teams,cash_bids,webhooks. - Auto-pagination — every
list()returns a generator that followsnextand yields items lazily. - Idempotency —
inventory.place_bid()sends anIdempotency-Keyautomatically (passidempotency_key=to override). - Typed errors — non-2xx responses raise
MgxApiErrorwithstatus,code,message, andfield_errors.
try:
bid = mgx.inventory.place_bid(
"inv_3Kd9aZ",
quantity_mt=50,
price={"amount": 312.5},
delivery={"from": "2026-08-01", "to": "2026-09-30"},
)
except MgxApiError as e:
print(e.status, e.code, e.message, e.field_errors)
Generated code
The mgx/ client (everything except mgx/overlay/) is generated from the OpenAPI
spec; the ergonomic layer lives in mgx/overlay/. Do not hand-edit the generated
modules — change the API spec and regenerate. See the
mgx-sdks repo.
License
MIT
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 mgx-1.0.1.tar.gz.
File metadata
- Download URL: mgx-1.0.1.tar.gz
- Upload date:
- Size: 80.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41dd49b2320b6978bd816edb38c5c6b82c77a487119a81eb1fa80c41570acada
|
|
| MD5 |
ff2c504775f18958ecb64161fde18d9d
|
|
| BLAKE2b-256 |
b12e30238969da445b203a62389395145ae13169587a540a2de2293b01b32e99
|
Provenance
The following attestation bundles were made for mgx-1.0.1.tar.gz:
Publisher:
release.yml on mygrainexchange/mgx-sdks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mgx-1.0.1.tar.gz -
Subject digest:
41dd49b2320b6978bd816edb38c5c6b82c77a487119a81eb1fa80c41570acada - Sigstore transparency entry: 2186964639
- Sigstore integration time:
-
Permalink:
mygrainexchange/mgx-sdks@c2521f6df4c525fd0b3cc24005a35ee15181470b -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/mygrainexchange
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c2521f6df4c525fd0b3cc24005a35ee15181470b -
Trigger Event:
push
-
Statement type:
File details
Details for the file mgx-1.0.1-py3-none-any.whl.
File metadata
- Download URL: mgx-1.0.1-py3-none-any.whl
- Upload date:
- Size: 179.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1676c0d37b82e89065615a2ac83d5a0cc51713432b3241aba79619daaff2867
|
|
| MD5 |
42858d4b5e9188da76a8f2962b059c4d
|
|
| BLAKE2b-256 |
ef8da3f153a0cd9112ef1960c72052057aa69599f7dc5ae7fbbb0a7bf3a8e2eb
|
Provenance
The following attestation bundles were made for mgx-1.0.1-py3-none-any.whl:
Publisher:
release.yml on mygrainexchange/mgx-sdks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mgx-1.0.1-py3-none-any.whl -
Subject digest:
c1676c0d37b82e89065615a2ac83d5a0cc51713432b3241aba79619daaff2867 - Sigstore transparency entry: 2186964672
- Sigstore integration time:
-
Permalink:
mygrainexchange/mgx-sdks@c2521f6df4c525fd0b3cc24005a35ee15181470b -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/mygrainexchange
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c2521f6df4c525fd0b3cc24005a35ee15181470b -
Trigger Event:
push
-
Statement type: