script for finding closest apis match