best way to use Relative API Url in a jquery Plugin

Well you could actually have the script find it's own source using jquery. Just make sure to give the js file a unique enough name.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/demux/4d4ce440d7c379305a9a/raw/findfilehosttest.js"></script>

Actual Script:

$(function(){
    var url = $("script[src$='findfilehosttest.js']").attr('src')
    var matches = url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i)
    var domain = matches && matches[1]
    alert(domain)
})

But in general I think it's best to keep it simple. So allow the user to set the URL of the server manually, like so:

<script>
    var MY_API_URL = 'https://instance1.myapiserver.foo'
</script>
<script src="/whateverpath/myapiscript.js"></script>

This would also allow them to host the script on their own server, or even proxy it for what ever reason they might have.