Skip to content

Access the WSO2 Developer Platform Insights API

The Usage Insights page in the WSO2 Developer Platform Console displays data retrieved from the Insights API exposed over the Internet. However, in some scenarios, you may need to retrieve data from external systems and implement custom dashboards to display the data.

WSO2 Developer Platform provides a secure and user-friendly approach to accomplish this requirement. Follow the steps given below:

Become a member of the WSO2 Developer Platform System organization

  1. Access the Developer Portal of the WSO2 Developer Platform System organization via the WSO2 Developer Platform Developer Portal and sign in using your preferred method.

  2. To obtain access to the WSO2 Developer Platform System organization, click Request Access.

    Request access

Create an application and generate keys

To create an application and generate keys, follow the steps below:

  1. To create a new application in the WSO2 Developer Platform System organization, click + Create Application.

  2. Enter a name for the application and click Create. This creates the application and takes you to the Overview page.

  3. To subscribe to the Insights API via the newly created application, follow the steps below:

    1. In the left navigation menu, click Subscriptions.
    2. In the Subscription Management pane, click + Add APIs.
    3. Search for Insights and click Add.
  4. To generate credentials for the application, follow the steps given below:

    1. In the left navigation menu, click Production under Credentials.
    2. Click Generate Credentials. WSO2 Developer Platform generates tokens and populates the Consumer Key and Consumer Secret fields in the Application Keys pane.
  5. To specify an appropriate token expiry time for the application, follow the steps given below:

    1. In the Application Keys pane, click to expand Advanced Configurations.
    2. Specify an appropriate value in the Application access token expiry time field and click Update.

      Update token expiry time

  6. Execute the following cURL command to generate an access token:

    curl --location --request POST 'https://sts.choreo.dev/oauth2/token' \
    --header 'Authorization: Basic <BASE64_ENCODED_CONSUMER_KEY_AND_CONSUMER_SECRET_OF_YOUR_APP_HERE>' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data-urlencode 'grant_type=client_credentials' \
    --data-urlencode 'orgHandle=<YOUR_ORG_HANDLE_HERE>' \
    --data-urlencode 'scope=apim:api_manage'
    

    Info

    To obtain your organization handle, follow the steps given below:

    1. Go to the WSO2 Developer Platform Console and sign in using your preferred method.
    2. In the WSO2 Developer Platform Console, click your username in the top right corner.
    3. In the drop-down menu, click Settings.
    4. In the Organization pane, click Copy Handle.

    You can use the generated token to access the Insights API exposed via https://choreocontrolplane.choreo.dev/93tu/insights/1.0.0/query-api.

    The following is a sample cURL command to invoke the Insights API:

    curl --location --request POST 'https://choreocontrolplane.choreo.dev/93tu/insights/1.0.0/query-api' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <TOKEN_HERE>' \
    --data-raw '{"query":"query ($org: OrgFilter!) {listEnvironments(org: $org){id\n name}}","variables":{"org":{"orgId":"<ORG_UUID_HERE>"}}}'
    

    Tip

    • When the token expires, you can generate a new token programmatically by making an API call to the token endpoint using the client credentials grant type.
    • If a token theft occurs, you can revoke the token by making an API call to the revoke endpoint.

    Endpoints