Making haxelib api calls

Howdy all,

Does anyone know how you can make remoting calls to haxelib ( without having to use neko / haxelib client? Ive tried things like:

        var cnx = haxe.remoting.HttpAsyncConnection.urlConnect("");["search", "haxeui-core"], function(d) {

And just get a “moved permanently” error - is there any documentation anywhere of a way to acheive this sort of stuff? Reading the haxelib source is making my eyes bleed :smiley:


The moved permanently redirects to which gives me a result, though it still errors.

Having a file with (haxelib/SiteApi.hx at development · HaxeFoundation/haxelib · GitHub)

interface HaxelibApi {
	public function search(word:String):List<{id:Int, name:String}>;


class SiteProxy extends haxe.remoting.Proxy<HaxelibApi> {}

function main() {
	final site = new SiteProxy(haxe.remoting.HttpConnection.urlConnect("").resolve("api"));


Good luck reading the haxelib source, you’ll need it :smiley:

1 Like

Thanks! Im getting this now though:

SiteProxy.hx:3: characters 0-58 : Could not load proxy module HaxelibApi (try using absolute path)

EDIT: any chance you could zip and post your entire project?

Had that error too, I think it ignores imports. Also had an error when trying to have it in the same file, so had to put it in another.

Here’s a full project: GitHub - ibilon/haxelibApi

1 Like

Nice one, thanks Valentin :slight_smile:

It compiles now, but throws this at runtime:

Uncaught TypeError: Cannot read property 'substr' of null
    at Function.HxOverrides.substr

This is under js

EDIT: so i think the issue is that its trying to use a sync http, and under nodejs that isnt a thing (or doesnt seem to be looking at the code):

		#if (js && !nodejs)
			h.async = false;

I tried to use HttpAsyncConnection but dont seem to be getting anywhere

EDIT2: Ok, so i can get it compile by using HttpAsyncConnection and haxe.remoting.AsyncProxy:

class HaxelibApi extends haxe.remoting.AsyncProxy<data.haxelib.SiteApi> {
	public static function connect() {
		return new HaxelibApi(haxe.remoting.HttpAsyncConnection.urlConnect("").resolve("api"));

And changing the call to something like:

            _api = HaxelibApi.connect();
  "haxeui-core", function(list:List<{id:Int, name:String}>) {

however, now i get this at runtime:

haxe_ValueException {message: "Invalid path ''", __previousException: undefined, __nativeException: haxe_ValueException, value: "Invalid path ''"}
message: "Invalid path ''"
value: "Invalid path ''"

FINAL EDIT!!! Ok, so ignore more! :smiley:

I had edited HttpAsyncConnection yesterday to hardcode things… doh! Works fine now… sorry for the spam!

Couple years ago I tried something similar. In case you don’t want to deal with the remoting macros, you can use haxe.Serializer directly and send a request like here:

The reponse starts with ‘hxr’ and the rest can de deserialized:


Yeah, nice one… now i have it working using remoting, i can get payloads etc and have managed to replicate a request in postman that seems to work fine… So as you point out, it would be fairly trivial i think to have it working with just raw http and get rid of the macros + hx3compat lib… thanks for the info, ill certainly likely use yours a starting point if / when i decide to go down that route.