# Google Drive Direct Link API

> Turn a Google Drive share link into a direct download URL.

Resolves a Google Drive share link (the `file/d/<id>/view` or `open?id=` forms) to the URL that serves the file bytes directly, so it can be used in download buttons, `wget` scripts or media tags. The file must be shared with "anyone with the link".

The link is built from the file id Google issues for that share URL. The endpoint does not check that the file exists or is shared publicly; a private or deleted file yields a link that Google will refuse. Only Google Drive and Google Docs hosts are accepted.

- **Endpoint:** `GET https://api.zactonz.com/gdrive/directlink/`
- **Category:** Files
- **Version:** 1
- **Status:** stable
- **Authentication:** `Authorization: Bearer YOUR_API_KEY`
- **Reference page:** https://developers.zactonz.com/apis/gdrive-direct-link/

## Parameters

Send parameters in the query string.

| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `url` | string | yes |  | The Google Drive share link. |

## Example request

```bash
curl "https://api.zactonz.com/gdrive/directlink/?url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F0B8vQ0mnbCTFRcW1ZclhtS3ZKZGs%2Fview" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

## Response

The direct download URL.

| Field | Type | Description |
|---|---|---|
| `status` | integer | `200` on success. See status codes below. |
| `data` | string | The direct download URL, or an explanation for non-200 statuses. |

```json
{
    "status": 200,
    "data": "https://drive.usercontent.google.com/download?id=0B8vQ0mnbCTFRcW1ZclhtS3ZKZGs&export=download"
}
```

## Status codes

The outcome is reported in the JSON `status` field. General rules: https://developers.zactonz.com/apis/errors.md

| status | Meaning | Description |
|---|---|---|
| `200` | OK | Resolved. |
| `400` | Missing url | `url` was empty or absent. |
| `403` | Could not resolve | The file is private, was removed, or Google is throttling it. `data` carries the reason. |

## Notes

Direct links for large files pass through Google's virus-scan interstitial; the resolver follows it for you. Google may rate-limit files that are downloaded very frequently, in which case the reply is a `403` with the explanation in `data`.
