Search code examples
graph-databasesarangodbfoxx

ArangoDB: Create a new Foxx service via API


A core requirement of my application is the ability to automatically deploy ArangoDB with all collections, graphs, data, and APIs. The HTTP API and the various wrappers have been sufficient for this so far, but I haven't been able to find an API for deploying Foxx services. Is there any way to create and deploy a Foxx service via RESTful API or through one of the wrappers? So far, the only way I know to create a Foxx service is through the web interface.

I found this question which leads me to believe it's possible, but I don't know how to specify the Git location of the Foxx service. Could you provide instructions for creating a Foxx service without the web UI and list the possible parameters?


Solution

  • To install a Foxx service via the REST API, you can use the endpoint HTTP PUT /_admin/foxx/install.

    It will require a JSON body to be sent, with attributes named mount and appInfo. mount needs to contain the mountpoint (needs to start with a forward slash). appInfo is the application to be mounted. It can contain the filename as previously returned by the server from the call to /_api/upload, e.g.

    { 
        "appInfo" : "uploads/tmp-30573-2010894858", 
        "mount" : "/my-mount-point" 
    }
    

    install from remote URL

    You can also install a Foxx service from a zip file available via HTTP(S) from an external server. You can include the username and password for HTTP Basic Auth as necessary:

    { 
        "appInfo" : "https://user:[email protected]/my-service.zip", 
        "mount" : "/my-mount-point" 
    }
    

    install from GitHub

    You can also install a Foxx service from a GitHub repository, if the repository is public accessible, e.g.

    { 
        "appInfo" : "git:arangodb-foxx/demo-hello-foxx:master", 
        "mount" : "/my-mount-point" 
    }
    

    Behind the scenes, ArangoDB will translate the request into a regular URL for the zip bundle GitHub provides.

    install from local file system

    You can also install a Foxx service from a zip file or directory on the local filesystem:

    { 
        "appInfo" : "/path/to/foxx-service.zip", 
        "mount" : "/my-mount-point" 
    }
    

    This also works with directory, but ArangoDB will create a temporary zip file for you in this case.