---
schema_version: "1"
id: f1a49ce1e9e4e1d9614e83051ebdf0b4fb03337c9ba45c685da54657a62a023c
title: Searching the Graph API
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/exchange/to-search-with-graph-api.md
canonical_url: https://docs.mulesoft.com/exchange/to-search-with-graph-api
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 564b8eb46e30141c453371eb574e25b1eb7207e4983df1b1f187dc678333e6db
description: MuleSoft Documentation Site
latest: true
---
---
product: Exchange
---

# Searching the Graph API

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Search Exchange assets for a string value by using the Exchange Graph API. You can specify what
values to receive in each search.

The Exchange Graph API accesses Anypoint Exchange and Anypoint Platform, and a search requires
authentication to access assets in a private Exchange. If you only search for MuleSoft public
assets, you don’t need authentication.

The Exchange Graph API can be used without an Anypoint Platform account to find assets made publicly
available by MuleSoft. Accessing private content through the API requires an Anypoint Platform
account.

## Authentication

Use either an access token or a connected application for authentication.

You only need authentication if you are searching for assets that are not created by MuleSoft.

To use token authentication:

1.  Log in to Anypoint Platform.

2.  Obtain an access token with a cURL command.

You can also use Postman or another application for sending HTTP commands.

Replace `ANYPOINT_USERNAME` with your Anypoint Platform user account name and replace
`ANYPOINT_PASSWORD` with your password.

```console
curl --location --request POST 'https://anypoint.mulesoft.com/accounts/login' \
     --header 'Content-Type: application/json' \
     --header 'Accept: application/json' \
     --data-raw '{
        "username":"ANYPOINT_USERNAME",
        "password":"ANYPOINT_PASSWORD"
     }' | jq -r ".access_token"
```

Use this access token in your API calls.

Your organization administrator sets the expiration time for access tokens to a value from 15 to 180
minutes. If you perform a search or other operation that requires more time, you must request an
additional token.

See also
[Access Management API Authentication](https://dev-portal.mulesoft.com/apis/access-management.html).

To use connected application authentication:

1.  [Create a connected application](https://docs.mulesoft.com/exchange/connected-app-authentication).

2.  Choose whether to use basic authentication or query variable authentication.

    If both basic authentication and query variable authentication are set, the API uses basic
    authentication and ignores the query variable authentication.

3.  To use basic authentication, provide basic authentication and define the username as
    `~~~Client~~~` and the password as `clientID~?~clientSecret`.

    1.  Replace `clientID` with the client ID.

    2.  Replace `clientSecret` with the client secret.

4.  To use query variable authentication, define the connected application authentication as an
    authorization field in the query variables:

    ```json
    {
      "authorization": "Basic ABC123"
    }
    ```

    Replace `ABC123` with the base64 encoding of the concatenated client ID and client secret:
    `~~~Client~~~:clientID~?~clientSecret`

## Graph API Access URL

You can access the Graph API at the `https://anypoint.mulesoft.com/graph/api/v1/graphql` URL. To
search using the API, send a POST command containing the search string.

For example:

```json
curl -X POST \
  https://anypoint.mulesoft.com/graph/api/v1/graphql \
  -H 'content-type: application/json' \
  -d '{"query": "{ assets(query: { searchTerm: \"searchTerm\" }) { groupId, assetId, version } }"}'
```

The query field contains the GraphQL query, which allows fetching more asset fields.

```json
{
  assets(asset: {groupId: "some-group-id", assetId: "some-asset-id", version: "some-version-1.2.3"}) {
    # Possible fields to retrieve
    groupId
    assetId
    version
    description
    name
    type
    contactName
    contactEmail
    tags {
      value
      key
    }
    createdBy {
      id
      userName
      firstName
      lastName
    }
    files {
      classifier
      packaging
      externalLink
      md5
    }
    rating
    numberOfRates
    createdAt
    organizationId
    assetLink
    runtimeVersion
    productAPIVersion
    dependencies {
      groupId
      assetId
      version
      name
      type
    }
    related(relationshipType: OtherVersions) {
      groupId
      assetId
      version
      name
      type
      runtimeVersion
      productAPIVersion
    }
  }
}
```

You can get the group ID, asset ID, and version of a Mule 4.x asset with this example:

```json
curl -X POST \
  https://anypoint.mulesoft.com/graph/api/v1/graphql \
  -H 'content-type: application/json' \
  -d '{"query":"{assets(query: {tags: {key: \"min-mule-version\", value: \"4.0.0\"}}) {groupId assetId version}}"}'
```

## 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.

    A single organization ID would be:

    `organizationIds: ["42424242"]`

    ```json
    {
      assets(
        query: {
          searchTerm: "product",
          organizationIds: ["4141141", "32322", "2342345"]
        },
        latestVersionsOnly: true
      ) {
        assetId,
        description
      }
    }
    ```

    The output for this example is:

    ```json
    {
      "data": {
        "assets": [
          {
            "assetId": "product-datatype",
            "description": "Product Datatype Asset"
          },
          {
            "assetId": "product-api",
            "description": "Product API Asset"
          }
        ]
      }
    }
    ```

## Asset Lifecycle State

To consume an asset and its lifecycle state, replace `ANYPOINT_TOKEN`, `:groupId`, `:assetId`, and
`:version` with your information, and execute this command:

```console
curl -X POST \
  https://anypoint.mulesoft.com/graph/api/v2/graphql \
  -H 'Authorization: bearer ANYPOINT_TOKEN' \
  -H 'content-type: application/json' \
  -d '{"query":"{asset(groupId: \":groupId\",assetId: \":assetId\",version: \":version\"){groupId assetId version status}}"}'
```

To search for an asset by lifecycle state, replace `ANYPOINT_TOKEN` with your information, replace
`[development, published, deprecated]` with your list of desired lifecycle states, and execute this
command:

```console
curl -X POST \
  https://anypoint.mulesoft.com/graph/api/v2/graphql \
  -H 'Authorization: bearer ANYPOINT_TOKEN' \
  -H 'content-type: application/json' \
  -d '{"query":"{assets(status:[development, published, deprecated]){groupId assetId version status}}"}'
```

## Reference: Query Filter Parameters

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

The following filters let you refine query output:

<table><colgroup><col> <col></colgroup><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><p>assetId</p></td><td><p>Asset ID for each asset.</p></td></tr><tr><td><p>createdAt</p></td><td><p>Date and time an asset was created, for example, 2018-08-11T04:48:20.585Z.</p></td></tr><tr><td><p>createdBy { id, userName, firstName, lastName }</p></td><td><p>Display who created the asset.</p></td></tr><tr><td><p>dependencies { groupId, assetId, version, name, type }</p></td><td><p>Returns the assets the listed asset depends on.</p></td></tr><tr><td><p>files { classifier, packaging, externalLink, md5 }</p></td><td><p>File information.</p></td></tr><tr><td><p>name</p></td><td><p>Asset name.</p></td></tr><tr><td><p>contactName</p></td><td><p>Name of a person to contact about the asset.</p></td></tr><tr><td><p>contactEmail</p></td><td><p>Email address of a person to contact about the asset.</p></td></tr><tr><td><p>numberOfRates</p></td><td><p>The number of star ratings for an asset.</p></td></tr><tr><td><p>organizationId</p></td><td><p>Organization ID for an asset.</p></td></tr><tr><td><p>rating</p></td><td><p>Star rating value for an asset.</p></td></tr><tr><td><p>runtimeVersion</p></td><td><p>Mule Runtime version.</p></td></tr><tr><td><p>tags { value, key, mutable }</p></td><td><p>The asset tags. The tags created in the user interface and when publishing are only <code>value</code> tags (they don’t have a key). Tags created in the user interface are mutable while the others are immutable. Tags with a key and value are special tags created by Exchange to describe the asset.</p></td></tr><tr><td><p>type</p></td><td><p>Lowercase values corresponding to the Exchange All Types menu: connector, template, example, rest-api, soap-api, raml-fragment, and custom.</p></td></tr><tr><td><p>version</p></td><td><p>Version for an asset.</p></td></tr><tr><td><p>groupId</p></td><td><p>Group ID for an asset.</p></td></tr></tbody></table>

## See Also

- [Exchange Graph API](https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/f1e97bc6-315a-4490-82a7-23abe036327a.anypoint-platform/exchange-graph-http/)

- [Anypoint Exchange](https://anypoint.mulesoft.com/exchange/)

- [Exchange Documentation](https://docs.mulesoft.com/exchange/)
