read-env
Boilerplate code to read API keys from a .env file in Python
Quickstart
Functions to choose from include
read_pair_from_env: Read key pair from specified env fileread_key_from_env: Read API key from specified env fileread_sec_from_env: Read API secret from specified env file
You can install the read-env-keys package via pip
pip3 install read-env-keys
After installing, you will be able to import the module using
from read_env_keys import *
or
import read_env_keys
Read an API key from your .env file
After you have installed the package, create an env file (if you do not have one already) in your current working directory (cwd).
-
MacOS / Unix
Get the current working directory's absolute path by typing
pwdin the terminal. Copy and paste this as a string with the name of your env file appended (including the
.envextension) as an argument. -
Windows
Get the current working directory's absolute path by typing
cdin the command line.
Once you have the full path to the env file, pass it as an argument. You can optionally specifiy the API key name to read.
from read_env_keys import *
# Read an API Key. Default key name is 'API_KEY'
api_key_value = read_key_from_env(YOUR_ENVS_ABSOLUTE_FILEPATH)
# Read an API Key and specify the key name in the env file
api_key_value = read_key_from_env(YOUR_ENVS_ABSOLUTE_FILEPATH, api_key='my_key')
Metadata
Release files for read-env-keys 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| read_env_keys-0.0.3.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| read_env_keys-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.9 kB
Release files / read_env_keys-0.0.3.tar.gz
| Download URL | read_env_keys-0.0.3.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
462d0ae387800de4463713d6b6f035760228cd7f4d1a8b7c2592f1122597f33e
|
|
BLAKE2b-256 checksum How to use checksums |
784f63af4f10b8353a4c29b184677d86cdae1ad50838321c927199fdd34a4dbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / read_env_keys-0.0.3-py3-none-any.whl
| Download URL | read_env_keys-0.0.3-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3da3324d944abad4812144dbf2383c3f3dd07b7c7516723b55173102aaf85350
|
|
BLAKE2b-256 checksum How to use checksums |
58b8434e96856e7c639d1c6d7c24aa822436387e0edad20f8e220595df5976aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|