# Excontentstack
[](https://hex.pm/packages/excontentstack)
[](https://hexdocs.pm/excontentstack/)
[](https://git.developers.burberry.com/platform-services/content/content-stack/excontentstack/-/pipelines)
Elixir wrapper for [Contentstack's](https://www.contentstack.com/) Management API. A simple and idiomatic way to interact with Contentstack from Elixir applications.
## Installation
Add `excontentstack` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:excontentstack, "~> 0.1.0"}
]
end
```
Then run:
```bash
mix deps.get
```
## Configuration
You can configure Contentstack credentials in your config files:
```elixir
# config.exs
config :excontentstack,
management_token: System.get_env("CONTENTSTACK_MANAGEMENT_TOKEN"),
api_key: System.get_env("CONTENTSTACK_API_KEY"),
master_locale: "en"
```
## Usage
### Management API
The Management API allows you to manage content in your Contentstack account.
```elixir
# Create a client
client = Excontentstack.Management.new(
management_token: "your_management_token",
api_key: "your_api_key",
master_locale: "en-us"
)
alias Excontentstack.Management.Entries
# List entries (single page)
{:ok, entries} = Entries.list(client, "blog_post")
# List all entries (automatic pagination)
{:ok, all_entries} = Entries.list_all(client, "blog_post")
# Stream entries for memory-efficient processing
client
|> Entries.stream("blog_post")
|> Stream.filter(&published?/1)
|> Stream.map(&transform/1)
|> Enum.take(50)
# Get a specific entry
{:ok, entry} = Entries.get(client, "blog_post", "entry_uid")
# Use raw: true to get the entire response data
{:ok, result} = Entries.list(client, "blog_post", raw: true, params: [include_count: true])
# Create an entry
{:ok, new_entry} = Entries.create(client, "blog_post", %{
title: "My Blog Post",
content: "This is the content"
})
# Update an entry
{:ok, updated_entry} = Entries.update(
client,
"blog_post",
"entry_uid",
%{title: "Updated Title"}
)
# Delete an entry
{:ok, _} = Entries.delete(client, "blog_post", "entry_uid")
```