# `ApifyClient.API.KeyValueStores`
[🔗](https://github.com/social-growth-studio/apify-client-ex/blob/v1.0.0/lib/apify_client/api/key_value_stores.ex#L1)

Provides API endpoints related to api/key value stores

# `create`

```elixir
@spec create(opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.KeyValueStoreResource.t()}
  | {:error, ApifyClient.Error.t()}
```

Create key-value store

Creates a key-value store and returns its object. The response is the same
object as returned by the [Get key-value store](https://docs.apify.com/api/v2/key-value-store-get)
endpoint.

Keep in mind that data stored under unnamed store follows [data retention
period](https://docs.apify.com/platform/storage#data-retention).

It creates a store with the given name if the parameter name is used.
If there is another store with the same name, the endpoint does not create a
new one and returns the existing object instead.

## Options

  * `name`: Custom unique name to easily identify the store in the future.

# `delete`

```elixir
@spec delete(store_id :: String.t(), opts :: keyword()) ::
  :ok | {:error, ApifyClient.Error.t()}
```

Delete key-value store

Deletes a key-value store.

# `get`

```elixir
@spec get(store_id :: String.t(), opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.KeyValueStoreResource.t()}
  | {:error, ApifyClient.Error.t()}
```

Get key-value store

Gets an object that contains all the details about a specific key-value
store.

# `list`

```elixir
@spec list(opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.ListOfKeyValueStores.t()}
  | {:error, ApifyClient.Error.t()}
```

Get list of key-value stores

Gets the list of key-value stores owned by the user.

The response is a list of objects, where each objects contains a basic
information about a single key-value store.

The endpoint supports pagination using the `limit` and `offset` parameters
and it will not return more than 1000 array elements.

By default, the records are sorted by the `createdAt` field in ascending
order, therefore you can use pagination to incrementally fetch all key-value stores
while new ones are still being created. To sort the records in descending order, use
the `desc=1` parameter.

## Options

  * `offset`: Number of items that should be skipped at the start. The default value is `0`.
    
  * `limit`: Maximum number of items to return. The default value as well as the maximum is `1000`.
    
  * `desc`: If `true` or `1` then the objects are sorted by the `createdAt` field in
    descending order. By default, they are sorted in ascending order.
    
  * `unnamed`: If `true` or `1` then all the storages are returned. By default, only
    named storages are returned.
    
  * `ownership`: Filter by ownership. If this parameter is omitted, all accessible key-value stores are returned.
    
    - `ownedByMe`: Return only key-value stores owned by the user.
    - `sharedWithMe`: Return only key-value stores shared with the user by other users.
    

# `update`

```elixir
@spec update(
  store_id :: String.t(),
  body :: map() | ApifyClient.Schemas.UpdateKeyValueStoreRequest.t(),
  opts :: keyword()
) ::
  {:ok, ApifyClient.Schemas.KeyValueStoreResource.t()}
  | {:error, ApifyClient.Error.t()}
```

Update key-value store

Updates a key-value store's name and general resource access level using a value specified by a JSON object
passed in the PUT payload.

The response is the updated key-value store object, as returned by the [Get key-value store](https://docs.apify.com/api/v2/key-value-store-get) API endpoint.

## Request Body

**Content Types**: `application/json`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
