Skip to content

Commit 4ca9418

Browse files
authored
Feat/new faqs (#250)
2 parents 2af94d4 + d290ff6 commit 4ca9418

File tree

4 files changed

+406
-365
lines changed

4 files changed

+406
-365
lines changed

nbs/docs/getting-started/1_getting_started_short.ipynb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
"id": "8e7cea32-ade9-4b23-be93-9a4fbea7c6b2",
168168
"metadata": {},
169169
"source": [
170-
"You can test the validate of your token calling the `validate_token` method:"
170+
"Check your token status with the `validate_token` method."
171171
]
172172
},
173173
{
@@ -198,6 +198,14 @@
198198
"timegpt.validate_token()"
199199
]
200200
},
201+
{
202+
"cell_type": "markdown",
203+
"id": "a2597400",
204+
"metadata": {},
205+
"source": [
206+
"To learn more about how to set up your token, please refer to the [Setting Up your Authentication Token](https://nixtlaverse.nixtla.io/nixtla/docs/getting-started/setting_up_your_authentication_token.html) tutorial. "
207+
]
208+
},
201209
{
202210
"cell_type": "markdown",
203211
"id": "8ca0d1f7-9730-4146-b6f3-596099ce6e3b",
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Setting Up Your Authentication Token "
8+
]
9+
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"A **token**, also known as an **API Key**, is a unique string of characters that serves as a key to authenticate your requests to `TimeGTP`. This tutorial will explain how to set up your token when using the Nixtla SDK. \n",
15+
"\n",
16+
"Upon [registration](https://dashboard.nixtla.io/), you will recibe an email asking you to confirm your signup. After confirming, you will receive access to your dashboard. There, under `API Keys`, you will find your token. To integrate your token into your development workflow with the Nixtla SDK, you have two methods. "
17+
]
18+
},
19+
{
20+
"cell_type": "markdown",
21+
"metadata": {},
22+
"source": [
23+
"## 1. Direct copy and paste \n",
24+
"\n",
25+
"- **Step 1**: Copy the token found in the `API Keys` of your [dashboard]((https://dashboard.nixtla.io/)). \n",
26+
"- **Step 2**: Instantiate the `TimeGPT` class by directly pasting your token into the code, as shown below:"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": null,
32+
"metadata": {},
33+
"outputs": [],
34+
"source": [
35+
"from nixtlats import TimeGPT \n",
36+
"timegpt = TimeGPT(token = 'your token here')"
37+
]
38+
},
39+
{
40+
"cell_type": "markdown",
41+
"metadata": {},
42+
"source": [
43+
"This approach is straightforward and best for quick tests or scripts that won’t be shared."
44+
]
45+
},
46+
{
47+
"cell_type": "markdown",
48+
"metadata": {},
49+
"source": [
50+
"## 2. Using an environment variable"
51+
]
52+
},
53+
{
54+
"cell_type": "markdown",
55+
"metadata": {},
56+
"source": [
57+
"- **Step 1:** Store your token in an environment variable named `TIMEGPT_TOKEN`. This can be done for a session or permanently, depending on your preference.\n",
58+
"- **Step 2:** When you instantiate the `TimeGPT` class, the SDK will automatically look for the `TIMEGPT_TOKEN` environment variable and use it to authenticate your requests."
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": null,
64+
"metadata": {},
65+
"outputs": [
66+
{
67+
"data": {
68+
"text/plain": [
69+
"True"
70+
]
71+
},
72+
"execution_count": null,
73+
"metadata": {},
74+
"output_type": "execute_result"
75+
}
76+
],
77+
"source": [
78+
"#| hide\n",
79+
"from dotenv import load_dotenv\n",
80+
"load_dotenv()"
81+
]
82+
},
83+
{
84+
"cell_type": "code",
85+
"execution_count": null,
86+
"metadata": {},
87+
"outputs": [],
88+
"source": [
89+
"from nixtlats import TimeGPT\n",
90+
"timegpt = TimeGPT()"
91+
]
92+
},
93+
{
94+
"cell_type": "markdown",
95+
"metadata": {},
96+
"source": [
97+
"::: {.callout-important}\n",
98+
"The environment variable must be named exactly `TIMEGPT_TOKEN`, with all capital letters and no deviations in spelling, for the SDK to recognize it.\n",
99+
"::: "
100+
]
101+
},
102+
{
103+
"cell_type": "markdown",
104+
"metadata": {},
105+
"source": [
106+
"There are several ways to set an environment variable. "
107+
]
108+
},
109+
{
110+
"cell_type": "markdown",
111+
"metadata": {},
112+
"source": [
113+
"### a. From the Terminal\n",
114+
"Use the `export` command to set `TIMEGPT_TOKEN`. \n",
115+
"\n",
116+
"``` bash\n",
117+
"export TIMEGPT_TOKEN=your_token\n",
118+
"```"
119+
]
120+
},
121+
{
122+
"cell_type": "markdown",
123+
"metadata": {},
124+
"source": [
125+
"### b. Using a `.env` file\n",
126+
"\n",
127+
"For a more persistent solution that can be version-controlled if private, or for ease of use across different projects, place your token in a `.env` file.\n",
128+
"\n",
129+
"``` bash\n",
130+
"# Inside a file named .env\n",
131+
"TIMEGPT_TOKEN=your_token\n",
132+
"```"
133+
]
134+
},
135+
{
136+
"cell_type": "markdown",
137+
"metadata": {},
138+
"source": [
139+
"**Within Python:** If using a `.env` file, you can load the environment variable within your Python script. Use the `dotenv` package to load the `.env` file and then instantiate the `TimeGPT` class."
140+
]
141+
},
142+
{
143+
"cell_type": "code",
144+
"execution_count": null,
145+
"metadata": {},
146+
"outputs": [],
147+
"source": [
148+
"from dotenv import load_dotenv\n",
149+
"load_dotenv()\n",
150+
"\n",
151+
"from nixtlats import TimeGPT\n",
152+
"timegpt = TimeGPT()"
153+
]
154+
},
155+
{
156+
"cell_type": "markdown",
157+
"metadata": {},
158+
"source": [
159+
"This approach is more secure and suitable for applications that will be deployed or shared, as it keeps tokens out of the source code."
160+
]
161+
},
162+
{
163+
"cell_type": "markdown",
164+
"metadata": {},
165+
"source": [
166+
"::: {.callout-important}\n",
167+
"Remember, your token is like a password - keep it secret, keep it safe!\n",
168+
"::: "
169+
]
170+
},
171+
{
172+
"cell_type": "markdown",
173+
"metadata": {},
174+
"source": [
175+
"## Validate your token\n",
176+
"\n",
177+
"You can always find your token in the `API Keys` section of your dashboard. To check the status of your token, use the [`validate_token` method](https://nixtlaverse.nixtla.io/nixtla/timegpt.html#timegpt-validate-token) of the `TimeGPT` class. This method will return `True` if the token is valid and `False` otherwise. "
178+
]
179+
},
180+
{
181+
"cell_type": "code",
182+
"execution_count": null,
183+
"metadata": {},
184+
"outputs": [
185+
{
186+
"name": "stderr",
187+
"output_type": "stream",
188+
"text": [
189+
"INFO:nixtlats.timegpt:Happy Forecasting! :), If you have questions or need support, please email [email protected]\n"
190+
]
191+
},
192+
{
193+
"data": {
194+
"text/plain": [
195+
"True"
196+
]
197+
},
198+
"execution_count": null,
199+
"metadata": {},
200+
"output_type": "execute_result"
201+
}
202+
],
203+
"source": [
204+
"timegpt.validate_token()"
205+
]
206+
},
207+
{
208+
"cell_type": "markdown",
209+
"metadata": {},
210+
"source": [
211+
"You don't need to validate your token every time you use `TimeGPT`. This function is provided for your convenience to ensure its validity. For full access to `TimeGPT`'s functionalities, in addition to a valid token, you also need sufficient credits in your account. You can check your credits in the `Usage` section of your [dashboard]((https://dashboard.nixtla.io/)). "
212+
]
213+
}
214+
],
215+
"metadata": {
216+
"kernelspec": {
217+
"display_name": "python3",
218+
"language": "python",
219+
"name": "python3"
220+
}
221+
},
222+
"nbformat": 4,
223+
"nbformat_minor": 2
224+
}

0 commit comments

Comments
 (0)