Skip to main content

MGP API Example Bruno Collection

The MGP API Example Collection was created using the API client "Bruno". Bruno is a free, open-source API client that runs locally and does not save credentials or data to a cloud environment. You can import this collection into other API clients, but it may require some modifications. For Maxar's Account Services API and administrator calls, see the Account Services guide.

Download Bruno

Importing the collection to Bruno

  1. Download the Collection zip file. Unzip the file to a location you want to keep it. The uncompressed directory is labeled mgp_api.
  2. Open Bruno, then select "Open Collection" from the home page. Open Collection
  3. Navigate to the mgp_api directory on your local drive and select it. Once you've uploaded the collection it will appear in the navigation pane on the left side of the application.
    mgp collection

Note: When prompted, choose "safe mode". The "Developer" version is not needed to run examples in the collection.

Authentication

The Bruno collection has been set up to use an API key for authentication. The authentication method is set at the top of the collection. The value is set up as an environment variable.

Bruno collection api key auth

You can either create an environment file that stores your API key, or you can put your API key directly in the value field. If you store your API key, do not share your saved collection file with anyone.

Never share your API key with anyone. If you share a Bruno collection with others, make sure the API key is not stored in the collection file. If you inadvertently share your API key, submit a delete a single key call within the Auth/API keys directory to invalidate it.

Get API keys

There are two ways to get API keys to authenticate your API calls: Through the MGP Pro UI or through the API. Both methods can be used to generate a single API key or multiple API keys. If you generate an API key using the API, your API key will be automatically stored as a variable in your environment.

API keys from the MGP Pro UI

  1. Sign in to MGP Pro

  2. Select your initials in the lower left corner of the window to expand the profile menu and select "API Key" from the list.

MGP profile menu

  1. From the API key menu, select the "copy" button to copy your API key.

mgp profile menu

  1. Create an environment file in Bruno with maxar-api-key as a variable. Bruno environment file

Be sure to save your environment after making changes.

Generate an API key programmatically

To get an API key programmatically, you'll need to store additional variables in your environment file and fetch a bearer token.

  1. Set up an environment file with the following variables. Username and password are your MGP credentials. full environment credentials

  2. From the "Auth" folder in the collection, choose the POST Get Auth token request. Click the arrow at the end of the line to run the request. This will generate a token and store it as the accessToken and refreshToken in your environment.

  3. To generate an API key, from within the "Auth" folder, choose "API Keys", then "Generate an API key". Click the arrow at the end of the line to generate a new API key. Your API key will be saved to your environment.

For more information about API keys, see the API keys guide.

Using the Auth Type "Bearer Token"

You can use an MGP bearer token to authenticate requests in this collection instead of an API key. To do so, change the auth type at the top level of the collection to "Bearer Token". All requests will inherit the new auth type.

Bearer Token auth method

  1. Click the three dots next to the collection name and choose "settings" from the menu.

  2. From the Auth tab, select the dropdown arrow next to "API Key" and choose Bearer Token from the menu

  3. In the "Token" box, use a variable for the value: {{accessToken}}

Bearer tokens are short-lived, so you will need to fetch a new token regularly if you choose this method. For more information about Bearer tokens, see the get a token guide.

Using the MGP API Collection in Bruno

Once you've stored your API key or Bearer token, you can run requests in this collection.

  1. Navigate to the request you want to run

  2. Review the data in the "Params" tab or the "Body" to view the request. You can run the request example, or you can update the values or add parameters to change or narrow your results.

  3. Click the arrow at the end of the request line to run the request.

  4. View the "Response" panel to see the status of the request and the response.