Added base-url detection, added API endpoint