The attached script is an example of using the WAPI to trigger a traffic capture and then download it. It's written in Perl, but used the WAPI and not the PAPI. Rename traffic_capture_to_file.txt to traffic_capture_to_file.pl.
To get help use:
traffic_capture_to_file.pl --help
traffic_capture_to_file.pl --man
Help information also attached in HTML format.
Hope that helps someone,
Jim