# Airtop Python Library
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fairtop-ai%2Fairtop-python-sdk)
[![pypi](https://img.shields.io/pypi/v/airtop)](https://pypi.python.org/pypi/airtop)
The Airtop Python library provides convenient access to the Airtop API from Python.
## Installation
```sh
pip install airtop
```
## Reference
A full reference for this library is available [here](./reference.md).
## Usage
Instantiate and use the client with the following:
```python
from airtop import Airtop
client = Airtop(
api_key="YOUR_API_KEY",
)
client.sessions.create()
```
## Async Client
The SDK also exports an `async` client so that you can make non-blocking calls to our API.
```python
import asyncio
from airtop import AsyncAirtop
client = AsyncAirtop(
api_key="YOUR_API_KEY",
)
async def main() -> None:
await client.sessions.create()
asyncio.run(main())
```
## Exception Handling
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
will be thrown.
```python
from airtop.core.api_error import ApiError
try:
client.sessions.create(...)
except ApiError as e:
print(e.status_code)
print(e.body)
```
## Streaming
The SDK supports streaming responses, as well, the response will be a generator that you can loop over.
```python
from airtop import Airtop
client = Airtop(
api_key="YOUR_API_KEY",
)
response = client.sessions.events(
id="string",
)
for chunk in response:
yield chunk
```
## Advanced
### Retries
The 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 (default: 2).
A request is deemed retriable when any of the following HTTP status codes is returned:
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
Use the `max_retries` request option to configure this behavior.
```python
client.sessions.create(..., request_options={
"max_retries": 1
})
```
### Timeouts
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
```python
from airtop import Airtop
client = Airtop(
...,
timeout=20.0,
)
# Override timeout for a specific method
client.sessions.create(..., request_options={
"timeout_in_seconds": 1
})
```
### Custom Client
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
and transports.
```python
import httpx
from airtop import Airtop
client = Airtop(
...,
httpx_client=httpx.Client(
proxies="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
)
```
## 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!
Raw data
{
"_id": null,
"home_page": null,
"name": "airtop",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "airtop, ai, cloud, browser, automation, agent, python",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/4c/0d/9419cafacdf8b360dcebaf1eb9f758315636ec126ba6965400798efdd698/airtop-0.0.25.tar.gz",
"platform": null,
"description": "# Airtop Python Library\n\n[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fairtop-ai%2Fairtop-python-sdk)\n[![pypi](https://img.shields.io/pypi/v/airtop)](https://pypi.python.org/pypi/airtop)\n\nThe Airtop Python library provides convenient access to the Airtop API from Python.\n\n## Installation\n\n```sh\npip install airtop\n```\n\n## Reference\n\nA full reference for this library is available [here](./reference.md).\n\n## Usage\n\nInstantiate and use the client with the following:\n\n```python\nfrom airtop import Airtop\n\nclient = Airtop(\n api_key=\"YOUR_API_KEY\",\n)\nclient.sessions.create()\n```\n\n## Async Client\n\nThe SDK also exports an `async` client so that you can make non-blocking calls to our API.\n\n```python\nimport asyncio\n\nfrom airtop import AsyncAirtop\n\nclient = AsyncAirtop(\n api_key=\"YOUR_API_KEY\",\n)\n\n\nasync def main() -> None:\n await client.sessions.create()\n\n\nasyncio.run(main())\n```\n\n## Exception Handling\n\nWhen the API returns a non-success status code (4xx or 5xx response), a subclass of the following error\nwill be thrown.\n\n```python\nfrom airtop.core.api_error import ApiError\n\ntry:\n client.sessions.create(...)\nexcept ApiError as e:\n print(e.status_code)\n print(e.body)\n```\n\n## Streaming\n\nThe SDK supports streaming responses, as well, the response will be a generator that you can loop over.\n\n```python\nfrom airtop import Airtop\n\nclient = Airtop(\n api_key=\"YOUR_API_KEY\",\n)\nresponse = client.sessions.events(\n id=\"string\",\n)\nfor chunk in response:\n yield chunk\n```\n\n## Advanced\n\n### Retries\n\nThe SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long\nas the request is deemed retriable and the number of retry attempts has not grown larger than the configured\nretry limit (default: 2).\n\nA request is deemed retriable when any of the following HTTP status codes is returned:\n\n- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)\n- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)\n- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)\n\nUse the `max_retries` request option to configure this behavior.\n\n```python\nclient.sessions.create(..., request_options={\n \"max_retries\": 1\n})\n```\n\n### Timeouts\n\nThe SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.\n\n```python\n\nfrom airtop import Airtop\n\nclient = Airtop(\n ...,\n timeout=20.0,\n)\n\n\n# Override timeout for a specific method\nclient.sessions.create(..., request_options={\n \"timeout_in_seconds\": 1\n})\n```\n\n### Custom Client\n\nYou can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies\nand transports.\n```python\nimport httpx\nfrom airtop import Airtop\n\nclient = Airtop(\n ...,\n httpx_client=httpx.Client(\n proxies=\"http://my.test.proxy.example.com\",\n transport=httpx.HTTPTransport(local_address=\"0.0.0.0\"),\n ),\n)\n```\n\n## Contributing\n\nWhile we value open-source contributions to this SDK, this library is generated programmatically.\nAdditions made directly to this library would have to be moved over to our generation code,\notherwise they would be overwritten upon the next generated release. Feel free to open a PR as\na proof of concept, but know that we will not be able to merge it as-is. We suggest opening\nan issue first to discuss with us!\n\nOn the other hand, contributions to the README are always very welcome!\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "SDK for Airtop cloud browsers",
"version": "0.0.25",
"project_urls": null,
"split_keywords": [
"airtop",
" ai",
" cloud",
" browser",
" automation",
" agent",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8485c66402573c0e98825e8d2d9746ef17b5e60cbb4ee75f45e967a0ba9bd86e",
"md5": "9069986c3dafda2390ecae56987974de",
"sha256": "6282ec14f454d1d0e619df17d654f71d2f29484fc653aa2f628d1a3e79253a40"
},
"downloads": -1,
"filename": "airtop-0.0.25-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9069986c3dafda2390ecae56987974de",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 69690,
"upload_time": "2024-11-07T19:28:28",
"upload_time_iso_8601": "2024-11-07T19:28:28.932118Z",
"url": "https://files.pythonhosted.org/packages/84/85/c66402573c0e98825e8d2d9746ef17b5e60cbb4ee75f45e967a0ba9bd86e/airtop-0.0.25-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4c0d9419cafacdf8b360dcebaf1eb9f758315636ec126ba6965400798efdd698",
"md5": "a7de727b4ece09d5e94dbaae743a57d2",
"sha256": "bfeed89de46f16d399ce6cc440bb67fde8dcff083a3130e06a7e7c329cacdca3"
},
"downloads": -1,
"filename": "airtop-0.0.25.tar.gz",
"has_sig": false,
"md5_digest": "a7de727b4ece09d5e94dbaae743a57d2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 35897,
"upload_time": "2024-11-07T19:28:30",
"upload_time_iso_8601": "2024-11-07T19:28:30.656945Z",
"url": "https://files.pythonhosted.org/packages/4c/0d/9419cafacdf8b360dcebaf1eb9f758315636ec126ba6965400798efdd698/airtop-0.0.25.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-07 19:28:30",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "airtop"
}