Dokumentacja dla deweloperów

Shortcuts i x-callback-url

Automatyzuj sprawdzanie przepustowości, walidację punktów końcowych i zbieranie wyników za pomocą wbudowanych akcji i punktów końcowych wywołań zwrotnych.

Przegląd

iPerf3 Client & Server udostępnia dwie warstwy automatyzacji:

  • Natywne akcje Apple Shortcuts (zalecane dla większości użytkowników)
  • Punkty końcowe x-callback-url dla skryptowalnych przepływów pracy między aplikacjami
Podstawowy schemat URL

Używaj iperf3cs://x-callback-url/... dla automatyzacji opartej na wywołaniach zwrotnych.

Zgodność

Aktualne wymagania platformy Apple to iOS/iPadOS 16.6+, macOS 13.5+ i visionOS 1.0+.

Wbudowane akcje Shortcuts

Te akcje są dostępne bezpośrednio w aplikacji Apple Shortcuts:

Uruchom test iPerf

Uruchamia test z konfigurowalnym serwerem, protokołem, kierunkiem i czasem. Typowy domyślny czas trwania w przepływie shortcuts wynosi 5 sekund.

Pobierz ostatni wynik

Zwraca najnowszy ukończony wynik z lokalnej historii.

Sprawdź serwer

Sprawdza dostępność punktu końcowego przed pełnym uruchomieniem.

Lista serwerów

Zwraca skonfigurowane serwery dla automatyzacji sterowanej menu.

Punkty końcowe x-callback-url

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

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

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

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

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

Parametr Typ Wymagany Opis
serverId String Nie Limit the lookup to one server: host:port, a UUID, or default. Omit it for the latest result overall.
serverName String Nie Same lookup by saved name. Takes precedence over serverId.
format String Nie json (default) or text.
x-success String Nie Callback URL. Receives result with the payload, or resultRef when the payload is too large to pass in a URL.
x-error String Nie Callback URL. Receives errorCode and errorMessage.
x-cancel String Nie 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.

Parametr Typ Wymagany Opis
resultRef String Tak Reference returned earlier in place of result.
format String Nie json (default) or text.
x-success String Nie Callback URL. Receives result with the payload, or resultRef when the payload is too large to pass in a URL.
x-error String Nie Callback URL. Receives errorCode and errorMessage.
x-cancel String Nie Callback URL for a cancelled run.

Przykłady

Uruchom test z wywołaniami zwrotnymi

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

Odczytaj najnowszy wynik

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

Uruchomienie z terminala na macOS

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

Typowe pola ładunku

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

Obsługa błędów

Gdy akcja zawiedzie i obecny jest x-error, wywołanie zwrotne otrzymuje obiekt błędu.

Kod Opis
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

Dlaczego moje wywołanie zwrotne nie wraca do Shortcuts?

Upewnij się, że adresy URL wywołania zwrotnego są zakodowane w URL, a schemat jest dozwolony na Twoim urządzeniu. Unikaj spacji lub niezakodowanych znaków specjalnych w wartościach zapytań.

Czy testy mogą działać całkowicie w tle?

Dla niezawodnego działania utrzymuj aplikację aktywną podczas trwania testu. Używaj planowania Shortcuts, aby wyzwalać uruchomienia o określonych porach.

Jaki jest najbezpieczniejszy wzorzec integracji?

Ustaw x-error przy każdym wywołaniu i rozgałęziaj po errorCode. Zacznij od krótkiego przebiegu durationSec=5: jeśli wróci serverNotFound lub connectionTimeout, długi test nie ma sensu.