Name | apitoolkit-fastapi JSON |
Version |
2.0.0
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-12-24 09:39:39 |
maintainer | None |
docs_url | None |
author | APIToolkit |
requires_python | None |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<div align="center">


## FastAPI SDK
[](https://github.com/topics/apitoolkit-sdk) [](https://pypi.org/project/apitoolkit-fastapi) [](https://pypi.org/project/apitoolkit-fastapi) [](https://apitoolkit.io/discord?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme) [](https://apitoolkit.io/docs/sdks/python/fastapi?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme)
APIToolkit FastAPI SDK is a middleware that can be used to monitor incoming HTTP requests, errors and outgoing requests. It is provides additional functionalities on top of the open telemetry instrumentation which creates a custom span for each request capturing details about the request including request, response bodies, headers, status code, duration, etc.
</div>
---
## Table of Contents
- [Installation](#installation)
- [Setup Open Telemetry](#setup-open-telemetry)
- [Configuration](#apitoolkit-fastapi-configuration)
- [Contributing and Help](#contributing-and-help)
- [License](#license)
---
## Installation
Kindly run the command below to install the apitoolkit pyramid sdks and necessary opentelemetry packages:
```sh
pip install apitoolkit-fastapi opentelemetry-distro opentelemetry-exporter-otlp
opentelemetry-bootstrap -a install
```
## Setup Open Telemetry
Setting up open telemetry allows you to send traces, metrics and logs to the APIToolkit platform.
To setup open telemetry, you need to configure the following environment variables:
```sh
OTEL_EXPORTER_OTLP_ENDPOINT="http://otelcol.apitoolkit.io:4317"
OTEL_SERVICE_NAME="my-service" # Specifies the name of the service.
OTEL_RESOURCE_ATTRIBUTES="at-project-key={ENTER_YOUR_API_KEY_HERE}" # Adds your API KEY to the resource.
OTEL_EXPORTER_OTLP_PROTOCOL="grpc" #Specifies the protocol to use for the OpenTelemetry exporter.
```
Then run the command below to start your server with opentelemetry instrumented:
```sh
opentelemetry-instrument python3 myapp.py
```
## APIToolkit FastAPI Configuration
Next, initialize APItoolkit in your application's entry point (e.g., `main.py`), like so:
```python
from fastapi import FastAPI
from apitoolkit_fastapi import APIToolkit
app = FastAPI()
# Initialize APItoolkit
apitoolkit = APIToolkit(service_name="my-service")
app.middleware('http')(apitoolkit.middleware)
@app.get("/")
def read_root():
return {"Hello": "World"}
```
> [!NOTE]
>
> The `{ENTER_YOUR_API_KEY_HERE}` demo string should be replaced with the [API key](https://apitoolkit.io/docs/dashboard/settings-pages/api-keys?utm_source=github-sdks) generated from the APItoolkit dashboard.
<br />
> [!IMPORTANT]
>
> To learn more configuration options (redacting fields, error reporting, outgoing requests, etc.), please read this [SDK documentation](https://apitoolkit.io/docs/sdks/python/fastapi?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme).
## Contributing and Help
To contribute to the development of this SDK or request help from the community and our team, kindly do any of the following:
- Read our [Contributors Guide](https://github.com/apitoolkit/.github/blob/main/CONTRIBUTING.md).
- Join our community [Discord Server](https://apitoolkit.io/discord?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme).
- Create a [new issue](https://github.com/apitoolkit/apitoolkit-fastapi/issues/new/choose) in this repository.
## License
This repository is published under the [MIT](LICENSE) license.
---
<div align="center">
<a href="https://apitoolkit.io?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme" target="_blank" rel="noopener noreferrer"><img src="https://github.com/apitoolkit/.github/blob/main/images/icon.png?raw=true" width="40" /></a>
</div>
Raw data
{
"_id": null,
"home_page": null,
"name": "apitoolkit-fastapi",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "APIToolkit",
"author_email": "hello@apitoolkit.io",
"download_url": "https://files.pythonhosted.org/packages/e0/b6/374f420ebbf03170c08a20f49fd9d23b1a8386d24bcc67a4cbc1a6adf4c3/apitoolkit_fastapi-2.0.0.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n\n\n\n\n## FastAPI SDK\n\n[](https://github.com/topics/apitoolkit-sdk) [](https://pypi.org/project/apitoolkit-fastapi) [](https://pypi.org/project/apitoolkit-fastapi) [](https://apitoolkit.io/discord?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme) [](https://apitoolkit.io/docs/sdks/python/fastapi?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme)\n\nAPIToolkit FastAPI SDK is a middleware that can be used to monitor incoming HTTP requests, errors and outgoing requests. It is provides additional functionalities on top of the open telemetry instrumentation which creates a custom span for each request capturing details about the request including request, response bodies, headers, status code, duration, etc.\n\n</div>\n\n---\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Setup Open Telemetry](#setup-open-telemetry)\n- [Configuration](#apitoolkit-fastapi-configuration)\n- [Contributing and Help](#contributing-and-help)\n- [License](#license)\n\n---\n\n## Installation\n\nKindly run the command below to install the apitoolkit pyramid sdks and necessary opentelemetry packages:\n\n```sh\npip install apitoolkit-fastapi opentelemetry-distro opentelemetry-exporter-otlp\nopentelemetry-bootstrap -a install\n```\n\n## Setup Open Telemetry\n\nSetting up open telemetry allows you to send traces, metrics and logs to the APIToolkit platform.\nTo setup open telemetry, you need to configure the following environment variables:\n\n```sh\nOTEL_EXPORTER_OTLP_ENDPOINT=\"http://otelcol.apitoolkit.io:4317\"\nOTEL_SERVICE_NAME=\"my-service\" # Specifies the name of the service.\nOTEL_RESOURCE_ATTRIBUTES=\"at-project-key={ENTER_YOUR_API_KEY_HERE}\" # Adds your API KEY to the resource.\nOTEL_EXPORTER_OTLP_PROTOCOL=\"grpc\" #Specifies the protocol to use for the OpenTelemetry exporter.\n```\n\nThen run the command below to start your server with opentelemetry instrumented:\n\n```sh\nopentelemetry-instrument python3 myapp.py\n```\n\n## APIToolkit FastAPI Configuration\n\nNext, initialize APItoolkit in your application's entry point (e.g., `main.py`), like so:\n\n```python\nfrom fastapi import FastAPI\nfrom apitoolkit_fastapi import APIToolkit\n\napp = FastAPI()\n\n# Initialize APItoolkit\napitoolkit = APIToolkit(service_name=\"my-service\")\napp.middleware('http')(apitoolkit.middleware)\n\n\n@app.get(\"/\")\ndef read_root():\n return {\"Hello\": \"World\"}\n```\n\n> [!NOTE]\n>\n> The `{ENTER_YOUR_API_KEY_HERE}` demo string should be replaced with the [API key](https://apitoolkit.io/docs/dashboard/settings-pages/api-keys?utm_source=github-sdks) generated from the APItoolkit dashboard.\n\n<br />\n\n> [!IMPORTANT]\n>\n> To learn more configuration options (redacting fields, error reporting, outgoing requests, etc.), please read this [SDK documentation](https://apitoolkit.io/docs/sdks/python/fastapi?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme).\n\n## Contributing and Help\n\nTo contribute to the development of this SDK or request help from the community and our team, kindly do any of the following:\n\n- Read our [Contributors Guide](https://github.com/apitoolkit/.github/blob/main/CONTRIBUTING.md).\n- Join our community [Discord Server](https://apitoolkit.io/discord?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme).\n- Create a [new issue](https://github.com/apitoolkit/apitoolkit-fastapi/issues/new/choose) in this repository.\n\n## License\n\nThis repository is published under the [MIT](LICENSE) license.\n\n---\n\n<div align=\"center\">\n\n<a href=\"https://apitoolkit.io?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme\" target=\"_blank\" rel=\"noopener noreferrer\"><img src=\"https://github.com/apitoolkit/.github/blob/main/images/icon.png?raw=true\" width=\"40\" /></a>\n\n</div>\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "2.0.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4468bdd936be3146eca095d0cec0d7ad87a868b5bab1332b9e26a9247f3497b0",
"md5": "f6957b82db163bdc64ff7d9241a885bf",
"sha256": "81f9de58d6ae7783387ea5c8087825eb3d2409ffe40ecbb8f73ccf1ab6a62ee4"
},
"downloads": -1,
"filename": "apitoolkit_fastapi-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f6957b82db163bdc64ff7d9241a885bf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4226,
"upload_time": "2024-12-24T09:39:36",
"upload_time_iso_8601": "2024-12-24T09:39:36.453552Z",
"url": "https://files.pythonhosted.org/packages/44/68/bdd936be3146eca095d0cec0d7ad87a868b5bab1332b9e26a9247f3497b0/apitoolkit_fastapi-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e0b6374f420ebbf03170c08a20f49fd9d23b1a8386d24bcc67a4cbc1a6adf4c3",
"md5": "7fa898fae855efd7a35bfe2e8b5b12f0",
"sha256": "081115981a739df1558acdc2cc337c1af2f707ac89cfca0c70a8a8ef28c5f93c"
},
"downloads": -1,
"filename": "apitoolkit_fastapi-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "7fa898fae855efd7a35bfe2e8b5b12f0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4130,
"upload_time": "2024-12-24T09:39:39",
"upload_time_iso_8601": "2024-12-24T09:39:39.474004Z",
"url": "https://files.pythonhosted.org/packages/e0/b6/374f420ebbf03170c08a20f49fd9d23b1a8386d24bcc67a4cbc1a6adf4c3/apitoolkit_fastapi-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-24 09:39:39",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "apitoolkit-fastapi"
}