Skip to main content

Getting repl metadata

In some cases, it's useful to automatically retrieve metadata about a Repl from within that Repl. Your Repl's environment variables are pre-populated with some data that you can use. However, please avoid printing out the entirety of your Repl's environment variables in a public Repl, as it will expose any secrets you've added.

To access this data, first retrieve your Repl's environment variables.

Retrieve environment variables in Node.js

console.log(process.env);

Retrieve environment variables in Python

import os

print(os.environ)

Retrieve environment variables in Rust

use std::env;

fn main() {
for (key, value) in env::vars() {
println!("{}: {}", key, value);
}
}

To access a single environment variable from within a Repl, use the following examples:

Access a single environment variable in Node.js:

const variable = process.env.REPL_SLUG;
console.log(variable);

Access a single environment variable in Python:

import os

variable = os.environ.get('REPL_SLUG')
print(variable)

Access a single environment variable in Rust:

use std::env;

fn main() {
let variable = env::var("REPL_SLUG").unwrap();
println!("{}", variable);
}

Here is a table showing the most useful metadata accessible inside your Repl:

keydescription
REPL_OWNERThe username of the owner of the Repl. If your Repl is text-based and has no webserver, REPL_OWNER will reflect the value of the current user accessing the Repl
REPLIT_DB_URLThe URL of your key-value Replit database
REPL_IDThe unique UUID string of your Repl
HOMEThe home path of your Repl
systemThe system name of your Repl
LANGText language and encoding
REPL_IMAGEThe docker image that corresponds to your Repl
REPL_LANGUAGEThe language of your Repl
REPL_PUBKEYSA stringified JSON object containing different public api keys
REPL_SLUGThe slug of your Repl
PRYBAR_FILEThe main/entrypoint file of your Repl