HTTP API /v1/events /v1/snapshots

I downloaded the dev version, run it and start playing with the REST API. I tried getting some events out by GET /v1/events but the request is just hanging and never returning. I can see that I successfully sent some events via the API with POST but they do not get back. The swagger documentation is also a bit confusing as it doesn’t give any context about authentication and some of the operations are not at all documented - example would be sending the events, where should I put the events metadata.

I’m btw talking about AxonDB

Hi Daniel,

Great to hear you’re giving AxonDB a spin!

Answering your questions:

  • When reading events through the HTTP API, AxonDB returns a stream. Unfortunately, Swagger UI doesn’t deal with that well. It waits for the response to complete, which never happens, so you don’t see anything. If you would for instance use HTTPie from the command line you could do something like “http -S --timeout 3600 :8023/v1/events” and you would see new events come in.
  • Authentication is disabled by default, but Swagger UI wants to have an authentication token set. You can put a random character there until you enable authentication through the properties.
  • To post one or more new events you could do something like this (and yes, that is poorly documented):
    {
    “messages”: [
    {
    “aggregateId”:“00005”,
    “aggregateSequenceNumber”:0,
    “aggregateType”:“MyEvent”,
    “payload”: {
    “type”: “io.axoniq.simpleperftest.MyEvent”,
    “revision”:"",
    “data”:"<io.axoniq.simpleperftest.MyEvent/>"
    },
    “timestamp”:1531341962631
    }
    ]
    }

I didn’t manage to successfully post metadata this way; I’ll discuss tomorrow with the devs and try to find out.

Now, there’s also a background as to why this doesn’t work as smoothly as it might: the HTTP/JSON API is not the primary way to exchange data with AxonDB, it’s mainly there for testing/experimenting purposes. The core data interface is the much faster gRPC interface (Protobuf + HTTP2). This is the interface exploited by the open source client (https://github.com/AxonIQ/axoniq-eventstore-client, https://mvnrepository.com/artifact/io.axoniq/axondb-client). It can be used with or without Axon Framework, but in any case will give you a clean Java API on AxonDB operations. I highly recommend using this interface for your applications.

Hope this is useful,

Hello Frans,

Thank you for the quick response at this late time :slight_smile: I work for a company in Eindhoven, NL called Studyportals. Right now we are trying out DDD and along with it CQRS and event sourcing. We have been looking for an event store that would support our use cases and like in the video in the product description, all the options had the problems that you already mentioned. So seeing AxonDB was a nice moment. Unfortunately we are not using Java but mostly Typescript and Python. Having a REST API would allow us to integrate without the requirement of using Java (another reason we are not using kafka). We also were looking into a custom solution using Amazon Web Services and trying to outsource as many responsibilities for them so we can just use the event store as a service - that is the ultimate goal. Until then we are a bit limited by the language we are using so a HTTP API would be very easy to use. I don’t have much experience with gRPC with node but maybe I can give it a try. I also tried creating new events with some metadata but as you I also didn’t manage to see it in the quick search.

Kind Regards,
Daniel Papukchiev

Hi Daniel,

I checked with the development team. Sending metadata over the HTTP/JSON interface doesn’t work right now - it should, but some code is missing. We’ll put that on our backlog.

It does work well on the gRPC interface of course. I haven’t tried using this from node myself, but should be possible. Some pointers:

  • Our db client repository has two projects. One is the actual Java client (which you wouldn’t use), the other is the project containing only the gRPC proto files. These are the ones that you would need for code generation from node.
  • You have probably already found the node/grpc guide
  • The logic you’ll find in our Java client has largely to do with clustering. This uses platform_api.proto. It will help find out which node is the master. The actual data transfer is over eventstore_api.proto. In a non-clustered environment, you could just use the latter and forget about platform_api.proto.
  • Our development team has run some experiments with accessing our AxonHub messaging platform via Node and gRPC. I’m attaching their notes. This is for Hub and not DB, and it’s somewhat outdated, but it still may give a useful overview.

Kind regards,

AxonHub from Node.md (3.71 KB)