No project description provided
Project description
MultiOn Python Library
The MultiOn Python Library provides convenient access to the MultiOn API from applications written in Python.
Documentation
API reference documentation is available here.
Installation
Add this dependency to your project's build file:
pip install multion
# or
poetry add multion
Usage
Simply import MultiOn
and start making calls to our API.
from multion.client import MultiOn
client = MultiOn(
api_key="YOUR_API_KEY" # defaults to os.getenv("MULTION_API_KEY")
)
response = client.browse(
url="https://google.com"
)
Async Client
The SDK also exports an async client so that you can make non-blocking calls to our API.
from multion.client import AsyncMultiOn
client = AsyncMultiOn(
api_key="YOUR_API_KEY" # defaults to os.getenv("MULTION_API_KEY")
)
async def main() -> None:
await response = client.browse(
url="https://google.com"
)
asyncio.run(main())
Exception Handling
All errors thrown by the SDK will be subclasses of ApiError
.
import multion
try:
client.browse(...)
except multion.core.ApiError as e: # Handle all errors
print(e.status_code)
print(e.body)
Advanced
Retries
The MultiOn SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retriable and the number of retry attempts has not grown larger than the configured retry limit.
A request is deemed retriable when any of the following HTTP status codes is returned:
Use the max_retries
request option to configure this behavior.
from multion.client import MultiOn
client = MultiOn()
# Override retries for a specific method
client.brwose(url="https://google.com", {
max_retries=1
})
Timeouts
By default, requests time out after 60 seconds. You can configure this with a timeout option at the client or request level.
from multion.client import MultiOn
client = MultiOn(
# All timeouts are 20 seconds
timeout=20.0,
)
# Override timeout for a specific method
client.brwose(url="https://google.com", {
timeout_in_seconds=20.0
})
Custom HTTP client
You can override the httpx client to customize it for your use-case. Some common use-cases include support for proxies and transports.
import httpx
from multion.client import MultiOn
client = MultiOn(
http_client=httpx.Client(
proxies="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
)
Beta Status
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version. This way, you can install the same version each time without breaking changes.
Contributing
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 as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!
On the other hand, contributions to the README are always very welcome!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file multion-1.3.7.tar.gz
.
File metadata
- Download URL: multion-1.3.7.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/5.15.0-1070-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7248bbb0e1d85fed0f1407c2ba2de0fa2ef40fe700602059d9a6842cae2513b |
|
MD5 | 37df662e6203c66587d7c123cb4a926a |
|
BLAKE2b-256 | c556afb0ffd16687860a22fa444008c4e0183b73e1429166a5799942bac4adb5 |
File details
Details for the file multion-1.3.7-py3-none-any.whl
.
File metadata
- Download URL: multion-1.3.7-py3-none-any.whl
- Upload date:
- Size: 49.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/5.15.0-1070-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebc636afdbb88b68331c439461c9232a57e9cf103d38c5464f19a428c0d5c4c6 |
|
MD5 | 65f03b08a3344c287400936abe7ee9d3 |
|
BLAKE2b-256 | 982a9027222bfdb28bf41ff4f4d31c3b2cc16b97d3e52fb42253bccd2cf24f91 |