# Fetching assets

This API reference document contains information on fetching assets

Hygraph automatically generates 4 query types for assets. These are:

![Asset queries](https://hygraph.com/images/docs/api-reference/assets/asset-queries.png)

- `asset`
- `assets`
- `assetVersion`
- `assetsConnection`

These queries work just like regular [queries](https://hygraph.com/docs/api-reference/content-api/queries), and can be [filtered](https://hygraph.com/docs/api-reference/content-api/filtering) by their [fields](https://hygraph.com/docs/api-reference/schema/field-types#asset).

Here are some sample queries:

  **asset**

```graphql
# Fetch the fileName, local, size and stage of the asset with the provided id
query MyQuery {
  asset(where: {id: "<YOUR_ASSET_ID>"}) {
    fileName
    locale
    size
    stage
    url
  }
}
```

  
  **assets**

```graphql
# Fetch the fileName, size and locale of all assets in stage PUBLISHED
query MyQuery {
  assets(stage: PUBLISHED) {
    fileName
    size
    locale
    url
  }
}
```

  
  **assetVersion**

```graphql
# Fetch an asset version, filtered by revision number, unique identifier, and stage
query MyQuery {
  assetVersion(
    where: {revision: 10, id: "<YOUR_ASSET_ID>", stage: DRAFT}
  ) {
    createdAt
    data
  }
}
```

  
  **assetsConnection**

```graphql
# Fetch assets with assetUploadStatus ASSET_CREATE_PENDING
query MyQuery {
  assetsConnection(where: {assetUploadStatus: ASSET_CREATE_PENDING}) {
    edges {
      node {
        id
      }
    }
  }
}
```


## Generate URLs with file names

To enhance SEO and improve user trust, you can include the original file name in asset URLs generated via the new Hygraph Asset Management system.

1. Run the following query:

  **Query**

```graphql
# Fetch the url and fileName of the asset
query MyQuery {
  assets {
    url
    fileName
  }
}
```

  
  **Response**

```graphql
{
  "data": {
    "assets": [
      {
        "url": "https://eu-central-1-shared-euc1-02.graphassets.com/cmbq7mmxm0nhp07uqduk/cmcaodlnt9vxpfhycpf4",
        "fileName": "content-finder.gif"
      }
    ]
  }
}
```


2. Combine the `url` and `fileName` manually or via a script, separated by `/`. The final URL would look like this:

```url
https://eu-central-1-shared-euc1-02.graphassets.com/cmbq7mmxm0nhp07uqduk/cmcaodlnt9vxpfhycpf4/content-finder.gif
```

**Pro Tip:**

Ensure that the file name and file extension (`jpg`, `webp`, etc.) matches the current version of the asset. If you convert a `jpg` to `webp` using URL transformations, then you need to update the extension at the end to `webp`.
