Skip to main content

Description

Returns the URL to the storage location of a data file or directory tracked in a DVC repository. This function provides direct access to the remote storage URL without downloading the file.
This function does not check for the actual existence of the file in remote storage. It only returns the expected URL based on DVC metadata.
For Git repositories, HEAD is used unless a rev argument is supplied. The default remote is tried unless a remote argument is supplied.

Signature

Parameters

str
required
Location and filename of the target, relative to the root of the repository.
str
default:"None"
Location of the DVC project or Git repository. Defaults to the current DVC project (found by walking up from the current working directory).Can be:
  • A URL to a Git repository
  • A local file system path
  • Both HTTP and SSH protocols are supported for online Git repos
str
default:"None"
Any Git revision such as a branch or tag name, a commit hash, or a DVC experiment name.
  • Defaults to HEAD for Git repositories
  • If repo is not a Git repo, this option is ignored
str
default:"None"
Name of the DVC remote used to form the returned URL string.
  • Defaults to the default remote of the repository
  • For local projects, the cache is tried before the default remote
dict
default:"None"
Config dictionary to be passed to the DVC repository.
dict
default:"None"
Remote config dictionary to be passed to the DVC repository.

Returns

str
The URL to the file or directory in remote storage. The format depends on the remote type:
  • S3: s3://bucket-name/path/to/file
  • GCS: gs://bucket-name/path/to/file
  • Azure: azure://container/path/to/file
  • HTTP: https://server.com/path/to/file
  • SSH: ssh://user@server/path/to/file
  • Local: file:///path/to/file

Raises

exception
Raised when the file is not tracked by DVC.
exception
Raised when no remote is configured or specified.
exception
Raised when accessing an external repository with no remote configured.

Examples

Basic Usage

Get URL from Specific Remote

Access Different Versions

Download with External Tool

Use with AWS CLI

Check Multiple Files

Get Directory URL

From Specific Tag

Error Handling

Custom Remote Configuration

Generate Presigned URL (S3)

Use Cases

Direct Downloads

Download files using external tools like wget, curl, or AWS CLI.

URL Sharing

Share direct URLs to data with team members or services.

Integration

Integrate DVC-tracked data with other tools and services.

Presigned URLs

Generate temporary access URLs for private cloud storage.

Remote Storage URL Formats

Important Notes

File Existence: This function does NOT verify that the file actually exists in remote storage. It only constructs and returns the expected URL based on DVC metadata.
Cache Priority: For local projects, DVC will try to get the URL from the local cache before checking the default remote.
Direct Access: The returned URL can often be used directly with cloud provider tools (aws, gsutil, az) or HTTP clients for downloading.

Best Practices

Since get_url() doesn’t check if the file exists, verify before using:
For very large files, getting the URL allows you to use optimized download tools:
Parse URLs appropriately based on storage type:
Remember that accessing the URL may require authentication:

Comparison with Other Functions

read()

Read complete file contents

open()

Stream file with context manager

DVCFileSystem

File system interface