Skip to main content

Ding Python SDK

The Ding Python library provides convenient access to the Ding API from applications written in the Python language.

Summary

Ding: The OTP API allows you to send authentication codes to your users using their phone numbers.

Table of Contents

SDK Installation

The SDK can be installed using the pip package manager, with dependencies and metadata stored in the setup.py file.

pip install ding_api_client

SDK Example Usage

SDK Example Usage

Send a code

Send an OTP code to a user's phone number.

import ding
from ding.models import components

s = ding.Ding(
    api_key='YOUR_API_KEY',
)


res = s.otp.create_authentication(request=components.CreateAuthenticationRequest(
    customer_uuid='cf2edc1c-7fc6-48fb-86da-b7508c6b7b71',
    phone_number='+1234567890',
    locale='fr-FR',
))

if res.create_authentication_response is not None:
    # handle response
    pass

Check a code

Check that a code entered by a user is valid.

import ding
from ding.models import components

s = ding.Ding(
    api_key='YOUR_API_KEY',
)


res = s.otp.check(request=components.CreateCheckRequest(
    customer_uuid='eebe792b-2fcc-44a0-87f1-650e79259e02',
    authentication_uuid='64f66a7c-4b2c-4131-a8ff-d5b954cca05f',
    check_code='123456',
))

if res.create_check_response is not None:
    # handle response
    pass

Perform a retry

Perform a retry if a user has not received the code.

import ding

s = ding.Ding(
    api_key='YOUR_API_KEY',
)


res = s.otp.retry()

if res.retry_authentication_response is not None:
    # handle response
    pass

Send feedback

Send feedback about the authentication process.

import ding
from ding.models import components

s = ding.Ding(
    api_key='YOUR_API_KEY',
)


res = s.otp.feedback(request=components.FeedbackRequest(
    customer_uuid='cc0f6c04-40de-448f-8301-3cb0e6565dff',
    phone_number='+1234567890',
    status=components.FeedbackRequestStatus.ONBOARDED,
))

if res.feedback_response is not None:
    # handle response
    pass

Get authentication status

Get the status of an authentication.

import ding

s = ding.Ding(
    api_key='YOUR_API_KEY',
)


res = s.otp.get_authentication_status(auth_uuid='d8446450-f2fa-4dd9-806b-df5b8c661f23')

if res.authentication_status_response is not None:
    # handle response
    pass

Look up for phone number

Perform a phone number lookup.

import ding

s = ding.Ding(
    api_key='YOUR_API_KEY',
)


res = s.lookup.lookup(phone_number='<value>', customer_uuid='69a197d9-356c-45d1-a807-41874e16b555')

if res.lookup_response is not None:
    # handle response
    pass

Available Resources and Operations

Available methods

lookup

  • lookup - Look up for phone number

otp

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.

By default, an API error will raise a errors.SDKError exception, which has the following properties:

Property Type Description
.status_code int The HTTP status code
.message str The error message
.raw_response httpx.Response The raw HTTP response
.body str The response content

When custom error responses are specified for an operation, the SDK may also raise their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the create_authentication method may raise the following exceptions:

Error Type Status Code Content Type
errors.ErrorResponse 400 application/json
errors.SDKError 4XX, 5XX */*

Example

import ding
from ding.models import components, errors

s = ding.Ding(
    api_key='YOUR_API_KEY',
)

res = None
try:
    res = s.otp.create_authentication(request=components.CreateAuthenticationRequest(
    customer_uuid='cf2edc1c-7fc6-48fb-86da-b7508c6b7b71',
    phone_number='+1234567890',
    locale='fr-FR',
))

except errors.ErrorResponse as e:
    # handle exception
    raise(e)
except errors.SDKError as e:
    # handle exception
    raise(e)

if res.create_authentication_response is not None:
    # handle response
    pass

Server Selection

Override Server URL Per-Client

The default server can be overridden globally by passing a URL to the server_url: str optional parameter when initializing the SDK client instance. For example:

import ding
from ding.models import components

s = ding.Ding(
    server_url='https://api.ding.live/v1',
    api_key='YOUR_API_KEY',
)


res = s.otp.create_authentication(request=components.CreateAuthenticationRequest(
    customer_uuid='cf2edc1c-7fc6-48fb-86da-b7508c6b7b71',
    phone_number='+1234567890',
    locale='fr-FR',
))

if res.create_authentication_response is not None:
    # handle response
    pass

Custom HTTP Client

The Python SDK makes API calls using the requests HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom requests.Session object.

For example, you could specify a header for every request that this sdk makes as follows:

import ding
import requests

http_client = requests.Session()
http_client.headers.update({'x-custom-header': 'someValue'})
s = ding.Ding(client=http_client)

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
api_key apiKey API key

To authenticate with the API the api_key parameter must be set when initializing the SDK client instance. For example:

import ding
from ding.models import components

s = ding.Ding(
    api_key='YOUR_API_KEY',
)


res = s.otp.create_authentication(request=components.CreateAuthenticationRequest(
    customer_uuid='cf2edc1c-7fc6-48fb-86da-b7508c6b7b71',
    phone_number='+1234567890',
    locale='fr-FR',
))

if res.create_authentication_response is not None:
    # handle response
    pass

Development

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

Metadata

Release files for ding-api-client 3.9.120

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

Source distribution (sdist)

Source distribution for ding-api-client 3.9.120
File Size Uploaded
ding_api_client-3.9.120.tar.gz 26.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ding-api-client 3.9.120
File Interpreter ABI Platform
ding_api_client-3.9.120-py3-none-any.whl Python 3 none any Details

Total release size: 63.6 kB

Release files / ding_api_client-3.9.120.tar.gz

Download URL ding_api_client-3.9.120.tar.gz
Size 26.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ee55a7a7346f0f157f1fbc8cec7f9ea87fe599982039b8042f28648bb353e3b8
BLAKE2b-256 checksum
How to use checksums
d74af5f5ca46e7065ec292e7ed0b516a0d2ea36f44aa38e33c38196261421a7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / ding_api_client-3.9.120-py3-none-any.whl

Download URL ding_api_client-3.9.120-py3-none-any.whl
Size 37.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fea0cf8f2ca557f4d5426b34acd922f91f95c11ef0b63df91d1dfb13f1ccdb11
BLAKE2b-256 checksum
How to use checksums
f80dcd82dcab8e96a793568bb1d4d00104f05f9190821dc70f049445250c3e65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release history Release notifications | RSS feed

This release

3.9.120 This release

2 release files

3.9.94

2 release files

3.9.93

2 release files

3.9.92

2 release files

3.9.91

2 release files

3.9.90

2 release files

3.9.89

2 release files

3.9.88

2 release files

3.9.87

2 release files

3.9.86

2 release files

3.9.85

2 release files

3.9.84

2 release files

3.9.83

2 release files

3.9.82

2 release files

3.9.81

2 release files

3.9.80

2 release files

3.9.79

2 release files

3.9.78

2 release files

3.9.77

2 release files

3.9.76

2 release files

3.9.75

2 release files

3.9.74

2 release files

3.9.64

2 release files

3.9.63

2 release files

3.9.62

2 release files

3.9.61

2 release files

3.9.60

2 release files

3.9.59

2 release files

3.9.58

2 release files

3.9.57

2 release files

3.9.56

2 release files

3.9.55

2 release files

3.9.54

2 release files

3.9.53

2 release files

3.9.52

2 release files

3.9.51

2 release files

3.9.50

2 release files

3.9.49

2 release files

3.9.48

2 release files

3.9.47

2 release files

3.9.46

2 release files

3.9.45

2 release files

3.9.44

2 release files

3.9.43

2 release files

3.9.33

2 release files

3.9.32

2 release files

3.9.31

2 release files

3.9.30

2 release files

3.9.29

2 release files

3.9.28

2 release files

3.9.27

2 release files

3.9.26

2 release files

3.9.25

2 release files

3.9.24

2 release files

3.9.23

2 release files

3.9.22

2 release files

3.9.21

2 release files

3.9.20

2 release files

3.9.19

2 release files

3.9.18

2 release files

3.9.17

2 release files

3.9.16

2 release files

3.9.15

2 release files

3.9.14

2 release files

3.9.13

2 release files

3.9.9

2 release files

3.9.8

2 release files

3.9.7

2 release files

3.9.6

2 release files

3.9.5

2 release files

3.9.4

2 release files

3.9.3

2 release files

3.9.2

2 release files

3.9.1

2 release files

3.9.0

2 release files

3.8.11

2 release files

3.8.9

2 release files

3.8.8

2 release files

3.8.7

2 release files

3.8.6

2 release files

3.8.5

2 release files

3.8.4

2 release files

3.8.3

2 release files

3.8.2

2 release files

3.8.1

2 release files

3.8.0

2 release files

3.7.6

2 release files

3.7.5

2 release files

3.7.4

2 release files

3.7.3

2 release files

3.7.2

2 release files

3.7.1

2 release files

3.7.0

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.5

2 release files

3.4.4

2 release files

3.4.3

2 release files

3.4.2

2 release files

3.4.1

2 release files

3.4.0

2 release files

3.3.5

2 release files

3.3.4

2 release files

3.3.3

2 release files

3.3.2

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

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