MCM CLI
MCM Command Line Interface tool
The Moloco MCM CLI tool lets you easily access Moloco’s APIs, such as retrieving authentication tokens, performing ad account management, and querying wallet balances.
Requirements
The MCM CLI tool requires Python and PIP please review the documentation links for installation and configuration.
Installation
Open a terminal and run the following command:
$ pip install --upgrade mcm-cli
The CLI tool is also accessible in Moloco’s GitHub repository. https://github.com/moloco-mcm/mcm-cli
Configuration
Run the following command in your terminal to initialize the configuration tool:
$ mcm config init
You will be prompted with a series of questions which will set up a default
profile:
If you do not have the following configuration information please contact your Moloco MCM team.
$ mcm config init
Creating a profile [default] ...
Platform ID: PLATFORM_TEST
Your email address of the Campaign Manager: (your email for the Moloco Campaign Manager login)
Password of the Campaign Manager: (your password for the Moloco Campaign Manager login)
Currency in a three digit code like 'USD' [USD]: (hit enter)
Timezone [unknown]: (hit enter)
Decision API hostname [unknown]: https://your_decision_api_hostname.moloco.com
Management API hostname [unknown]: https://your_management_api_hostname.moloco.com
Event API hostname [unknown]: https://your_event_api_hostname.rmp-api.moloco.com
Decision API key [unknown]: (hit enter)
Friendly name of the decision API key [unknown]: (hit enter)
Event API key [unknown]: (hit enter)
Friendly name of the event API key [unknown]: (hit enter)
The profile [default] has been created.
Configuration saved to ~/.mcm/config.toml
$
The CLI tool is now configured to use the TEST environment (PLATFORM_TEST
) as the default
profile.
To configure a Production (prod
) profile run the following command in your terminal and follow the same steps using your production PLATFORM ID.
$ mcm config init --profile prod
The CLI tool will now contain two profiles: a (default
) profile for your PLATFORM_TEST
environment and a (prod
) profile for your production environment.
- To view the profile configurations open the file: ~/.mcm/config.toml
Command Syntax
Usage: mcm [OPTIONS
] COMMAND [ARGS
]
For help with usage and syntax add the --help
flag to any command.
$ mcm --help
mcm --help
Usage: mcm [OPTIONS] COMMAND [ARGS]...
╭─ Options ────────────────────────────────────────────────────────╮
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────╮
│ account Ad account management │
│ auth Authentication management │
│ config Configurations │
│ decision Decision command │
│ version Show the tool version │
│ wallet Wallet management │
╰──────────────────────────────────────────────────────────────────╯
Use Case Examples
We’re constantly adding new commands, like these examples.
Getting JWT authentication token
You can call CreateToken API by running the following command in your terminal:
$ mcm auth get-token
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJtb3JzZSIsImV4cCI6MTcyMzc1NzIwOSwiaWF0IjoxNzIzNzUzNjA5LCJ2ZXJzaW9uIjoidjIiLCJ1c2VyX2lkIjoiUUZycm55anRmMmJHdEhETGdibm8iLCJ1c2VyX2VtYWlsIjoiam9uZ25hbUBtb2xvY28uY29tIiwidXNlcl90eXBlIjoiaW5kaXZpZHVhbCIsInBsYXRmb3JtX2lkIjoiTEVBRkxJTktfVEVTVCIsInVzZXJzcGFjZV9pZCI6IlVTRVJTUEFDRV9MRUFGTElOS19URVNUIiwibmFtZSI6IkpvbmduYW0gTGVlIiwibGFzdF9uYW1lIjoiIiwic2NvcGUiOiIiLCJ0b2tlbl9pZCI6IiIsImZpYSI6MH0.83lhTzRQqGa3IgHAMTO7iER0eEauv-QtDwrf6YL8UCM
$
Generating CURL commands
Alternatively, you may generate curl command by using the --to-curl
option instead of directly invoking the API:
$ mcm auth get-token --to-curl
curl --request POST \
--url https://your-management-api-hostname.moloco.com/rmp/mgmt/v1/platforms/YOURPLATFORM_TEST/tokens \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"auth_type": "CREDENTIAL",
"credential_type_payload": {
"email": "[email protected]",
"password": "campaign manager password"
}
}
'
$
Getting decision API responses
You can call DecideAdItems API by running the following command in your terminal:
$ mcm decision decide-items --inventory-id test --num-items 1
{"request_id":"request-1","decided_items":[{"item_id":"SOFA01","auction_result":{"ad_account_id":"S2","campaign_id":"nJPwhTlVcZPd5kZF","win_price":{"currency":"USD","amount_micro":"690000"},"campaign_text_entry":""},"imp_trackers":["https://your-event-api-hostname.mcm-api.moloco.com/t/i/YOURPLATFORM_TEST?source=2X1JxeFdETDESP1sC5mnyzTmX9420CYG65aDJbZCZSvD30pDZPXE3bZCJ1YP6OtOpKtCpSmE3OoCsOpE3HaD6GsCc8mD3CsPZCuC3CrOJDaCZ4rCJ5cDMGOjv2RjWOW0YW1-4WPJJqP1C34"],"click_trackers":["https://your-event-api-hostname.moloco.com/t/c/YOURPLATFORM_TEST?source=2X1JxeFdETDESP1sC5mnyzTmX9420CYG65aDJbZCZSvD30pDZPXE3bZCJ1YP6OtOpKtCpSmE3OoCsOpE3HaD6GsCc8mD3CsPZCuC3CrOJDaCZ4rCJ5cDMGOjv2RjWOW0YW1-4WPJJqP1C34"],"track_id":"2X1JxeFdETDESP1sC5mnyzTmX9420CYG65aDJbZCZSvD30pDZPXE3bZCJ1YP6OtOpKtCpSmE3OoCsOpE3HaD6GsCc8mD3CsPZCuC3CrOJDaCZ4rCJ5cDMGOjv2RjWOW0YW1-4WPJJqP1C34"}]}
$
You can also call Moloco’s DecideAdCreative API by running the following command:
$ mcm decision decide-creative --inventory-id creative_test
{"request_id":"request-1","auction_result":{"ad_account_id":"S2","campaign_id":"PJBIZEKOmygUn3bp","win_price":{"currency":"USD","amount_micro":"1000000"},"campaign_text_entry":""},"banner":{"creative_id":"g36fRyiw7gVy6lDR","image_url":"https://rmp-cdn.moloco.com/platform/YOURPLATFORM_TEST/images/lzvazj9n_y88qqmk.jpeg","imp_trackers":["https://your-event-api-hostname.moloco.com/t/i/YOURPLATFORM_TEST?source=2X2JYzpvoesWSbozEkK1MoOzmaY106H832o6foncHkScXWPcnimd1onc9WnCZCRiPgRcPkO71iP6RCPd1eo6Z8R6J4O6XcRCncS61cQi9co6HYQc9Yp6h8CGKdDsmCG0PG0W"],"click_trackers":["https://your-event-api-hostname.moloco.com/t/c/YOURPLATFORM_TEST?source=2X2JYzpvoesWSbozEkK1MoOzmaY106H832o6foncHkScXWPcnimd1onc9WnCZCRiPgRcPkO71iP6RCPd1eo6Z8R6J4O6XcRCncS61cQi9co6HYQc9Yp6h8CGKdDsmCG0PG0W"]},"items":[],"landing_url":null}
$
Getting Wallet balances
You can call QueryWallets API by running the following command in your terminal:
$ mcm wallet platform-balance
ad_account_id,credit_balance,prepaid_balance,got_balance_info_at_utc
10054,1890.02,0.0,2024-10-23T16:42:03.723992Z
10083,0.21,0.0,2024-10-23T16:42:03.723992Z
10128,675.32,0.0,2024-10-23T16:42:03.723992Z
10131,0.0,-4.46,2024-10-23T16:42:03.723992Z
......
$
Updated 7 days ago