scripts: Support both python2 and python3 for api.py

Since Python3 basestring has been removed. Therefor to use isinstance
it needs to pass str instead of basestring.

Signed-off-by: Masami Ichikawa <masami256@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>