Documentação para desenvolvedores

Shortcuts e x-callback-url

Automatize verificações de throughput, validação de endpoints e coleta de resultados com ações integradas e endpoints de callback.

Visão Geral

O iPerf3 Client & Server expõe duas camadas de automação:

  • Ações nativas do Apple Shortcuts (recomendado para a maioria dos usuários)
  • Endpoints x-callback-url para fluxos de trabalho de app para app programáveis
Esquema de URL Base

Use iperf3cs://x-callback-url/... para automação baseada em callback.

Compatibilidade

Os requisitos atuais da plataforma Apple são iOS/iPadOS 16.6+, macOS 13.5+ e visionOS 1.0+.

Ações Integradas de Shortcuts

Essas ações estão disponíveis diretamente no app Apple Shortcuts:

Executar Teste iPerf

Executa um teste com servidor, protocolo, direção e temporização configuráveis. A duração padrão típica no fluxo de Shortcuts é de 5 segundos.

Obter Último Resultado

Retorna o resultado completo mais recente do histórico local.

Testar Servidor

Verifica a disponibilidade do endpoint antes de uma execução completa.

Listar Servidores

Retorna servidores configurados para automação orientada por menu.

Endpoints x-callback-url

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

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

Parâmetro Tipo Obrigatório Descrição
serverId String Não Saved server to use: host:port, a server UUID, or default. Omit it and the default server is used.
serverName String Não Pick the server by its saved name instead of serverId. Takes precedence when both are present.
autoAdd Boolean Não Create the server if it is not in the library yet. addServer is accepted as an alias.
durationSec Integer Não Test length in seconds. Defaults to 5.
protocol String Não tcp (default) or udp.
direction String Não download, upload or bidirectional.
streams Integer Não Parallel stream count.
bandwidthMbps Number Não Target bandwidth for UDP tests, in Mbps.
format String Não json (default) or text.
x-success String Não Callback URL. Receives result with the payload, or resultRef when the payload is too large to pass in a URL.
x-error String Não Callback URL. Receives errorCode and errorMessage.
x-cancel String Não Callback URL for a cancelled run.

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

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

Parâmetro Tipo Obrigatório Descrição
serverId String Não Limit the lookup to one server: host:port, a UUID, or default. Omit it for the latest result overall.
serverName String Não Same lookup by saved name. Takes precedence over serverId.
format String Não json (default) or text.
x-success String Não Callback URL. Receives result with the payload, or resultRef when the payload is too large to pass in a URL.
x-error String Não Callback URL. Receives errorCode and errorMessage.
x-cancel String Não 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.

Parâmetro Tipo Obrigatório Descrição
resultRef String Sim Reference returned earlier in place of result.
format String Não json (default) or text.
x-success String Não Callback URL. Receives result with the payload, or resultRef when the payload is too large to pass in a URL.
x-error String Não Callback URL. Receives errorCode and errorMessage.
x-cancel String Não Callback URL for a cancelled run.

Exemplos

Executar teste com 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

Ler resultado mais recente

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

Iniciar pelo terminal no macOS

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

Campos típicos do payload

{ "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" }

Tratamento de Erros

Quando uma ação falha e x-error está presente, o callback recebe um objeto de erro.

Código Descrição
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

Por que meu callback não retorna para o Shortcuts?

Certifique-se de que as URLs de callback estejam codificadas em URL e que o esquema seja permitido no seu dispositivo. Evite espaços ou símbolos não escapados em valores de consulta.

Os testes podem ser executados completamente em segundo plano?

Para execução confiável, mantenha o app ativo durante o tempo de execução do teste. Use o agendamento do Shortcuts para acionar execuções em horários específicos.

Qual é o padrão de integração mais seguro?

Defina x-error em cada chamada e ramifique por errorCode. Comece com uma execução curta durationSec=5: se voltar serverNotFound ou connectionTimeout, não vale a pena rodar um teste longo.