- Notifications
You must be signed in to change notification settings - Fork1
PipedreamHQ/pipedream-sdk-python
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The Pipedream Python library provides convenient access to the Pipedream API from Python.
pip install pipedream
A full reference for this library is availablehere.
Instantiate and use the client with the following:
frompipedreamimportPipedreamclient=Pipedream(project_id="YOUR_PROJECT_ID",project_environment="YOUR_PROJECT_ENVIRONMENT",client_id="YOUR_CLIENT_ID",client_secret="YOUR_CLIENT_SECRET",)client.accounts.create(app_slug="app_slug",cfmap_json="cfmap_json",connect_token="connect_token",)
The SDK also exports anasync
client so that you can make non-blocking calls to our API.
importasynciofrompipedreamimportAsyncPipedreamclient=AsyncPipedream(project_id="YOUR_PROJECT_ID",project_environment="YOUR_PROJECT_ENVIRONMENT",client_id="YOUR_CLIENT_ID",client_secret="YOUR_CLIENT_SECRET",)asyncdefmain()->None:awaitclient.accounts.create(app_slug="app_slug",cfmap_json="cfmap_json",connect_token="connect_token", )asyncio.run(main())
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following errorwill be thrown.
frompipedream.core.api_errorimportApiErrortry:client.accounts.create(...)exceptApiErrorase:print(e.status_code)print(e.body)
Paginated requests will return aSyncPager
orAsyncPager
, which can be used as generators for the underlying object.
frompipedreamimportPipedreamclient=Pipedream(project_id="YOUR_PROJECT_ID",project_environment="YOUR_PROJECT_ENVIRONMENT",client_id="YOUR_CLIENT_ID",client_secret="YOUR_CLIENT_SECRET",)response=client.apps.list()foriteminresponse:yielditem# alternatively, you can paginate page-by-pageforpageinresponse.iter_pages():yieldpage
The SDK provides access to raw response data, including headers, through the.with_raw_response
property.The.with_raw_response
property returns a "raw" client that can be used to access the.headers
and.data
attributes.
frompipedreamimportPipedreamclient=Pipedream( ...,)response=client.accounts.with_raw_response.create(...)print(response.headers)# access the response headersprint(response.data)# access the underlying objectpager=client.apps.list(...)print(pager.response.headers)# access the response headers for the first pageforiteminpager:print(item)# access the underlying object(s)forpageinpager.iter_pages():print(page.response.headers)# access the response headers for each pageforiteminpage:print(item)# access the underlying object(s)
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as longas the request is deemed retryable and the number of retry attempts has not grown larger than the configuredretry limit (default: 2).
A request is deemed retryable when any of the following HTTP status codes is returned:
Use themax_retries
request option to configure this behavior.
client.accounts.create(...,request_options={"max_retries":1})
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
frompipedreamimportPipedreamclient=Pipedream( ...,timeout=20.0,)# Override timeout for a specific methodclient.accounts.create(...,request_options={"timeout_in_seconds":1})
You can override thehttpx
client to customize it for your use-case. Some common use-cases include support for proxiesand transports.
importhttpxfrompipedreamimportPipedreamclient=Pipedream( ...,httpx_client=httpx.Client(proxies="http://my.test.proxy.example.com",transport=httpx.HTTPTransport(local_address="0.0.0.0"), ),)
While we value open-source contributions to this SDK, this library is generated programmatically.Additions made directly to this library would have to be moved over to our generation code,otherwise they would be overwritten upon the next generated release. Feel free to open a PR asa proof of concept, but know that we will not be able to merge it as-is. We suggest openingan issue first to discuss with us!
On the other hand, contributions to the README are always very welcome!
About
Python SDK for Pipedream
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors2
Uh oh!
There was an error while loading.Please reload this page.