one-sdk


Nameone-sdk JSON
Version 1.0.0b11 PyPI version JSON
download
home_page
SummaryOneSDK is a universal API client which provides an unparalleled developer experience for every HTTP API
upload_time2024-02-26 16:43:57
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords superface api client sdk one-sdk ai integrations
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [Website](https://superface.ai) | [Get Started](https://superface.ai/docs/getting-started) | [Documentation](https://superface.ai/docs) | [GitHub Discussions](https://sfc.is/discussions) | [Twitter](https://twitter.com/superfaceai) | [Support](https://superface.ai/support)
<br />
<br />
<img src="https://github.com/superfaceai/one-sdk/raw/main/docs/LogoGreen.png" alt="Superface" width="100" height="100">

# Superface OneSDK

**One SDK for all the APIs you want to integrate with.**

[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/superfaceai/one-sdk/ci_cd.yml)](https://github.com/superfaceai/one-sdk/actions/workflows/ci_cd.yml)
[![license](https://img.shields.io/npm/l/@superfaceai/one-sdk)](LICENSE)
[![GitHub Discussions](https://img.shields.io/github/discussions/superfaceai/.github?logo=github&logoColor=fff)](https://github.com/orgs/superfaceai/discussions)
[![npm](https://img.shields.io/pypi/v/one-sdk)](https://pypi.org/project/one-sdk/)

`OneClient` is a universal API client which provides an unparalleled developer experience for every HTTP API. It enhances resiliency to API changes, and comes with built-in integration monitoring and provider failover.

For more details about Superface, visit [How it Works](https://superface.ai/how-it-works) and [Get Started](https://superface.ai/docs/getting-started).

## Important Links

- [Superface website](https://superface.ai)
- [Get Started](https://superface.ai/docs/getting-started)
- [Documentation](https://superface.ai/docs)
- [Support](https://superface.ai/support)

## Install

To install OneSDK into the project, run:

```shell
python3 -m pip install one-sdk
```

## Setup

OneClient uses three files (also called Comlink) which together make the integration:

- **Profile** - describe business capabilities apart from the implementation details, what is expected as input and what will be the result. Profile name have optional scope before `/` and required name `[scope/]<name>`
- **Provider** - Define a provider's API services and security schemes to use in a Comlink Map
- **Map** - describe implementation details for fulfilling a business capability from a Comlink Profile

To glue all the parts together, OneClient uses name and file structure convention.

```
.
└── superface/ - directory with all the Comlinks in project root
    ├── <profileScope>.<profileName>.profile - profile file
    ├── <providerName>.provider.json - provider file
    ├── <profileScope>.<profileName>.<providerName>.map.js - map file
    └── ... - repeat for all the Comlinks
```

### Send email example

As an example, lets send an email with [Mailchimp](https://github.com/superfaceai/one-sdk/blob/main/examples/maps/src/mailchimp.provider.json). The use-case is described in the profile [communication/send-email](https://github.com/superfaceai/one-sdk/blob/main/examples/maps/src/communication.send-email.profile) and the map with [implementation](https://github.com/superfaceai/one-sdk/blob/feat/superface_assets_convention/examples/maps/src/communication.send-email.mailchimp.map.js).

1. Start with creating a new directory `superface` in the root of your project.
2. Add the profile. Because profile name contains have scope we need to replace `/` with `.`. So, the profile with name `communication/send-email` have corresponding filename `communication.send-email.profile`.
3. Add the provider. The provider name is the same as the filename. So the provider with name `mailchimp` have corresponding filename `mailchimp.provider.json`.
4. Add the map. Map connects profile and provider, so the filename is consists of both as well `communication.send-email.mailchimp.map.js`.

The final structure should look like this:

```
.
└── superface/
    ├── communication.send-email.mailchimp.map.js
    ├── communication.send-email.profile
    └── mailchimp.provider.json
```

## Use

Create `__main__.py` file with following content and update:

```py
import sys
from one_sdk import OneClient, PerformError, UnexpectedError

client = OneClient()
profile = client.get_profile("<profileName>")
use_case = profile.get_usecase("<usecaseName>")
try:
    r = use_case.perform(
        {
            # Input parameters as defined in profile:
            '<key>': '<value>'
        },
        provider = "<providerName>",
        # Provider specific integration parameters:
        parameters = {
            '<integrationParameterName>': '<integrationParameterValue>'
        },
        security = {
            # Provider specific security values:
            '<securityValueId>': {
                # Security values as described in provider or on profile page
            }
        }
    )
    print(f"RESULT: {r}")
except PerformError as e:
    print(f"ERROR RESULT: {e.error_result}")
except ValidationError as e:
    print(f"INVALID INPUT: {e.message}", file = sys.stderr)
except UnexpectedError as e:
    print(f"ERROR:", e, file = sys.stderr)
finally:
    client.send_metrics_to_superface()
```

Then run the script with:

```shell
python __main__.py
```

## License

OneSDK is licensed under the [MIT License](LICENSE).

© 2023 Superface s.r.o.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "one-sdk",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "superface,api,client,sdk,one-sdk,ai,integrations",
    "author": "",
    "author_email": "Superface Team <hello@superface.ai>",
    "download_url": "https://files.pythonhosted.org/packages/9a/1b/db27205299e9b5d0d5761e702239659e51460053ed8ea982bc5af8a02ef6/one-sdk-1.0.0b11.tar.gz",
    "platform": null,
    "description": "[Website](https://superface.ai) | [Get Started](https://superface.ai/docs/getting-started) | [Documentation](https://superface.ai/docs) | [GitHub Discussions](https://sfc.is/discussions) | [Twitter](https://twitter.com/superfaceai) | [Support](https://superface.ai/support)\n<br />\n<br />\n<img src=\"https://github.com/superfaceai/one-sdk/raw/main/docs/LogoGreen.png\" alt=\"Superface\" width=\"100\" height=\"100\">\n\n# Superface OneSDK\n\n**One SDK for all the APIs you want to integrate with.**\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/superfaceai/one-sdk/ci_cd.yml)](https://github.com/superfaceai/one-sdk/actions/workflows/ci_cd.yml)\n[![license](https://img.shields.io/npm/l/@superfaceai/one-sdk)](LICENSE)\n[![GitHub Discussions](https://img.shields.io/github/discussions/superfaceai/.github?logo=github&logoColor=fff)](https://github.com/orgs/superfaceai/discussions)\n[![npm](https://img.shields.io/pypi/v/one-sdk)](https://pypi.org/project/one-sdk/)\n\n`OneClient` is a universal API client which provides an unparalleled developer experience for every HTTP API. It enhances resiliency to API changes, and comes with built-in integration monitoring and provider failover.\n\nFor more details about Superface, visit [How it Works](https://superface.ai/how-it-works) and [Get Started](https://superface.ai/docs/getting-started).\n\n## Important Links\n\n- [Superface website](https://superface.ai)\n- [Get Started](https://superface.ai/docs/getting-started)\n- [Documentation](https://superface.ai/docs)\n- [Support](https://superface.ai/support)\n\n## Install\n\nTo install OneSDK into the project, run:\n\n```shell\npython3 -m pip install one-sdk\n```\n\n## Setup\n\nOneClient uses three files (also called Comlink) which together make the integration:\n\n- **Profile** - describe business capabilities apart from the implementation details, what is expected as input and what will be the result. Profile name have optional scope before `/` and required name `[scope/]<name>`\n- **Provider** - Define a provider's API services and security schemes to use in a Comlink Map\n- **Map** - describe implementation details for fulfilling a business capability from a Comlink Profile\n\nTo glue all the parts together, OneClient uses name and file structure convention.\n\n```\n.\n\u2514\u2500\u2500 superface/ - directory with all the Comlinks in project root\n    \u251c\u2500\u2500 <profileScope>.<profileName>.profile - profile file\n    \u251c\u2500\u2500 <providerName>.provider.json - provider file\n    \u251c\u2500\u2500 <profileScope>.<profileName>.<providerName>.map.js - map file\n    \u2514\u2500\u2500 ... - repeat for all the Comlinks\n```\n\n### Send email example\n\nAs an example, lets send an email with [Mailchimp](https://github.com/superfaceai/one-sdk/blob/main/examples/maps/src/mailchimp.provider.json). The use-case is described in the profile [communication/send-email](https://github.com/superfaceai/one-sdk/blob/main/examples/maps/src/communication.send-email.profile) and the map with [implementation](https://github.com/superfaceai/one-sdk/blob/feat/superface_assets_convention/examples/maps/src/communication.send-email.mailchimp.map.js).\n\n1. Start with creating a new directory `superface` in the root of your project.\n2. Add the profile. Because profile name contains have scope we need to replace `/` with `.`. So, the profile with name `communication/send-email` have corresponding filename `communication.send-email.profile`.\n3. Add the provider. The provider name is the same as the filename. So the provider with name `mailchimp` have corresponding filename `mailchimp.provider.json`.\n4. Add the map. Map connects profile and provider, so the filename is consists of both as well `communication.send-email.mailchimp.map.js`.\n\nThe final structure should look like this:\n\n```\n.\n\u2514\u2500\u2500 superface/\n    \u251c\u2500\u2500 communication.send-email.mailchimp.map.js\n    \u251c\u2500\u2500 communication.send-email.profile\n    \u2514\u2500\u2500 mailchimp.provider.json\n```\n\n## Use\n\nCreate `__main__.py` file with following content and update:\n\n```py\nimport sys\nfrom one_sdk import OneClient, PerformError, UnexpectedError\n\nclient = OneClient()\nprofile = client.get_profile(\"<profileName>\")\nuse_case = profile.get_usecase(\"<usecaseName>\")\ntry:\n    r = use_case.perform(\n        {\n            # Input parameters as defined in profile:\n            '<key>': '<value>'\n        },\n        provider = \"<providerName>\",\n        # Provider specific integration parameters:\n        parameters = {\n            '<integrationParameterName>': '<integrationParameterValue>'\n        },\n        security = {\n            # Provider specific security values:\n            '<securityValueId>': {\n                # Security values as described in provider or on profile page\n            }\n        }\n    )\n    print(f\"RESULT: {r}\")\nexcept PerformError as e:\n    print(f\"ERROR RESULT: {e.error_result}\")\nexcept ValidationError as e:\n    print(f\"INVALID INPUT: {e.message}\", file = sys.stderr)\nexcept UnexpectedError as e:\n    print(f\"ERROR:\", e, file = sys.stderr)\nfinally:\n    client.send_metrics_to_superface()\n```\n\nThen run the script with:\n\n```shell\npython __main__.py\n```\n\n## License\n\nOneSDK is licensed under the [MIT License](LICENSE).\n\n\u00a9 2023 Superface s.r.o.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "OneSDK is a universal API client which provides an unparalleled developer experience for every HTTP API",
    "version": "1.0.0b11",
    "project_urls": {
        "Bug Tracker": "https://github.com/superfaceai/one-sdk/issues",
        "Homepage": "https://github.com/superfaceai/one-sdk/tree/main/packages/python_host"
    },
    "split_keywords": [
        "superface",
        "api",
        "client",
        "sdk",
        "one-sdk",
        "ai",
        "integrations"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f83d1db3a0b4527176a74fc4deddf82aec309ad7af4600f981bf0f7b29bad250",
                "md5": "5020078bbb87a9cfa19adc6452d46cb0",
                "sha256": "22e9ba62e295a42a7855b263c2d6956123ef64dd837b838727bada20fa5324bb"
            },
            "downloads": -1,
            "filename": "one_sdk-1.0.0b11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5020078bbb87a9cfa19adc6452d46cb0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 1195178,
            "upload_time": "2024-02-26T16:43:55",
            "upload_time_iso_8601": "2024-02-26T16:43:55.060754Z",
            "url": "https://files.pythonhosted.org/packages/f8/3d/1db3a0b4527176a74fc4deddf82aec309ad7af4600f981bf0f7b29bad250/one_sdk-1.0.0b11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a1bdb27205299e9b5d0d5761e702239659e51460053ed8ea982bc5af8a02ef6",
                "md5": "0db444118d376de86b57f86aae02cbd6",
                "sha256": "b44444a33a06224f0dd7ac5ae93764b983fd3843fc976f1dad462c5de149c6ee"
            },
            "downloads": -1,
            "filename": "one-sdk-1.0.0b11.tar.gz",
            "has_sig": false,
            "md5_digest": "0db444118d376de86b57f86aae02cbd6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 1193188,
            "upload_time": "2024-02-26T16:43:57",
            "upload_time_iso_8601": "2024-02-26T16:43:57.345438Z",
            "url": "https://files.pythonhosted.org/packages/9a/1b/db27205299e9b5d0d5761e702239659e51460053ed8ea982bc5af8a02ef6/one-sdk-1.0.0b11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-26 16:43:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "superfaceai",
    "github_project": "one-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "one-sdk"
}
        
Elapsed time: 0.72071s