SDK
Credentials are required to use the SDKThe SDKs authenticate with an API key or OAuth client credentials. See API Authentication to create either, and each SDK's documentation for how to pass them.
Monte Carlo provides convenient programmatic access to all APIs and additional features via a simple yet powerful SDK.
| Language | API | Details |
|---|---|---|
| Python (pycarlo) | GraphQL | pypi.org/project/pycarlo |
| Python (pycarlo2) | REST API v2 | pypi.org/project/pycarlo2 |
| Go | REST API v2 | pkg.go.dev/github.com/monte-carlo-data/mc-sdk-go |
Keeping pycarlo current
Each pycarlo release includes the GraphQL schema as it was when the release was published. Fields and arguments added to the API later aren't in pycarlo's query builders until you upgrade, and selecting one there fails. For example, Alert.audiences needs pycarlo 0.10.208 or later. Queries you pass as a string aren't checked. Upgrade with pip install --upgrade pycarlo.
Newer enum values work the other way round: when the API returns a value your release doesn't know, pycarlo logs a warning such as Unknown enum value '<value>' for <Type>. This may indicate the SDK is out of date. Returning raw string value., keeps the raw value, and continues. The warning is harmless.
REST API v2 SDKs
BetaThe REST API v2 SDKs are versioned
0.x, and a new minor version may carry breaking changes.
The Python and Go SDKs cover the REST API v2: deployments, collection agents and data stores, credentials, warehouses and connections. Both read credentials from their options, from MCD_DEFAULT_* environment variables, or from a profile in ~/.mcd/profiles.ini written by the CLI.
Python
pycarlo2 is a separate package from pycarlo, which covers the GraphQL API; the two can be installed side by side. It requires Python 3.10 or later:
pip install pycarlo2With credentials already configured through the CLI, a client needs no options:
import pycarlo2
client = pycarlo2.new_client()
print(pycarlo2.UsersApi(client).get_current_user())See the Python SDK reference for every operation, other ways to pass credentials, and paginated lists.
Go
go get github.com/monte-carlo-data/mc-sdk-go/montecarloSee its documentation for usage and examples.
Updated 8 days ago
