@@ -29,9 +29,7 @@ import os
2929from unlayer import Unlayer
3030
3131client = Unlayer(
32- access_token = os.environ.get(" UNLAYER_ACCESS_TOKEN" ), # This is the default and can be omitted
33- # or 'production' | 'qa' | 'dev'; defaults to "production".
34- environment = " stage" ,
32+ api_key = os.environ.get(" UNLAYER_API_KEY" ), # This is the default and can be omitted
3533)
3634
3735project = client.project.retrieve(
@@ -40,10 +38,10 @@ project = client.project.retrieve(
4038print (project.data)
4139```
4240
43- While you can provide a ` access_token ` keyword argument,
41+ While you can provide an ` api_key ` keyword argument,
4442we recommend using [ python-dotenv] ( https://pypi.org/project/python-dotenv/ )
45- to add ` UNLAYER_ACCESS_TOKEN ="My Access Token "` to your ` .env ` file
46- so that your Access Token is not stored in source control.
43+ to add ` UNLAYER_API_KEY ="My API Key "` to your ` .env ` file
44+ so that your API Key is not stored in source control.
4745
4846## Async usage
4947
@@ -55,9 +53,7 @@ import asyncio
5553from unlayer import AsyncUnlayer
5654
5755client = AsyncUnlayer(
58- access_token = os.environ.get(" UNLAYER_ACCESS_TOKEN" ), # This is the default and can be omitted
59- # or 'production' | 'qa' | 'dev'; defaults to "production".
60- environment = " stage" ,
56+ api_key = os.environ.get(" UNLAYER_API_KEY" ), # This is the default and can be omitted
6157)
6258
6359
@@ -95,9 +91,7 @@ from unlayer import AsyncUnlayer
9591
9692async def main () -> None :
9793 async with AsyncUnlayer(
98- access_token = os.environ.get(
99- " UNLAYER_ACCESS_TOKEN"
100- ), # This is the default and can be omitted
94+ api_key = os.environ.get(" UNLAYER_API_KEY" ), # This is the default and can be omitted
10195 http_client = DefaultAioHttpClient(),
10296 ) as client:
10397 project = await client.project.retrieve(
@@ -132,8 +126,8 @@ client = Unlayer()
132126all_templates = []
133127# Automatically fetches more pages as needed.
134128for template in client.templates.list(
135- project_id = " your-project-id" ,
136129 limit = 10 ,
130+ project_id = " your-project-id" ,
137131):
138132 # Do something with template here
139133 all_templates.append(template)
@@ -153,8 +147,8 @@ async def main() -> None:
153147 all_templates = []
154148 # Iterate through items across all pages, issuing requests as needed.
155149 async for template in client.templates.list(
156- project_id = " your-project-id" ,
157150 limit = 10 ,
151+ project_id = " your-project-id" ,
158152 ):
159153 all_templates.append(template)
160154 print (all_templates)
@@ -167,8 +161,8 @@ Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get
167161
168162``` python
169163first_page = await client.templates.list(
170- project_id = " your-project-id" ,
171164 limit = 10 ,
165+ project_id = " your-project-id" ,
172166)
173167if first_page.has_next_page():
174168 print (f " will fetch next page using these details: { first_page.next_page_info()} " )
@@ -182,8 +176,8 @@ Or just work directly with the returned data:
182176
183177``` python
184178first_page = await client.templates.list(
185- project_id = " your-project-id" ,
186179 limit = 10 ,
180+ project_id = " your-project-id" ,
187181)
188182
189183print (f " next page cursor: { first_page.next_cursor} " ) # => "next page cursor: ..."
0 commit comments