telnyx-numbers-python

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
<!-- 由Telnyx OpenAPI规范自动生成,请勿编辑。 -->

Telnyx Numbers - Python

Telnyx Numbers - Python

Installation

安装

bash
pip install telnyx
bash
pip install telnyx

Setup

设置

python
import os
from telnyx import Telnyx

client = Telnyx(
    api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
)
All examples below assume
client
is already initialized as shown above.
python
import os
from telnyx import Telnyx

client = Telnyx(
    api_key=os.environ.get("TELNYX_API_KEY"),  # 这是默认配置,可省略
)
以下所有示例均假设
client
已按上述方式初始化完成。

Get country coverage

查询国家覆盖范围

GET /country_coverage
python
country_coverage = client.country_coverage.retrieve()
print(country_coverage.data)
GET /country_coverage
python
country_coverage = client.country_coverage.retrieve()
print(country_coverage.data)

Get coverage for a specific country

查询特定国家的覆盖范围

GET /country_coverage/countries/{country_code}
python
response = client.country_coverage.retrieve_country(
    "US",
)
print(response.data)
GET /country_coverage/countries/{country_code}
python
response = client.country_coverage.retrieve_country(
    "US",
)
print(response.data)

Create an inventory coverage request

创建库存覆盖范围请求

Creates an inventory coverage request.
GET /inventory_coverage
python
inventory_coverages = client.inventory_coverage.list()
print(inventory_coverages.data)
创建库存覆盖范围请求。
GET /inventory_coverage
python
inventory_coverages = client.inventory_coverage.list()
print(inventory_coverages.data)

List number reservations

列出号码预留记录

Gets a paginated list of phone number reservations.
GET /number_reservations
python
page = client.number_reservations.list()
page = page.data[0]
print(page.id)
获取电话号码预留的分页列表。
GET /number_reservations
python
page = client.number_reservations.list()
page = page.data[0]
print(page.id)

Create a number reservation

创建号码预留

Creates a Phone Number Reservation for multiple numbers.
POST /number_reservations
python
number_reservation = client.number_reservations.create()
print(number_reservation.data)
为多个号码创建电话号码预留。
POST /number_reservations
python
number_reservation = client.number_reservations.create()
print(number_reservation.data)

Retrieve a number reservation

查询单个号码预留

Gets a single phone number reservation.
GET /number_reservations/{number_reservation_id}
python
number_reservation = client.number_reservations.retrieve(
    "number_reservation_id",
)
print(number_reservation.data)
获取单个电话号码预留记录。
GET /number_reservations/{number_reservation_id}
python
number_reservation = client.number_reservations.retrieve(
    "number_reservation_id",
)
print(number_reservation.data)

Extend a number reservation

延长号码预留有效期

Extends reservation expiry time on all phone numbers.
POST /number_reservations/{number_reservation_id}/actions/extend
python
response = client.number_reservations.actions.extend(
    "number_reservation_id",
)
print(response.data)
延长所有电话号码的预留到期时间。
POST /number_reservations/{number_reservation_id}/actions/extend
python
response = client.number_reservations.actions.extend(
    "number_reservation_id",
)
print(response.data)

List number orders

列出号码订单

Get a paginated list of number orders.
GET /number_orders
python
page = client.number_orders.list()
page = page.data[0]
print(page.id)
获取电话号码订单的分页列表。
GET /number_orders
python
page = client.number_orders.list()
page = page.data[0]
print(page.id)

Create a number order

创建号码订单

Creates a phone number order.
POST /number_orders
python
number_order = client.number_orders.create()
print(number_order.data)
创建电话号码订单。
POST /number_orders
python
number_order = client.number_orders.create()
print(number_order.data)

Retrieve a number order

查询单个号码订单

Get an existing phone number order.
GET /number_orders/{number_order_id}
python
number_order = client.number_orders.retrieve(
    "number_order_id",
)
print(number_order.data)
获取已有的电话号码订单。
GET /number_orders/{number_order_id}
python
number_order = client.number_orders.retrieve(
    "number_order_id",
)
print(number_order.data)

Update a number order

更新号码订单

Updates a phone number order.
PATCH /number_orders/{number_order_id}
python
number_order = client.number_orders.update(
    number_order_id="number_order_id",
)
print(number_order.data)
更新电话号码订单信息。
PATCH /number_orders/{number_order_id}
python
number_order = client.number_orders.update(
    number_order_id="number_order_id",
)
print(number_order.data)

List number block orders

列出号码批量订单

Get a paginated list of number block orders.
GET /number_block_orders
python
page = client.number_block_orders.list()
page = page.data[0]
print(page.id)
获取电话号码批量订单的分页列表。
GET /number_block_orders
python
page = client.number_block_orders.list()
page = page.data[0]
print(page.id)

Create a number block order

创建号码批量订单

Creates a phone number block order.
POST /number_block_orders
— Required:
starting_number
,
range
python
number_block_order = client.number_block_orders.create(
    range=10,
    starting_number="+19705555000",
)
print(number_block_order.data)
创建电话号码批量订单。
POST /number_block_orders
— 必填参数:
starting_number
,
range
python
number_block_order = client.number_block_orders.create(
    range=10,
    starting_number="+19705555000",
)
print(number_block_order.data)

Retrieve a number block order

查询单个号码批量订单

Get an existing phone number block order.
GET /number_block_orders/{number_block_order_id}
python
number_block_order = client.number_block_orders.retrieve(
    "number_block_order_id",
)
print(number_block_order.data)
获取已有的电话号码批量订单。
GET /number_block_orders/{number_block_order_id}
python
number_block_order = client.number_block_orders.retrieve(
    "number_block_order_id",
)
print(number_block_order.data)

Retrieve a list of phone numbers associated to orders

查询与订单关联的电话号码列表

Get a list of phone numbers associated to orders.
GET /number_order_phone_numbers
python
number_order_phone_numbers = client.number_order_phone_numbers.list()
print(number_order_phone_numbers.data)
获取与订单关联的电话号码列表。
GET /number_order_phone_numbers
python
number_order_phone_numbers = client.number_order_phone_numbers.list()
print(number_order_phone_numbers.data)

Update requirement group for a phone number order

更新电话号码订单的需求组

POST /number_order_phone_numbers/{id}/requirement_group
— Required:
requirement_group_id
python
response = client.number_order_phone_numbers.update_requirement_group(
    id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    requirement_group_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.data)
POST /number_order_phone_numbers/{id}/requirement_group
— 必填参数:
requirement_group_id
python
response = client.number_order_phone_numbers.update_requirement_group(
    id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    requirement_group_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.data)

Retrieve a single phone number within a number order.

查询号码订单中的单个电话号码

Get an existing phone number in number order.
GET /number_order_phone_numbers/{number_order_phone_number_id}
python
number_order_phone_number = client.number_order_phone_numbers.retrieve(
    "number_order_phone_number_id",
)
print(number_order_phone_number.data)
获取号码订单中已有的单个电话号码。
GET /number_order_phone_numbers/{number_order_phone_number_id}
python
number_order_phone_number = client.number_order_phone_numbers.retrieve(
    "number_order_phone_number_id",
)
print(number_order_phone_number.data)

Update requirements for a single phone number within a number order.

更新号码订单中单个电话号码的需求

Updates requirements for a single phone number within a number order.
PATCH /number_order_phone_numbers/{number_order_phone_number_id}
python
response = client.number_order_phone_numbers.update_requirements(
    number_order_phone_number_id="number_order_phone_number_id",
)
print(response.data)
更新号码订单中单个电话号码的需求信息。
PATCH /number_order_phone_numbers/{number_order_phone_number_id}
python
response = client.number_order_phone_numbers.update_requirements(
    number_order_phone_number_id="number_order_phone_number_id",
)
print(response.data)

List sub number orders

列出子号码订单

Get a paginated list of sub number orders.
GET /sub_number_orders
python
sub_number_orders = client.sub_number_orders.list()
print(sub_number_orders.data)
获取子号码订单的分页列表。
GET /sub_number_orders
python
sub_number_orders = client.sub_number_orders.list()
print(sub_number_orders.data)

Update requirement group for a sub number order

更新子号码订单的需求组

POST /sub_number_orders/{id}/requirement_group
— Required:
requirement_group_id
python
response = client.sub_number_orders.update_requirement_group(
    id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    requirement_group_id="a4b201f9-8646-4e54-a7d2-b2e403eeaf8c",
)
print(response.data)
POST /sub_number_orders/{id}/requirement_group
— 必填参数:
requirement_group_id
python
response = client.sub_number_orders.update_requirement_group(
    id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    requirement_group_id="a4b201f9-8646-4e54-a7d2-b2e403eeaf8c",
)
print(response.data)

Retrieve a sub number order

查询单个子号码订单

Get an existing sub number order.
GET /sub_number_orders/{sub_number_order_id}
python
sub_number_order = client.sub_number_orders.retrieve(
    sub_number_order_id="sub_number_order_id",
)
print(sub_number_order.data)
获取已有的子号码订单。
GET /sub_number_orders/{sub_number_order_id}
python
sub_number_order = client.sub_number_orders.retrieve(
    sub_number_order_id="sub_number_order_id",
)
print(sub_number_order.data)

Update a sub number order's requirements

更新子号码订单的需求

Updates a sub number order.
PATCH /sub_number_orders/{sub_number_order_id}
python
sub_number_order = client.sub_number_orders.update(
    sub_number_order_id="sub_number_order_id",
)
print(sub_number_order.data)
更新子号码订单信息。
PATCH /sub_number_orders/{sub_number_order_id}
python
sub_number_order = client.sub_number_orders.update(
    sub_number_order_id="sub_number_order_id",
)
print(sub_number_order.data)

Cancel a sub number order

取消子号码订单

Allows you to cancel a sub number order in 'pending' status.
PATCH /sub_number_orders/{sub_number_order_id}/cancel
python
response = client.sub_number_orders.cancel(
    "sub_number_order_id",
)
print(response.data)
可取消状态为“pending”(待处理)的子号码订单。
PATCH /sub_number_orders/{sub_number_order_id}/cancel
python
response = client.sub_number_orders.cancel(
    "sub_number_order_id",
)
print(response.data)

Create a sub number orders report

创建子号码订单报告

Create a CSV report for sub number orders.
POST /sub_number_orders/report
python
sub_number_orders_report = client.sub_number_orders_report.create()
print(sub_number_orders_report.data)
创建子号码订单的CSV报告。
POST /sub_number_orders/report
python
sub_number_orders_report = client.sub_number_orders_report.create()
print(sub_number_orders_report.data)

Retrieve a sub number orders report

查询子号码订单报告

Get the status and details of a sub number orders report.
GET /sub_number_orders/report/{report_id}
python
sub_number_orders_report = client.sub_number_orders_report.retrieve(
    "12ade33a-21c0-473b-b055-b3c836e1c293",
)
print(sub_number_orders_report.data)
获取子号码订单报告的状态和详情。
GET /sub_number_orders/report/{report_id}
python
sub_number_orders_report = client.sub_number_orders_report.retrieve(
    "12ade33a-21c0-473b-b055-b3c836e1c293",
)
print(sub_number_orders_report.data)

Download a sub number orders report

下载子号码订单报告

Download the CSV file for a completed sub number orders report.
GET /sub_number_orders/report/{report_id}/download
python
response = client.sub_number_orders_report.download(
    "12ade33a-21c0-473b-b055-b3c836e1c293",
)
print(response)
下载已完成的子号码订单报告的CSV文件。
GET /sub_number_orders/report/{report_id}/download
python
response = client.sub_number_orders_report.download(
    "12ade33a-21c0-473b-b055-b3c836e1c293",
)
print(response)

List Advanced Orders

列出高级订单

GET /advanced_orders
python
advanced_orders = client.advanced_orders.list()
print(advanced_orders.data)
GET /advanced_orders
python
advanced_orders = client.advanced_orders.list()
print(advanced_orders.data)

Create Advanced Order

创建高级订单

POST /advanced_orders
python
advanced_order = client.advanced_orders.create()
print(advanced_order.id)
POST /advanced_orders
python
advanced_order = client.advanced_orders.create()
print(advanced_order.id)

Update Advanced Order

更新高级订单

PATCH /advanced_orders/{advanced-order-id}/requirement_group
python
response = client.advanced_orders.update_requirement_group(
    advanced_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.id)
PATCH /advanced_orders/{advanced-order-id}/requirement_group
python
response = client.advanced_orders.update_requirement_group(
    advanced_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.id)

Get Advanced Order

查询单个高级订单

GET /advanced_orders/{order_id}
python
advanced_order = client.advanced_orders.retrieve(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(advanced_order.id)
GET /advanced_orders/{order_id}
python
advanced_order = client.advanced_orders.retrieve(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(advanced_order.id)

List inexplicit number orders

列出非明确号码订单

Get a paginated list of inexplicit number orders.
GET /inexplicit_number_orders
python
page = client.inexplicit_number_orders.list()
page = page.data[0]
print(page.id)
获取非明确号码订单的分页列表。
GET /inexplicit_number_orders
python
page = client.inexplicit_number_orders.list()
page = page.data[0]
print(page.id)

Create an inexplicit number order

创建非明确号码订单

Create an inexplicit number order to programmatically purchase phone numbers without specifying exact numbers.
POST /inexplicit_number_orders
— Required:
ordering_groups
python
inexplicit_number_order = client.inexplicit_number_orders.create(
    ordering_groups=[{
        "count_requested": "count_requested",
        "country_iso": "US",
        "phone_number_type": "phone_number_type",
    }],
)
print(inexplicit_number_order.data)
创建非明确号码订单,无需指定具体号码即可程序化购买电话号码。
POST /inexplicit_number_orders
— 必填参数:
ordering_groups
python
inexplicit_number_order = client.inexplicit_number_orders.create(
    ordering_groups=[{
        "count_requested": "count_requested",
        "country_iso": "US",
        "phone_number_type": "phone_number_type",
    }],
)
print(inexplicit_number_order.data)

Retrieve an inexplicit number order

查询单个非明确号码订单

Get an existing inexplicit number order by ID.
GET /inexplicit_number_orders/{id}
python
inexplicit_number_order = client.inexplicit_number_orders.retrieve(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(inexplicit_number_order.data)
通过ID获取已有的非明确号码订单。
GET /inexplicit_number_orders/{id}
python
inexplicit_number_order = client.inexplicit_number_orders.retrieve(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(inexplicit_number_order.data)

Retrieve all comments

列出所有评论

GET /comments
python
comments = client.comments.list()
print(comments.data)
GET /comments
python
comments = client.comments.list()
print(comments.data)

Create a comment

创建评论

POST /comments
python
comment = client.comments.create()
print(comment.data)
POST /comments
python
comment = client.comments.create()
print(comment.data)

Retrieve a comment

查询单个评论

GET /comments/{id}
python
comment = client.comments.retrieve(
    "id",
)
print(comment.data)
GET /comments/{id}
python
comment = client.comments.retrieve(
    "id",
)
print(comment.data)

Mark a comment as read

将评论标记为已读

PATCH /comments/{id}/read
python
response = client.comments.mark_as_read(
    "id",
)
print(response.data)
PATCH /comments/{id}/read
python
response = client.comments.mark_as_read(
    "id",
)
print(response.data)

List available phone number blocks

列出可用电话号码批量段

GET /available_phone_number_blocks
python
available_phone_number_blocks = client.available_phone_number_blocks.list()
print(available_phone_number_blocks.data)
GET /available_phone_number_blocks
python
available_phone_number_blocks = client.available_phone_number_blocks.list()
print(available_phone_number_blocks.data)

List available phone numbers

列出可用电话号码

GET /available_phone_numbers
python
available_phone_numbers = client.available_phone_numbers.list()
print(available_phone_numbers.data)
GET /available_phone_numbers
python
available_phone_numbers = client.available_phone_numbers.list()
print(available_phone_numbers.data)

Retrieve the features for a list of numbers

查询号码列表的功能

POST /numbers_features
— Required:
phone_numbers
python
numbers_feature = client.numbers_features.create(
    phone_numbers=["string"],
)
print(numbers_feature.data)

POST /numbers_features
— 必填参数:
phone_numbers
python
numbers_feature = client.numbers_features.create(
    phone_numbers=["string"],
)
print(numbers_feature.data)

Webhooks

Webhooks

The following webhook events are sent to your configured webhook URL. All webhooks include
telnyx-timestamp
and
telnyx-signature-ed25519
headers for verification (Standard Webhooks compatible).
EventDescription
numberOrderStatusUpdate
Number Order Status Update
以下Webhook事件将发送至您配置的Webhook URL。 所有Webhook均包含
telnyx-timestamp
telnyx-signature-ed25519
头信息用于验证(兼容标准Webhooks)。
事件描述
numberOrderStatusUpdate
电话号码订单状态更新