Is there a direct "hello world" example available for the Augur API? Maybe something that will create a connection and then output My Markets or my Open Orders?

Yes. Essentially, all of the "Simplified API" docs are one big "hello world", in the column on the right.

To install augur.js, follow the README instructions:

mkdir augur-hello-world && cd augur-hello-world
npm install --save-exact augur.js

Then copy the snippet in the "Usage" section:

var Augur = require("augur.js");
var augur = new Augur();

var ethereumNode = { http: "http://127.0.0.1:8545", ws: "ws://127.0.0.1:8546" };
var augurNode = "ws://127.0.0.1:9001";

augur.connect({ ethereumNode, augurNode }, (err, connectionInfo) => {
  // do stuff
});

The commented-out line with "do stuff" is where you copy snippets from the "Simplified API" docs (first link in this answer).


For example, to output your markets, look for something in the docs that in general returns markets, such as

augur.markets.getMarkets(p, callback)

(Sadly, the docs' headers at this sub-level don't have a clickable anchor; you can try this link to get there, but it's not guaranteed to work.)

Among parameters, there's an optional p.creator, which you'd want to set to your account address.

Scrolling a bit down, you'd also see:

augur.markets.getMarketsCreatedByUser(p, callback)

This, I assume, is a convenience wrapper around augur.markets.getMarkets(...) above.

Anyway, once you find the method you want, look at the example code on the right. Copy-paste the snippet where // do stuff is.

For example, if you went with augur.markets.getMarketsCreatedByUser(...), the snippet you'd copy would be:

augur.markets.getMarketsCreatedByUser({
  universe: "0x000000000000000000000000000000000000000b",
  creator: "0x0000000000000000000000000000000000000b0b",
}, function (error, result) {
  console.log(result);
});

The main-net Universe ATM is 0xe991247b78f937d7b69cfc00f1a487a293557677. The "creator" address is the account address you wish to inspect.


In the name of copy-paste, our SE guide and saviour, here's the complete thing to grab in one fell swoop:

var Augur = require("augur.js");
var augur = new Augur();

var ethereumNode = { http: "http://127.0.0.1:8545", ws: "ws://127.0.0.1:8546" };
var augurNode = "ws://127.0.0.1:9001";

augur.connect({ ethereumNode, augurNode }, (err, connectionInfo) => {
  // do stuff
  augur.markets.getMarketsCreatedByUser({
    universe: "0xe991247b78f937d7b69cfc00f1a487a293557677",
    creator: "0x0000000000000000000000000000000000000b0b",
  }, function (error, result) {
    console.log(result);
  });
});

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.