# quilt3

## quilt3

Quilt API

### clear\_api\_key() <a href="#clear_api_key" id="clear_api_key"></a>

Clear the API key and fall back to interactive session (if available).

### config(\*catalog\_url, \*\*config\_values) <a href="#config" id="config"></a>

Set or read the QUILT configuration.

To retrieve the current config, call directly, without arguments:

```
import quilt3
quilt3.config()
```

To trigger autoconfiguration, call with just the navigator URL:

```
import quilt3
quilt3.config('https://YOUR-CATALOG-URL.com')
```

To set config values, call with one or more key=value pairs:

```
import quilt3
quilt3.config(navigator_url='http://example.com')
```

Default config values can be found in `quilt3.util.CONFIG_TEMPLATE`.

**Arguments**

* **catalog\_url**: A (single) URL indicating a location to configure from
* **\*\*config\_values**: `key=value` pairs to set in the config

**Returns**

`QuiltConfig`: (an ordered Mapping)

### delete\_package(name, registry=None, top\_hash=None) <a href="#delete_package" id="delete_package"></a>

Delete a package. Deletes only the manifest entries and not the underlying files.

**Arguments**

* **name (str)**: Name of the package
* **registry (str)**: The registry the package will be removed from
* **top\_hash (str)**: Optional. A package hash to delete, instead of the whole package.

### get\_boto3\_session(\*, fallback: bool = True) -> boto3.session.Session <a href="#get_boto3_session" id="get_boto3_session"></a>

Return a Boto3 session with Quilt stack credentials and AWS region. In case of no Quilt credentials found, return a "normal" Boto3 session if `fallback` is `True`, otherwise raise a `QuiltException`.

> Note: you need to call `quilt3.config("https://your-catalog-homepage/")` to have region set on the session, if you previously called it in quilt3 < 6.1.0.

### list\_package\_versions(name, registry=None) <a href="#list_package_versions" id="list_package_versions"></a>

Lists versions of a given package.

Returns an iterable of (latest\_or\_unix\_ts, hash) of package revisions. If the registry is None, default to the local registry.

**Arguments**

* **name (str)**: Name of the package
* **registry (str)**: location of registry to load package from.

**Returns**

An iterable of tuples containing the version and hash for the package.

### list\_packages(registry=None) <a href="#list_packages" id="list_packages"></a>

Lists Packages in the registry.

Returns an iterable of all named packages in a registry. If the registry is None, default to the local registry.

**Arguments**

* **registry (str)**: location of registry to load package from.

**Returns**

An iterable of strings containing the names of the packages

### logged\_in() <a href="#logged_in" id="logged_in"></a>

Return catalog URL if Quilt client is authenticated, `None` otherwise.

### login() <a href="#login" id="login"></a>

Authenticate to your Quilt stack and assume the role assigned to you by your stack administrator. Not required if you have existing AWS credentials.

Launches a web browser and asks the user for a token.

### login\_with\_api\_key(key: str) <a href="#login_with_api_key" id="login_with_api_key"></a>

Authenticate using an API key.

The API key is stored in memory only (no disk persistence). While set, the API key overrides any interactive session. Use clear\_api\_key() to revert to interactive session.

**Arguments**

* **key**: API key string (starts with 'qk\_')

**Raises**

* `ValueError`: If the key doesn't start with 'qk\_' prefix.

### logout() <a href="#logout" id="logout"></a>

Do not use Quilt credentials. Useful if you have existing AWS credentials.

### search(query: Union\[str, dict], limit: int = 10) -> List\[dict] <a href="#search" id="search"></a>

Execute a search against the configured search endpoint.

**Arguments**

* **query**: query string to query if passed as `str`, DSL query body if passed as `dict`
* **limit**: maximum number of results to return. Defaults to 10

Query Syntax: [Query String Query](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/query-dsl-query-string-query.html) [Query DSL](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/query-dsl.html)

Index schemas and search examples can be found in the [Quilt Search documentation](https://docs.quilt.bio/quilt-platform-catalog-user/search).

**Returns**

search results

## quilt3.api\_keys

API for managing your own API keys.

### APIKey(id: str, name: str, fingerprint: str, created\_at: datetime.datetime, expires\_at: datetime.datetime, last\_used\_at: Optional\[datetime.datetime], status: Literal\['ACTIVE', 'EXPIRED'], user\_email: str) -> None <a href="#apikey" id="apikey"></a>

An API key for programmatic access.

### APIKeyError(result) <a href="#apikeyerror" id="apikeyerror"></a>

Error during API key operation.

### list(name: Optional\[str] = None, fingerprint: Optional\[str] = None, status: Optional\[Literal\['ACTIVE', 'EXPIRED']] = None) -> List\[quilt3.api\_keys.APIKey] <a href="#list" id="list"></a>

List your API keys. Optionally filter by name, fingerprint, or status.

**Arguments**

* **name**: Filter by key name.
* **fingerprint**: Filter by key fingerprint.
* **status**: Filter by "ACTIVE" or "EXPIRED". None returns all.

**Returns**

List of your API keys matching the filters.

### get(id: str) -> Optional\[quilt3.api\_keys.APIKey] <a href="#get" id="get"></a>

Get a specific API key by ID.

**Arguments**

* **id**: The API key ID.

**Returns**

The API key, or None if not found.

### create(name: str, expires\_in\_days: int = 90) -> Tuple\[quilt3.api\_keys.APIKey, str] <a href="#create" id="create"></a>

Create a new API key for yourself.

**Arguments**

* **name**: Name for the API key.
* **expires\_in\_days**: Days until expiration (1-365, default 90).

**Returns**

Tuple of (APIKey, secret). The secret is only returned once - save it securely!

**Raises**

* `APIKeyError`: If the operation fails.

### revoke(id: Optional\[str] = None, secret: Optional\[str] = None) -> None <a href="#revoke" id="revoke"></a>

Revoke an API key. Provide either the key ID or the secret.

**Arguments**

* **id**: The API key ID to revoke.
* **secret**: The API key secret to revoke.

**Raises**

* `ValueError`: If neither id nor secret is provided.
* `APIKeyError`: If the operation fails.
