move API parsing to its own class