2021-08-17 15:24:37 +02:00
---
title: Quickstart
---
In this section we will attempt to guide you in order to get started with Unleash easily. There are multiple options to get started with Unleash, browse the headings to find the method that works best for you.
## I just want to get started creating toggles without much setup
Usually, you'll need to set up an Unleash instance in order to work with Unleash. However, for testing purposes we have set up a demo instance that you can use in order to test out different use-cases before setting up your own instance. You can find the demo instance admin panel here: https://app.unleash-hosted.com/demo/
NOTE: This is a demo instance set up with the Enterprise version. Some of the functionality may be enterprise specific, but everything we cover here is also available in open source.
### I want to test toggles in a client side environment
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
In order to use feature toggles on the client side you need to connect through [the Unleash proxy ](../reference/unleash-proxy.md ). The Unleash proxy will provide a security and performance layer between your client application and the Unleash instance. For now, you can use the proxy we have set up on the demo instance.
2021-08-17 15:24:37 +02:00
#### Create your first toggle
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
In order to create a toggle through the UI, [you can follow this guide ](../how-to/how-to-create-feature-toggles.md ). Once you have created your feature toggle, you are ready to connect your application using an SDK.
2021-08-17 15:24:37 +02:00
#### Connecting to the Unleash proxy from your app
Connection details:
```
2022-04-11 22:23:22 +02:00
Api URL: https://app.unleash-hosted.com/demo/api/proxy
2022-04-11 22:32:58 +02:00
Secret key: proxy-123
2021-08-17 15:24:37 +02:00
```
Now you can open your application code and connect through one of the proxy SDKs:
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
- [Android Proxy SDK ](../reference/sdks/android-proxy.md )
- [iOS Proxy SDK ](../reference/sdks/ios-proxy.md )
- [Javascript Proxy SDK ](../reference/sdks/javascript-browser.md )
- [React Proxy SDK ](../reference/sdks/react.md )
- [Svelte Proxy SDK ](../reference/sdks/svelte.md )
- [Vue Proxy SDK ](../reference/sdks/vue.md )
2021-08-17 15:24:37 +02:00
2022-06-29 13:04:21 +02:00
Here is a connection example using the JavaScript Proxy SDK:
2021-08-17 15:24:37 +02:00
```javascript
import { UnleashClient } from 'unleash-proxy-client';
const unleash = new UnleashClient({
2022-04-11 22:23:22 +02:00
url: 'https://app.unleash-hosted.com/demo/api/proxy',
2021-08-17 15:24:37 +02:00
clientKey: 'proxy-123',
appName: 'my-webapp',
});
2021-11-11 13:20:19 +01:00
unleash.on('synchronized', () => {
if (unleash.isEnabled('proxy.demo')) {
// do something
}
});
2021-08-17 15:24:37 +02:00
// Used to set the context fields, shared with the Unleash Proxy
unleash.updateContext({ userId: '1233' });
// Start the background polling
unleash.start();
```
Now you are ready to use the feature toggle you created in your client side application, using the appropriate proxy SDK.
### I want to test toggles in a backend environment
#### Create your first toggle
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
In order to create a toggle through the UI, [you can follow this guide ](../how-to/how-to-create-feature-toggles.md ). Once you have created your feature toggle, you are ready to connect your application using an SDK.
2021-08-17 15:24:37 +02:00
#### Connecting to the Unleash instance from your app
Connection details:
```
Api URL: https://app.unleash-hosted.com/demo/api/
Secret key: 56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d
```
Curl command test credentials and retrieve feature toggles:
```
curl https://app.unleash-hosted.com/demo/api/client/features \
-H "Authorization: 56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d";
```
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
Now you can open up your application code and create a connection to Unleash using one of our [SDKs ](../reference/sdks/index.md ). Here's an example using the NodeJS SDK:
2021-08-17 15:24:37 +02:00
```javascript
const { initialize } = require('unleash-client');
const unleash = initialize({
url: 'https://app.unleash-hosted.com/demo/api/',
appName: 'my-app-name',
instanceId: 'my-unique-instance-id',
customHeaders: {
Authorization: '56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d',
},
});
unleash.on('synchronized', () => {
// Unleash is ready to serve updated feature toggles.
// Check a feature flag
const isEnabled = unleash.isEnabled('some-toggle');
// Check the variant
const variant = unleash.getVariant('app.ToggleY');
});
```
Now you can fetch the feature toggle you created and try turning it on / off in your code.
## I want to setup my own instance for testing purposes
If you want to set up your own instance for testing purposes you can easily do so by using one of our premade setup kits for Heroku or DigitalOcean.
2022-10-19 14:02:00 +02:00
::: info Pricing
2021-08-17 15:24:37 +02:00
2022-10-19 14:02:00 +02:00
Both DigitalOcean and Heroku will charge you for running Unleash on their services. However, if you use the DigitalOcean link below and are a new user, you will receive $100 in free credits.
:::
### Deploy a paid version of Unleash to Heroku
2021-08-17 15:24:37 +02:00
[![Deploy to Heroku ](https://www.herokucdn.com/deploy/button.png )](https://www.heroku.com/deploy/?template=https://github.com/Unleash/unleash)
### Deploy a paid version of Unleash to DigitalOcean
2022-10-19 14:02:00 +02:00
:::tip Free credits
You'll receive $100 in free credits if you are a new DigitalOcean user using this link.
:::
2021-08-17 15:24:37 +02:00
2021-12-23 14:12:19 +01:00
[![Deploy to DigitalOcean ](https://www.deploytodo.com/do-btn-blue.svg )](https://cloud.digitalocean.com/apps/new?repo=https://github.com/Unleash/unleash/tree/main& refcode=0e1d75187044)
2021-08-17 15:24:37 +02:00
### Accessing your new instance
2022-10-19 14:02:00 +02:00
Once you have set up the new instance, follow the URL provided by either Heroku or DigitalOcean and it will take you to the application login screen.
2021-08-17 15:24:37 +02:00
Input the following credentials to log in:
```
username: admin
password: unleash4all
```
### Create your first toggle
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
In order to create a toggle through the UI, [you can follow this guide ](../how-to/how-to-create-feature-toggles.md ). Once you have created your feature toggle, you are ready to connect your application using an SDK.
2021-08-17 15:24:37 +02:00
If you'd like to create your feature toggles with code, you can hit the create feature endpoint with the following command:
> CRUD operations require an admin API key. For security reasons we have split the admin and client API into separate APIs. You can view how to create API keys in the next section of this guide. Make sure you create client keys for use in SDKs and restrict Admin api key usage.
```curl
curl -H "Content-Type: application/json" \
-H "Authorization: MY-ADMIN-API-KEY" \
-X POST \
-d '{
"name": "my-unique-feature-name",
"description": "lorem ipsum..",
"type": "release",
"enabled": false,
"stale": false,
"strategies": [
{
"name": "default",
"parameters": {}
}
],
"variants": [],
"tags": []
}' \
http://CHANGEME/api/admin/features
```
### Connect your SDK
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
Next, find the navigation, open up the Admin panel and find the API Access tab. Click the "Add new api key" button and create a client key. This key can be used to connect to the instance with our [SDKs ](../reference/sdks/index.md ).
2021-08-17 15:24:37 +02:00
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
You can find more [information about API keys here ](/how-to/how-to-create-api-tokens.mdx ).
2021-08-17 15:24:37 +02:00
Now that you have your API key created, you have what you need to connect to the SDK (NodeJS example):
```javascript
const { initialize } = require('unleash-client');
const unleash = initialize({
url: 'https://your.heroku.instance.com/api/',
appName: 'my-app-name',
instanceId: 'my-unique-instance-id',
customHeaders: {
Authorization: 'YOUR_API_KEY_HERE',
},
});
unleash.on('synchronized', () => {
// Unleash is ready to serve updated feature toggles.
// Check a feature flag
const isEnabled = unleash.isEnabled('some-toggle');
// Check the variant
const variant = unleash.getVariant('app.ToggleY');
});
```
## I want to run Unleash locally
2021-11-22 16:16:38 +01:00
### Run Unleash with Docker {#run-unleash-with-docker}
2021-08-17 15:24:37 +02:00
The easiest way to run unleash locally is using [docker ](https://www.docker.com/ ).
2021-11-23 09:07:00 +01:00
:::tip
2021-11-23 09:40:05 +01:00
Each container that runs in your local Docker instance must have a unique name. If you've run these commands before, you can either start the containers again (`docker start ${CONTAINER_NAME}`) or remove them (`docker rm ${CONTAINER_NAME}`) and run the commands again.
2021-11-23 09:07:00 +01:00
:::
2021-08-17 15:24:37 +02:00
1. Create a network by running `docker network create unleash`
2. Start a postgres database:
```sh
2021-11-23 08:08:23 +01:00
docker run \
-e POSTGRES_USER=unleash_user \
-e POSTGRES_PASSWORD=some_password \
-e POSTGRES_DB=unleash \
--network unleash \
--name postgres \
postgres
2021-08-17 15:24:37 +02:00
```
3. Start Unleash via docker:
```sh
2021-11-23 08:08:23 +01:00
docker run \
2021-11-22 16:16:38 +01:00
-p 4242:4242 \
2021-11-23 08:08:23 +01:00
-e DATABASE_HOST=postgres \
-e DATABASE_NAME=unleash \
-e DATABASE_USERNAME=unleash_user \
-e DATABASE_PASSWORD=some_password \
2021-08-17 15:24:37 +02:00
-e DATABASE_SSL=false \
2021-11-23 08:08:23 +01:00
--network unleash \
--name unleash \
2021-11-23 09:40:05 +01:00
--pull=always unleashorg/unleash-server
2021-08-17 15:24:37 +02:00
```
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
[Click here to see all options to get started locally. ](reference/deploy/getting-started.md )
2021-08-17 15:24:37 +02:00
### Accessing your new instance
Once you have the local instance running on localhost, input the following credentials to log in:
```
username: admin
password: unleash4all
```
2021-11-22 16:16:38 +01:00
### Run Unleash and the Unleash proxy with Docker
2021-11-23 09:40:05 +01:00
Follow steps outlined in the [Run Unleash with Docker ](#run-unleash-with-docker ) section to get the Unleash instance up and running. Once you have done that you need to first get an API key from your Unleash instance and then use that API key when starting the Unleash proxy.
2021-11-22 16:16:38 +01:00
1. Get an API key.
2021-11-23 09:40:05 +01:00
To get an API key, access your Unleash instance in a web browser. First, navigate to the API access screen.
2021-11-22 16:16:38 +01:00
2021-12-20 08:33:46 +01:00
![The Unleash UI showing a dropdown menu under the Configure menu entry. The dropdown menu's API Access option is highlighted and you're told to navigate there. ](/img/api_access_navigation.png 'Navigate to the API access page.' )
2021-11-22 16:16:38 +01:00
Next, create an API key with these details
2021-11-23 09:40:05 +01:00
- **name:** proxy-key (this can be whatever you want)
- **token type:** client
- **project:** all
- **environment:** select your preferred environment (this option is only available in Unleash 4.3 and later)
2021-11-22 16:16:38 +01:00
2021-11-23 09:40:05 +01:00
Copy the API key to your clipboard. You'll need it in the next step.
2021-11-22 16:16:38 +01:00
:::note
2021-11-23 09:40:05 +01:00
Depending on whether you have the environments feature enabled or not, the API key will look a little different. If you don't have environments enabled, it'll just be a 64 character long hexadecimal string (for instance `be44368985f7fb3237c584ef86f3d6bdada42ddbd63a019d26955178` ). If you do have environments enabled, the key will be prefixed with the project and the environment that the key is valid for. It'll use the format `<project>:<environment>.<key>` , e.g. `demo-app:production.be44368985f7fb3237c584ef86f3d6bdada42ddbd63a019d26955178` .
2021-11-22 16:16:38 +01:00
2021-11-23 09:40:05 +01:00
Regardless of which format your string uses, do not modify it.
2021-11-22 16:16:38 +01:00
2021-11-23 09:40:05 +01:00
:::
2021-11-22 16:16:38 +01:00
2. Start the Unleash proxy
2021-11-23 09:40:05 +01:00
Start a container with the Unleash proxy by running the following command. Replace `${API_KEY}` with the key you created in the following step.
```sh
docker run \
2022-08-09 16:20:28 +02:00
-e UNLEASH_PROXY_CLIENT_KEYS=some-secret \
2021-11-23 09:40:05 +01:00
-e UNLEASH_URL='http://unleash:4242/api/' \
-e UNLEASH_API_TOKEN='${API_KEY}' \
-p 3000:3000 \
--network unleash \
--name unleash-proxy \
--pull=always unleashorg/unleash-proxy
```
2021-11-22 16:16:38 +01:00
3. Test the proxy
2021-11-23 09:40:05 +01:00
To make sure the proxy is running successfully, you can test it by running the following command:
2021-11-22 16:16:38 +01:00
2021-11-23 09:40:05 +01:00
```curl
curl http://localhost:3000/proxy -H "Authorization: some-secret"
```
2021-11-22 16:16:38 +01:00
2021-08-17 15:24:37 +02:00
### Create your first toggle
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
In order to create a toggle through the UI, [you can follow this guide ](../how-to/how-to-create-feature-toggles.md ). Once you have created your feature toggle, you are ready to connect your application using an SDK.
2021-08-17 15:24:37 +02:00
If you'd like to create your feature toggles with code, you can hit the create feature endpoint with the following command:
> CRUD operations require an admin API key. For security reasons we have split the admin and client API into separate APIs. You can view how to create API keys in the next section of this guide. Make sure you create client keys for use in SDKs and restrict Admin api key usage.
```curl
curl -H "Content-Type: application/json" \
-H "Authorization: MY-ADMIN-API-KEY" \
-X POST \
-d '{
"name": "my-unique-feature-name",
"description": "lorem ipsum..",
"type": "release",
"enabled": false,
"stale": false,
"strategies": [
{
"name": "default",
"parameters": {}
}
],
"variants": [],
"tags": []
}' \
http://CHANGEME/api/admin/features
```
### Connect your SDK
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
Find the navigation, open up the Admin panel and find the API Access tab. Click the "Add new api key" button and create a client key. This key can be used to connect to the instance with our [SDKs ](../reference/sdks/index.md ).
2021-08-17 15:24:37 +02:00
refactor: move docs into new structure / fix links for SEO (#2416)
## What
This (admittedly massive) PR updates the "physical" documentation
structure and fixes url inconsistencies and SEO problems reported by
marketing. The main points are:
- remove or move directories : advanced, user_guide, deploy, api
- move the files contained within to the appropriate one of topics,
how-to, tutorials, or reference
- update internal doc links and product links to the content
- create client-side redirects for all the urls that have changed.
A number of the files have been renamed in small ways to better match
their url and to make them easier to find. Additionally, the top-level
api directory has been moved to /reference/api/legacy/unleash (see the
discussion points section for more on this).
## Why
When moving our doc structure to diataxis a while back, we left the
"physical' files lying where they were, because it didn't matter much to
the new structure. However, that did introduce some inconsistencies with
where you place docs and how we organize them.
There's also the discrepancies in whether urls us underscores or hyphens
(which isn't necessarily the same as their file name), which has been
annoying me for a while, but now has also been raised by marketing as an
issue in terms of SEO.
## Discussion points
The old, hand-written API docs have been moved from /api to
/reference/api/legacy/unleash. There _is_ a /reference/api/unleash
directory, but this is being populated by the OpenAPI plugin, and mixing
those could only cause trouble. However, I'm unsure about putting
/legacy/ in the title, because the API isn't legacy, the docs are. Maybe
we could use another path? Like /old-docs/ or something? I'd appreciate
some input on this.
2022-11-22 10:05:30 +01:00
You can find more [information about API keys here ](../how-to/how-to-create-api-tokens.mdx ).
2021-08-17 15:24:37 +02:00
Now that you have your API key created, you have what you need to connect to the SDK (NodeJS example):
```javascript
const { initialize } = require('unleash-client');
const unleash = initialize({
url: 'https://localhost:4242/api/',
appName: 'my-app-name',
instanceId: 'my-unique-instance-id',
customHeaders: {
Authorization: 'YOUR_API_KEY_HERE',
},
});
unleash.on('synchronized', () => {
// Unleash is ready to serve updated feature toggles.
// Check a feature flag
const isEnabled = unleash.isEnabled('some-toggle');
// Check the variant
const variant = unleash.getVariant('app.ToggleY');
});
```