Nav

To Search Exchange with the Graph API

The Exchange Graph API lets you search Exchange assets for a string value. You can specify what values to receive in each search. You can send inquiries to the Graph API using the GraphiQL program provided by MuleSoft.

Because the Graph API accesses Anypoint Exchange and Anypoint Platform, inquiries should have an access token if you want to access assets in private exchange. If you only search for MuleSoft public assets, you don’t need an asset token.

To Run GraphiQL to Send a Query to Exchange

  1. Open GraphiQL program by browsing to https://anypoint.mulesoft.com/graph/api/v1/graphiql.

  2. If you are searching for non-MuleSoft assets, you need to get an access token. Access tokens expire approximately every 5 minutes, so you may need to get a new token while doing searches.

The GraphiQL program provides these controls:

Button Name Description

ex2-graphiql-run

Run

Send the query to the Exchange Graph API

ex2-graphiql-prettify

Prettify

Strip out comments at the top of the file and collapse the JSON as much as possible. This is not a toggle. If you want to see the comments again, run GraphiQL in another browser or in an incognito window.

ex2-graphiql-history

History

List previous queuries. To dismiss the History pane, click History again.

ex2-graphiql-docs

Docs

List a brief description about a parameter.

ex2-graphiql-query-vars

Query Variables

Specify the access token value and any other variables to use in a query.

To Obtain an Access Token

You only need an access token if you are searching for assets that are not created by MuleSoft.

Access tokens time out in approximately 5 minutes and must be renewed to continue use of the Graph API.

  1. Log into Anypoint Platform.

  2. Obtain an access token with a curl command such as the following. You can also use Postman or another application for sending HTTP commands.

    
                
             
    1
    2
    3
    4
    5
    6
    7
    
    curl -X POST \
      https://anypoint.mulesoft.com/accounts/login \
      -H 'content-type: application/json' \
      -d '{
      "username": "YOUR_ANYPOINT_PLATFORM_USER_NAME",
      "password": "YOUR_ANYPOINT_PLATFORM_PASSWORD"
    }'
  3. In GraphiQL, click Query Variables at the bottom of the screen and insert the access token as:

    
                
             
    1
    2
    3
    
    {
      "accessToken": "ACCESS_TOKEN_VALUE"
    }

To Indicate How Many Items to Display

By default, GraphiQL lists up to 23 items in a search. You can indicate a higher number as well as an offset into the list of results with the query: {limit:n, offset:n| command.

For example, to list all MuleSoft assets containing Salesforce:


         
      
1
2
3
4
5
6
7
{
  assets(query: {limit: 20, offset:0, searchTerm: "salesforce"}) {
    groupId
    assetId
    version
  }
}

Or to list the first 20 assets in Exchange:


         
      
1
2
3
4
5
6
7
{
  assets(query: {limit: 20, offset:0}) {
    groupId
    assetId
    version
  }
}

To Search Assets for a Search Term

Insert a JSON block for your query in the upper pane of GraphiQL, such as the following example that searches for any asset with with the word "product" in the asset ID or description. GraphiQL searches all assets that are visible to the access token owner including MuleSoft and private Exchange assets.


         
      
1
2
3
4
5
6
7
8
9
10
11
{
  assets(
    query: {
      searchTerm: "product"
    },
    latestVersionsOnly: true
  ) {
    assetId,
    description
  }
}

Output for this example is:


         
      
1
2
3
4
5
6
7
8
9
10
{
  "data": {
    "assets": [
      {
        "assetId": "template-sfdc2sap-product-aggregation",
        "description": "Aggregate products (materials in SAP) from Salesforce and SAP into a CSV file."
      }
    ]
  }
}

To Search Only a Private Exchange

  1. Get the organization ID for the Private Exchange by clicking an asset in your Private Exchange.

    An example URL is:

    https://anypoint.mulesoft.com/exchange/42424242/product-api/1.0.0/

    42424242 is the organization ID.

  2. Add the organization ID using the organizationIds field in GraphiQL:

    
                
             
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    {
      assets(
        query: {
          searchTerm: "product",
          organizationIds: "42424242"
        },
        latestVersionsOnly: true
      ) {
        assetId,
        description
      }
    }

    The output for this example is:

    
                
             
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    
    {
      "data": {
        "assets": [
          {
            "assetId": "product-datatype",
            "description": "Product Datatype Asset"
          },
          {
            "assetId": "product-api",
            "description": "Product API Asset"
          }
        ]
      }
    }

Reference: Query Filter Parameters

You can specify filters to display additional information about each asset.

The following filters let you refine query output:

Parameter Description

assetId

Asset ID for each asset.

createdAt

Date and time an asset was created, for example, 2017-08-11T04:48:20.585Z.

createdBy { id, userName, firstName, lastName }

Display who created the asset.

dependencies { groupId, assetId, version, name, type }

Dependency snippet information tp specify an asset in Maven, Gradle, SBT, and Ivy.

description

Description information in an asset.

files { classifier, packaging, externalLink, md5 }

File information. Classifier and packaging are not supported.

name

Asset name

numberOfRates

The number of star ratings for an asset.

organizationId

Organization ID for an asset.

rating

Star rating value for an asset.

runtimeVersion

Mule Runtime version.

tags { value, key, mutable }

Each tag for an asset, value is the tag type or version, key is the tag name or null, and mutable indicates whether or not a tag name can be changed. You can ignore the mutable value - its setting is arbitrary. Exchange tags cannot be set to immutable.

type

Lowercase values corresponding to the Exchange All Types menu: connector, template, example, rest-api, soap-api, raml-fragment, and custom.

version

Version for an asset.

groupId

Group ID for an asset.

GraphiQL provides additional filter values that are not supported for use with the Graph API.

Example query:


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
  assets(asset: {
    groupId: "ORGANIZATION_ID",
    assetId: "product-api/",
    version: "1.0.0"
  })
  {
    assetId,
    assetLink,
    createdAt,
    createdBy { id, userName, firstName, lastName },
    dependencies { groupId, assetId, version, name, type },
    description,
    files { classifier, packaging, externalLink, md5 },
    groupId,
    name,
    numberOfRates,
    organizationId,
    rating,
    runtimeVersion,
    tags { value, key },
    type,
    version
  }
}

Output from this command:


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
  "data": {
    "assets": [
      {
        "assetId": "mule-module-ms-dynamics-crm",
        "assetLink": "",
        "createdAt": "2017-09-12T19:36:42.746Z",
        "createdBy": {
          "id": "ORG_ID",
          "userName": "connectivity",
          "firstName": "MuleSoft",
          "lastName": "Organization"
        },
        "dependencies": [],
        "description": "Description for Microsoft Dynamics CRM Connector",
        "files": [
          {
            "classifier": "studio-plugin",
            "packaging": "zip",
            "externalLink": "https://exchange2-asset-manager-kprod...",
            "md5": "ASSETS_MD5"
          },
          {
            "classifier": null,
            "packaging": "pom",
            "externalLink": "https://exchange2-asset-manager-kprod...",
            "md5": "ASSETS_MD5"
          },
          {
            "classifier": null,
            "packaging": "jar",
            "externalLink": "https://exchange2-asset-manager-kprod..., "md5": "ASSETS_MD5" } ], "groupId": "org.mule.modules", "name": "Microsoft Dynamics CRM Connector", "numberOfRates": 0, "organizationId": "ORG_ID", "rating": 0, "runtimeVersion": "3.7.0", "tags": [ { "value": "2.9.1.201709121536", "key": "full-version", "mutable": false }, ...