RANK and entities API
Read RANK votes, profiles, posts, entities and discovery entries from a node, check a vote script before you sign it, and what changed with RANK data version 4.
RANK votes are OP_RETURN outputs whose value is burnt: the burn is the weight. The node decodes them, keeps the totals and serves them under /api/v1/social/ and /api/v1/entity/. This page is the guide for programs; the byte formats are in RANK and Entities, the score in RANK score.
Nothing here is consensus: a malformed vote is a valid transaction that is simply not indexed. The answers are never cached by the node, and the module can be off on a node (503 module_disabled).
What changed in 12.5.9 (RANK data version 4) #
| Change | What to do |
|---|---|
Platform 0 is named lotusia (upstream's platform for Lotus addresses), with binary profile ids (a 20-byte key hash or a 33-byte Taproot commitment) and 32-byte post ids, written as lowercase hex | Use lotusia in platform= filters and routes. unknown is still accepted as an alias by the REST filters. Rows of lotusia profiles carry profileAddress, the Lotus address |
Platform 6 is named entity: votes on anything named by a canonical key (wd:Q243, fr-siret:..., dns:example.com) | Use the /entity/ routes below |
The ENTY registry segment publishes the key behind an entity id | See Entities |
Every profile has supportSats, againstSats and a score (score_v1, from burns only) | Show the score next to the net ranking |
New routes: social/decode, social/movers, social/{platform}/{id}/window, social/{platform}/post/{id}/leaders | Below |
| The index is rebuilt from the blocks at the first start of 12.5.9 | A node answers 503 node_warming_up until it is done |
Read votes and profiles #
API=https://givelotus.org/api/v1
curl -s "$API/social/activity?pageSize=20" # newest votes, every platform
curl -s "$API/social/profiles?platform=twitter&pageSize=10" # ranked profiles
curl -s "$API/social/twitter/maxkeiser" # one profile
curl -s "$API/social/twitter/maxkeiser/window?days=30" # daily sums
curl -s "$API/social/movers?period=24h&direction=up" # biggest moves
curl -s "$API/social/tx/075ad48e92089fac330851ecce11ead639dbe6ed4355b5f3c9b6250c6636ea3b"const API = 'https://givelotus.org/api/v1';
// Walk the activity feed by cursor, newest first, up to `max` votes.
async function* votes(max = 500) {
let cursor, n = 0;
do {
const url = `${API}/social/activity?pageSize=100` + (cursor ? `&before=${cursor}` : '');
const page = await (await fetch(url)).json();
for (const v of page.votes) { if (n++ >= max) return; yield v; }
cursor = page.nextCursor;
} while (cursor);
}
for await (const v of votes(200)) console.log(v.platform, v.profileId, v.sentiment, v.sats);{"votes":[{"txid":"075ad48e92089fac330851ecce11ead639dbe6ed4355b5f3c9b6250c6636ea3b","firstSeen":1795720733,
"platform":"twitter","profileId":"caincurrency","sentiment":"positive","sats":1000000,
"postId":"2125619858708795753","source":"native","displayName":""}],
"numPages":2888626,"nextCursor":"1433863:0"}| Route | Use |
|---|---|
GET social/activity | Votes, newest first. platform, excludePlatform, pageSize (max 100), cursor before=<height>:<vout> |
GET social/profiles | Ranked profiles. platform, order=net\|controversy\|score, cursor after= |
GET social/search?q= | Profiles by id or display name |
GET social/{platform}/{profileId} | One profile: ranking, votes, supportSats, againstSats, score. An unknown profile answers 200 with zeros |
GET social/{platform}/{profileId}/posts, /votes, /post/{postId} | Its posts and votes |
GET social/{platform}/{profileId}/window | Daily sums: days (1 to 366), to, post |
GET social/{platform}/post/{postId}/leaders | The profiles inside one post id (entity collections) |
GET social/stats/{profiles\|posts}/{top\|bottom} | Top and bottom 10; period=24h\|7d\|30d\|all |
GET social/movers | Biggest moves of leaderboard position over 24h, 7d or 30d |
GET social/tx/{txid} | The votes and discovery entries of one transaction, and pendingVotes while it is in the mempool |
GET social/block/{height}/summary | Votes of one block |
GET social/discovery/... | Posts named by zero-burn discovery entries; they never change a score |
sentiment is positive or negative; sats is the burn. Use the cursors on deep lists: page numbers count rows.
Check a vote before you sign it #
POST social/decode runs the node's decoders on scripts you have not sent. It tells you whether each output would be indexed, and why not.
curl -s -X POST $API/social/decode -H 'content-type: application/json' \
-d '{"script":"6a0452414e4b51010105616c696365080102030405060708","value":1000000}'{"minBurn":1,"regMinBurn":1000,"ruleset":1,"outputs":[{"index":0,"value":1000000,"transport":"format_a",
"vote":{"platform":"twitter","platformId":1,"profileId":"alice","postId":"72623859790382856","sentiment":"positive"},
"indexed":true,"warnings":[]}]}Send {"outputs": [{"script": ..., "value": ...}, ...]} for a whole transaction (at most 3,000 outputs). An ENTY registration alone needs at least regMinBurn (1,000 sats) unless the same output carries a vote:
{"index":0,"value":0,"transport":"empp","vote":null,"indexed":false,
"regs":[{"valid":true,"key":"wd:Q243","kind":"place","eid":"35wicsrcclf4w33gvcrhn2k64i","indexed":false,"rule":"below_reg_min_burn"}]}minBurn is this node's -rankminburn: a vote below it is not indexed by this node, though it is valid for others.
Entities #
An entity is a RANK profile on platform entity whose id (eid) is derived from a canonical key, so anyone can compute it offline:
import base64, hashlib
d = hashlib.sha256(b"lotus-entity-v1\x00" + b"wd:Q243").digest()
print(base64.b32encode(d[:16]).decode().lower().rstrip("=")) # 35wicsrcclf4w33gvcrhn2k64icurl -s "$API/entity/by-key?key=wd:Q243"
curl -s $API/entity/35wicsrcclf4w33gvcrhn2k64i
curl -s $API/entity/35wicsrcclf4w33gvcrhn2k64i/votes
curl -s $API/entity/35wicsrcclf4w33gvcrhn2k64i/history # ENTY registrations
curl -s "$API/entity/35wicsrcclf4w33gvcrhn2k64i/window?days=30"
curl -s "$API/entity/search?q=eiffel"
curl -s -X POST $API/entity/batch -H 'content-type: application/json' \
-d '{"eids":["35wicsrcclf4w33gvcrhn2k64i"]}'
curl -s $API/entity/ruleset| Field | Meaning |
|---|---|
resolved, key, kind | Whether someone registered the key on chain; key and kind are null until then |
members | The profiles counted for it (a registered localbusiness id with the same SIRET counts too) |
totals | ranking, supportSats, againstSats, votesPositive, votesNegative, votes |
score | score_v1: support, against, pctBp, ... at height |
display | Whether lists show it (listed, reason): an unregistered eid keeps its votes but is left out of lists |
wikidata, factsSource | For wd keys, the Wikidata record the node loaded, and where to correct it. Facts are Wikidata's; no score depends on them |
policy, ruleset, scoreVersion, height | On every answer |
Errors: 400 invalid_eid, invalid_key (with the reason), missing_eids, too_many_eids (more than 100), invalid_json.
Compatibility #
- Apps that read RANK from upstream (Lotusia) nodes: votes use the same formats on both chains; platform 0 is decoded as upstream writes it from 12.5.9.
- A node before 12.5.9 reports platform 6 as
platform_6, refuses Format B and eMPP votes that nameentity, and has no/entity/routes. - Fields are only added: ignore those you do not know.
