Skip to main content

assets

Creates, updates, deletes, gets or lists an assets resource.

Overview

Nameassets
TypeResource
Idgithub.repos.assets

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
idinteger
namestringThe file name of the asset. (example: Team Environment)
node_idstring
browser_download_urlstring (uri)
content_typestring
created_atstring (date-time)
digeststring
download_countinteger
labelstring
sizeinteger
statestringState of the release asset. (uploaded, open)
updated_atstring (date-time)
uploaderobjectA GitHub user. (title: Simple User)
urlstring (uri)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_release_assetselectowner, repo, asset_idTo download the asset's binary content:

- If within a browser, fetch the location specified in the browser_download_url key provided in the response.
- Alternatively, set the Accept header of the request to
application/octet-stream.
The API will either redirect the client to the location, or stream it directly if possible.
API clients should handle both a 200 or 302 response.
list_release_assetsselectowner, repo, release_idper_page, page
upload_release_assetinsertowner, repo, release_id, namelabelThis endpoint makes use of a Hypermedia relation to determine which URL to access. The endpoint you call to upload release assets is specific to your release. Use the upload_url returned in
the response of the Create a release endpoint to upload a release asset.

You need to use an HTTP client which supports SNI to make calls to this endpoint.

Most libraries will set the required Content-Length header automatically. Use the required Content-Type header to provide the media type of the asset. For a list of media types, see Media Types. For example:

application/zip

GitHub expects the asset data in its raw binary form, rather than JSON. You will send the raw binary content of the asset as the request body. Everything else about the endpoint is the same as the rest of the API. For example,
you'll still need to pass your authentication to be able to upload an asset.

When an upstream failure occurs, you will receive a 502 Bad Gateway status. This may leave an empty asset with a state of starter. It can be safely deleted.

Notes:
* GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The "List release assets"
endpoint lists the renamed filenames. For more information and help, contact GitHub Support.
* To find the release_id query the GET /repos/{owner}/{repo}/releases/latest endpoint.
* If you upload an asset with the same filename as another uploaded asset, you'll receive an error and must delete the old file before you can re-upload the new asset.
update_release_assetupdateowner, repo, asset_idUsers with push access to the repository can edit a release asset.
delete_release_assetdeleteowner, repo, asset_id

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
asset_idintegerThe unique identifier of the asset.
namestring
ownerstringThe account owner of the repository. The name is not case sensitive.
release_idintegerThe unique identifier of the release.
repostringThe name of the repository without the .git extension. The name is not case sensitive.
labelstring
pageintegerThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pageintegerThe number of results per page (max 100). For more information, see "Using pagination in the REST API."

SELECT examples

To download the asset's binary content:

- If within a browser, fetch the location specified in the browser_download_url key provided in the response.
- Alternatively, set the Accept header of the request to
application/octet-stream.
The API will either redirect the client to the location, or stream it directly if possible.
API clients should handle both a 200 or 302 response.

SELECT
id,
name,
node_id,
browser_download_url,
content_type,
created_at,
digest,
download_count,
label,
size,
state,
updated_at,
uploader,
url
FROM github.repos.assets
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND asset_id = '{{ asset_id }}' -- required
;

INSERT examples

This endpoint makes use of a Hypermedia relation to determine which URL to access. The endpoint you call to upload release assets is specific to your release. Use the upload_url returned in
the response of the Create a release endpoint to upload a release asset.

You need to use an HTTP client which supports SNI to make calls to this endpoint.

Most libraries will set the required Content-Length header automatically. Use the required Content-Type header to provide the media type of the asset. For a list of media types, see Media Types. For example:

application/zip

GitHub expects the asset data in its raw binary form, rather than JSON. You will send the raw binary content of the asset as the request body. Everything else about the endpoint is the same as the rest of the API. For example,
you'll still need to pass your authentication to be able to upload an asset.

When an upstream failure occurs, you will receive a 502 Bad Gateway status. This may leave an empty asset with a state of starter. It can be safely deleted.

Notes:
* GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The "List release assets"
endpoint lists the renamed filenames. For more information and help, contact GitHub Support.
* To find the release_id query the GET /repos/{owner}/{repo}/releases/latest endpoint.
* If you upload an asset with the same filename as another uploaded asset, you'll receive an error and must delete the old file before you can re-upload the new asset.

INSERT INTO github.repos.assets (
owner,
repo,
release_id,
name,
label
)
SELECT
'{{ owner }}',
'{{ repo }}',
'{{ release_id }}',
'{{ name }}',
'{{ label }}'
RETURNING
id,
name,
node_id,
browser_download_url,
content_type,
created_at,
digest,
download_count,
label,
size,
state,
updated_at,
uploader,
url
;

UPDATE examples

Users with push access to the repository can edit a release asset.

UPDATE github.repos.assets
SET
name = '{{ name }}',
label = '{{ label }}',
state = '{{ state }}'
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND asset_id = '{{ asset_id }}' --required
RETURNING
id,
name,
node_id,
browser_download_url,
content_type,
created_at,
digest,
download_count,
label,
size,
state,
updated_at,
uploader,
url;

DELETE examples

No description available.

DELETE FROM github.repos.assets
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND asset_id = '{{ asset_id }}' --required
;