Cleaned up API usage

Added CURL for API call and moved variables to top for easy implementation.