Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Website | Get Started | Documentation | GitHub Discussions | Twitter | Support

Superface

Superface OneSDK

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

GitHub Workflow Status license GitHub Discussions npm

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 and Get Started.

Important Links

Install

To install OneSDK into the project, run:

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. The use-case is described in the profile communication/send-email and the map with implementation.

  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:

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:

python __main__.py

License

OneSDK is licensed under the MIT License.

© 2023 Superface s.r.o.

Metadata

Release files for one-sdk 1.0.0b14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for one-sdk 1.0.0b14
File Size Uploaded
one_sdk-1.0.0b14.tar.gz 1.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for one-sdk 1.0.0b14
File Interpreter ABI Platform
one_sdk-1.0.0b14-py3-none-any.whl Python 3 none any Details

Total release size: 2.4 MB

Release files / one_sdk-1.0.0b14.tar.gz

Download URL one_sdk-1.0.0b14.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
0521043fa905613eb37b5081476b7d11bbc08e97b8952e8fa0c57543dc890a0d
BLAKE2b-256 checksum
How to use checksums
af7653d69fa75b83c6b4c31f269ac449b82033b37c7d573ab3b1998e39a05e67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / one_sdk-1.0.0b14-py3-none-any.whl

Download URL one_sdk-1.0.0b14-py3-none-any.whl
Size 1.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
cd59294582f983f192d8dbc1506f4a25a3c6e7115fa491e5a3a164c75a707fc7
BLAKE2b-256 checksum
How to use checksums
51d5404142a4dfe292c8fec6e00c445ba0cffc29c19aa794f4cfb411b74d5811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page