Skip to content

Commit c6cc79d

Browse files
committed
ENV handling and documentation
1 parent 0d2dd37 commit c6cc79d

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ Create a `TINDClient` with optional configuration values:
3131

3232
## Usage
3333

34+
### TIND Credentials / Optional ENV config
35+
You will need to either pass your TIND API credentials as arguments when instantiating a `TINDClient` or set them as environment variables with the following names:
36+
- `TIND_API_KEY`
37+
- `TIND_API_URL`
38+
3439
### instantiate a client
3540
```python
3641
from tind_client import TINDClient

tind_client/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class TINDClient:
2727

2828
def __init__(
2929
self,
30-
api_key: str = os.environ.get("TIND_API_KEY", ""),
31-
api_url: str = os.environ.get("TIND_API_URL", ""),
30+
api_key: str = "",
31+
api_url: str = "",
3232
default_storage_dir: str = "./tmp",
3333
) -> None:
3434
self.api_key = api_key
@@ -45,8 +45,8 @@ def fetch_metadata(self, record: str) -> Record:
4545
"""
4646
status, response = tind_get(
4747
f"record/{record}/",
48-
api_key=self.api_key,
49-
api_url=self.api_url,
48+
api_key=self.api_key or os.environ.get("TIND_API_KEY", ""),
49+
api_url=self.api_url or os.environ.get("TIND_API_URL", ""),
5050
params={"of": "xm"},
5151
)
5252
if status == 404 or len(response.strip()) == 0:

0 commit comments

Comments
 (0)