initialize and connect to api