Документация для разработчиков

Shortcuts и x-callback-url

Автоматизируйте проверки пропускной способности, валидацию endpoints и сбор результатов с помощью встроенных действий и callback-endpoints.

Обзор

iPerf3 Client & Server предоставляет два уровня автоматизации:

  • Нативные действия Apple Shortcuts (рекомендуется для большинства пользователей)
  • Endpoints x-callback-url для сценариев межприложного взаимодействия
Базовая схема URL

Используйте iperf3cs://x-callback-url/... для автоматизации на основе callback.

Совместимость

Текущие требования к платформам Apple: iOS/iPadOS 16.6+, macOS 13.5+, visionOS 1.0+.

Встроенные действия Shortcuts

Эти действия доступны напрямую в приложении Apple Shortcuts:

Запустить тест iPerf

Запускает тест с настраиваемым сервером, протоколом, направлением и таймингом. Типичная длительность по умолчанию: 5 секунд.

Получить последний результат

Возвращает последний завершённый результат из локальной истории.

Проверить сервер

Проверяет доступность endpoint перед полным запуском.

Список серверов

Возвращает настроенные серверы для автоматизации с меню.

Endpoints x-callback-url

GETiperf3cs://x-callback-url/run-test

Runs a test and returns the result through the callback URLs.

Параметр Тип Обязательный Описание
serverId String Нет Saved server to use: host:port, a server UUID, or default. Omit it and the default server is used.
serverName String Нет Pick the server by its saved name instead of serverId. Takes precedence when both are present.
autoAdd Boolean Нет Create the server if it is not in the library yet. addServer is accepted as an alias.
durationSec Integer Нет Test length in seconds. Defaults to 5.
protocol String Нет tcp (default) or udp.
direction String Нет download, upload or bidirectional.
streams Integer Нет Parallel stream count.
bandwidthMbps Number Нет Target bandwidth for UDP tests, in Mbps.
format String Нет json (default) or text.
x-success String Нет Callback URL. Receives result with the payload, or resultRef when the payload is too large to pass in a URL.
x-error String Нет Callback URL. Receives errorCode and errorMessage.
x-cancel String Нет Callback URL for a cancelled run.

GETiperf3cs://x-callback-url/get-last-result

Returns the most recent saved result. Useful for periodic logging.

Параметр Тип Обязательный Описание
serverId String Нет Limit the lookup to one server: host:port, a UUID, or default. Omit it for the latest result overall.
serverName String Нет Same lookup by saved name. Takes precedence over serverId.
format String Нет json (default) or text.
x-success String Нет Callback URL. Receives result with the payload, or resultRef when the payload is too large to pass in a URL.
x-error String Нет Callback URL. Receives errorCode and errorMessage.
x-cancel String Нет Callback URL for a cancelled run.

GETiperf3cs://x-callback-url/fetch-result

Fetches a payload the app handed back as a reference. When a result is too large for a callback URL, the app returns <code>resultRef</code> instead of <code>result</code>, and this endpoint exchanges that reference for the full payload.

Параметр Тип Обязательный Описание
resultRef String Да Reference returned earlier in place of result.
format String Нет json (default) or text.
x-success String Нет Callback URL. Receives result with the payload, or resultRef when the payload is too large to pass in a URL.
x-error String Нет Callback URL. Receives errorCode and errorMessage.
x-cancel String Нет Callback URL for a cancelled run.

Примеры

Запуск теста с callbacks

iperf3cs://x-callback-url/run-test?serverId=iperf.example.com:5201&autoAdd=1&protocol=tcp&direction=download&durationSec=8&format=json&x-success=shortcuts://run-shortcut?name=StoreResult

Чтение последнего результата

iperf3cs://x-callback-url/get-last-result?format=json&x-success=shortcuts://run-shortcut?name=PushSummary

Запуск из терминала на macOS

open "iperf3cs://x-callback-url/run-test?serverId=10.0.1.5:5201&protocol=udp&direction=bidirectional&durationSec=5"

Типичные поля ответа

{ "success": true, "startTime": "2026-08-21T09:42:02Z", "endTime": "2026-08-21T09:42:10Z", "duration": 8, "receivedMegabitsPerSecond": 942.7, "sentMegabitsPerSecond": 876.4, "receivedBytes": 942700000, "summaryText": "942.7 Mbps down, 876.4 Mbps up" }

Обработка ошибок

Когда действие завершается неудачно и присутствует x-error, callback получает объект ошибки.

Код Описание
invalidParameter A parameter is missing, malformed or out of range.
serverNotFound No saved server matched the lookup, and autoAdd was not set.
networkUnavailable The device has no usable network path to the endpoint.
connectionTimeout The connection or the test exceeded its timeout.
testFailed The test started and ended without a usable result.
cancelled The run was cancelled before it finished.
requiresAppOpen The action needs the app in the foreground.
unsupportedOnOSVersion The action is not available on this OS version.
{ "errorCode": "serverNotFound", "errorMessage": "No saved server matches iperf.example.com:5201" }

FAQ

Почему мой callback не возвращается в Shortcuts?

Убедитесь, что callback-URL закодированы в URL-формате и схема разрешена на вашем устройстве. Избегайте пробелов и неэкранированных символов в значениях параметров.

Могут ли тесты выполняться полностью в фоне?

Для надёжного выполнения держите приложение активным во время теста. Используйте планировщик Shortcuts для запуска в определённое время.

Какой паттерн интеграции наиболее безопасен?

Указывайте x-error в каждом вызове и ветвитесь по errorCode. Начинайте с короткого прогона durationSec=5: если вернулся serverNotFound или connectionTimeout, длинный тест запускать незачем.