Skip to main content

Reading your first variable

We will read the variable DATABASE_USERNAME for the development environment; in this case the value is athlead_dev_user.

Variable value

In our example we have three environments: development, staging and production.

We can see these environments in the Environments module.

Environments

First, we get the development environment key and secret from here:

Application environment

And now we have 3 options to read the variable value:

NodeJS SDK

These are the basic steps:

  1. Install the npm module
npm install --save envbee-sdk
  1. Use it in your code
// First, import the SDK
const envbeeInit = require("envbee-sdk");

// Provide your API key and secret
const envbee = envbeeInit({
key: "YOUR_ENVBEE_API_KEY",
secret: "YOUR_ENVBEE_API_SECRET"
});

// And you're good to go!
const databaseHost = await envbee.get("YOUR_ENVIRONMENT_VARIABLE_NAME");

if we use the values from our example, this would be:

const envbeeInit = require("envbee-sdk");

const envbee = envbeeInit({
key: "marketapp--development--32",
secret: "5ngomexhkub9rcv4mxsuuz7za2c9frgcp32auurkhm5fp98ivh7"
});

const databaseHost = await envbee.get("DATABASE_USERNAME");

For more information, visit the envbee NodeJS SDK GitHub repository.

Python SDK

These are the basic steps:

  1. Install the pip module
pip install envbee-sdk
  1. Use it in your code
from envbee_sdk import Envbee

eb = Envbee(api_key="YOUR_ENVBEE_API_KEY", api_secret="YOUR_ENVBEE_API_SECRET")

# Get a single environment variable
value = eb.get("YOUR_ENVIRONMENT_VARIABLE_NAME")

if we use the values from our example, this would be:

from envbee_sdk import Envbee

eb = Envbee(api_key="marketapp--development--32", api_secret="5ngomexhkub9rcv4mxsuuz7za2c9frgcp32auurkhm5fp98ivh7")

value = eb.get("DATABASE_USERNAME")

For more information, visit the envbee Python SDK GitHub repository.

REST API

Simply call the API endpoint you need and read the JSON response:

curl https://api.envbee.dev/v1/variables-values-by-name/YOUR_ENVIRONMENT_VARIABLE_NAME/content \
-H 'Accept: application/json' \
-H 'x-api-key: YOUR_ENVBEE_API_KEY' \
-H 'x-api-secret: YOUR_ENVBEE_API_SECRET'

if we use the values from our example, this would be:

curl https://api.envbee.dev/v1/variables-values-by-name/DATABASE_USERNAME/content \
-H 'Accept: application/json' \
-H 'x-api-key: marketapp--development--32' \
-H 'x-api-secret: 5ngomexhkub9rcv4mxsuuz7za2c9frgcp32auurkhm5fp98ivh7'

You will get a response like this:

{
"value": "test.db.server"
}