` element from the
187 | DTCP links(those attributes in traditional hypertext links will be preserved) and then signs the content and posts it
188 | to Primas API.
189 |
190 | **For platform applications, the user interface to handle content editing and image uploading should be fully functional
191 | already. The content posting to Primas API is much easier with the help of the SDK, and the posting can be built as an
192 | async operation to avoid blocking:**
193 |
194 | ```js
195 | /**
196 | * Post content with embedded images
197 | */
198 |
199 | var htmlContent = 'The original HTML content.

';
200 |
201 | // Upgrade DTCP links before posting
202 | // This function call might take a long while to complete.
203 | client.Content.upgradeDTCPLinks(htmlContent, function (err, content) {
204 |
205 | // The content will become something like this:
206 | // The original HTML content.

207 |
208 | if (err) {
209 | // handle error
210 | return;
211 | }
212 |
213 | // The content will be processed again
214 | // to remove the `src` and `href` of DTCP links.
215 | // Then the content hash is calculated.
216 | // After that the whole metadata is signed and sent to the API.
217 |
218 | var content = client.Content.create({
219 | title: "",
220 | creator: {
221 | account_id: "",
222 | sub_account_id: "",
223 |
224 | // If the sub account is not registered separated before,
225 | // provide the name here and it will be created automatically.
226 | // sub_account_name: ""
227 | },
228 | abstract: "",
229 | language: "en-US",
230 | category: "",
231 | content: content
232 | })
233 |
234 | content.send(function (err, res) {
235 |
236 | if (err) {
237 | // handle error
238 | return;
239 | }
240 |
241 | // Article ID and DNA will be returned.
242 |
243 | console.log(res.id);
244 | console.log(res.dna);
245 | })
246 | });
247 | ```
248 |
249 | Note that in this case, the `src` and `href` attribute will **NOT** be replaced by the cached version on Primas Node
250 | and the original URL points to the UGC platform will be preserved.
251 |
252 | ### 4. Create a group
253 |
254 | There're different options to customize the group rules when creating the group:
255 |
256 | 1. How member could join the group
257 |
258 | a. Freely join
259 |
260 | b. Apply to join
261 |
262 | c. Pay to join (coming soon)
263 |
264 | 2. How content could be shared in the group
265 |
266 | a. Freely share
267 |
268 | b. Apply to share
269 |
270 | c. Whitelisted member can share
271 |
272 | d. Pay to share (coming soon)
273 |
274 | ```js
275 | /**
276 | * Creat a group
277 | */
278 |
279 | var group = client.Group.create({
280 | title: "",
281 | creator: {
282 | account_id: "",
283 | sub_account_id: "",
284 |
285 | // If the sub account is not registered separated before,
286 | // provide the name here and it will be created automatically.
287 | // sub_account_name: ""
288 | },
289 | avatar: "",
290 | abstract: "",
291 | language: "en-US",
292 | category: "",
293 | extra: {
294 | allow_join: "all", // How member could join the group. "all" or "application".
295 | allow_post: "all" // How content could be shared in the group. "all", "none" or "application".
296 | }
297 | });
298 |
299 | group.send(function (err, res) {
300 | if (err) {
301 | // handle error
302 | return;
303 | }
304 | // group ID and DNA will be returned.
305 |
306 | console.log(res.id);
307 | console.log(res.dna);
308 | })
309 | ```
310 |
311 | ### 5. Join a group
312 |
313 | The joining operation is a little bit different according to the group joining rules. The API is always the same. If the
314 | group requires application before joining, the `application_status` parameter should be set to "pending" in the API call.
315 |
316 | ```js
317 | /**
318 | * Join a group
319 | */
320 |
321 | var group = client.Group.join("", {
322 | title: "",
323 | src_id: "",
324 | dest_id: "",
325 | creator: {
326 | account_id: "",
327 | sub_account_id: "",
328 |
329 | // If the sub account is not registered separated before,
330 | // provide the name here and it will be created automatically.
331 | // sub_account_name: ""
332 | },
333 |
334 | // If the group requires application before joining, the following parameters should be set:
335 | extra: {
336 | application_status: "pending",
337 | application_expire: Date.now() + 24 * 3600 // The application will expire after 24 hours.
338 | }
339 | });
340 |
341 | group.send(function (err, res) {
342 | if (err) {
343 | // handle error
344 | return;
345 | }
346 |
347 | // group member ID and DNA will be returned
348 |
349 | console.log(res.id);
350 | console.log(res.dna);
351 | })
352 | ```
353 |
354 | ### 6. Share content to a group
355 |
356 | The share can be created from content directly, or from another share. There's a field named `share_id` in the `extra`
357 | field of a share to trace where this share came from. If the share is from the content directly, `share_id` in `extra`
358 | will be null.
359 |
360 | If the group requires application before sharing, set the `application_status` field.
361 |
362 | ```js
363 | /**
364 | * Share to a group
365 | */
366 |
367 | // Group requires application
368 | var group = client.Group.createShare("", {
369 | src_id: "",
370 | dest_id: "",
371 | creator: {
372 | account_id: "",
373 | sub_account_id: "",
374 |
375 | // If the sub account is not registered separated before,
376 | // provide the name here and it will be created automatically.
377 | // sub_account_name: ""
378 | },
379 |
380 |
381 | extra: {
382 | // If the share is created from another share, the following parameters should be set:
383 | share_id: "",
384 |
385 | // If the group requires application to share, the following parameters should be set:
386 | application_status: "pending",
387 | application_expire: Date.now() + 24 * 3600 // The application will expire after 24 hours.
388 | }
389 |
390 | });
391 | group.send(function (err, res) {
392 | if (err) {
393 | // handle error
394 | return;
395 | }
396 |
397 | // Share ID and DNA will be returned
398 |
399 | console.log(res.id);
400 | console.log(res.dna);
401 | })
402 | ```
403 |
404 | ### 7. Discuss about the content
405 |
406 | More precisely, it is discussing about the **shares** rather than the content, since content cannot be seen or liked
407 | or commented until it is shared to a group. So the discussion happens on the share in the group. And the discussion is
408 | only visible in the group.
409 |
410 | ```js
411 | /**
412 | * Like a share
413 | */
414 |
415 | var ci = client.ContentInteraction.createLike("", {
416 | src_id: "",
417 | dest_id: "",
418 | creator: {
419 | account_id: "",
420 | sub_account_id: "",
421 |
422 | // If the sub account is not registered separated before,
423 | // provide the name here and it will be created automatically.
424 | // sub_account_name: ""
425 | }
426 | });
427 | ci.send(function (err, res) {
428 | if (err) {
429 | // handle error
430 | return;
431 | }
432 | // handle res
433 | })
434 |
435 | /**
436 | * Comment on a share
437 | */
438 |
439 | var ci = client.ContentInteraction.createComment("", {
440 | src_id: "",
441 | dest_id: "",
442 | creator: {
443 | account_id: "",
444 | sub_account_id: "",
445 |
446 | // If the sub account is not registered separated before,
447 | // provide the name here and it will be created automatically.
448 | // sub_account_name: ""
449 | },
450 | extra: {
451 | parent_comment_id: "", // If this comment is a reply to another comment, the comment id should be set.
452 | content: "" // HTML format comment content, DTCP links still need to be upgraded.
453 | }
454 | });
455 | ci.send(function (err, res) {
456 | if (err) {
457 | // handle error
458 | return;
459 | }
460 | // Comment ID and DNA is returned
461 |
462 | console.log(res.id);
463 | console.log(res.dna);
464 | })
465 | ```
466 |
--------------------------------------------------------------------------------
/group.md:
--------------------------------------------------------------------------------
1 | # Primas Node API Documentation
2 |
3 | ## Group APIs
4 |
5 | ### 1. Get group metadata
6 |
7 | [GET] /groups/{group_id}
8 |
9 | #### Query parameters
10 |
11 | | Name | Type | Optional | Description |
12 | | ------------------ | -------- | -------- | --------------------------------------------------- |
13 | | account_id | string | y | Account id. Account related status will be returned.|
14 |
15 | #### Response
16 |
17 | | Name | Type | Optional | Description |
18 | | -------------- | ------- | -------- | ---------------------------------------- |
19 | | id | string | n | Group id. |
20 | | title | string | n | Group title. |
21 | | creator | object | n | Creator. |
22 | | avatar | string | n | An image id used for avatar. |
23 | | abstract | string | n | Group introduction. |
24 | | language | string | n | Group language. [RFC4646](http://www.ietf.org/rfc/rfc4646.txt) defined locales such as "en-US" |
25 | | category | string | n | Group categories. Comma separated words list. |
26 | | created | integer | n | Group creation time. Unix timestamp. |
27 | | updated | integer | n | Group last updating time. Unix timestamp. |
28 | | extra | object | n | Extra metadata. |
29 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
30 | | dna | string | n | Group DNA. |
31 | | transaction_id | string | n | Latest transaction id. |
32 |
33 | `creator` object:
34 |
35 | | Name | Type | Optional | Description |
36 | | -------------- | ------- | -------- | ---------------------------------------- |
37 | | account_id | string | n | Root account id. |
38 | | account_name | string | n | Root account name. |
39 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
40 | | sub_account_name | string | y | Sub account name. |
41 |
42 | `extra` object:
43 |
44 | | Name | Type | Optional | Description |
45 | | -------------- | ------- | -------- | ---------------------------------------- |
46 | | allow_join | string | n | Joining group control. "all" or "application". |
47 | | allow_post | string | n | Posting control. "all", "none", "application". |
48 | | members_total | integer | n | Total members number. |
49 | | shares_total | integer | n | Total shares number. |
50 | | account_role | string | y | Member status of current account. "owner", "member", "applicant" or "none". |
51 | | members | array | n | Members overview. An array of [account metadata](./account.md#1-get-account-metadata). |
52 |
53 |
54 | ### 2. Create group
55 |
56 | [POST] /groups
57 |
58 | #### Request
59 |
60 | | Name | Type | Optional | Description |
61 | | -------------- | ------- | -------- | ---------------------------------------- |
62 | | version | string | n | DTCP version. Fixed to "1.0". |
63 | | type | string | n | Fixed to "object". |
64 | | tag | string | n | Fixed to "group". |
65 | | title | string | n | Group title. |
66 | | creator | object | n | Creator. |
67 | | avatar | string | y | An image id used for avatar. |
68 | | abstract | string | n | Group introduction. |
69 | | language | string | n | Group language. [RFC4646](http://www.ietf.org/rfc/rfc4646.txt) defined locales such as "en-US" |
70 | | category | string | n | Group categories. Comma separated words list. |
71 | | created | integer | n | Group creation time. Unix timestamp. |
72 | | extra | object | n | Extra metadata. |
73 | | status | string | n | Fixed to "created". |
74 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
75 |
76 | `creator` object:
77 |
78 | | Name | Type | Optional | Description |
79 | | -------------- | ------- | -------- | ---------------------------------------- |
80 | | account_id | string | n | Account id. Root account id in the case of Sub account posting. |
81 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
82 | | sub_account_name | string | y | Sub account name. For fast creation of new sub accounts. |
83 |
84 | `extra` object:
85 |
86 | | Name | Type | Optional | Description |
87 | | -------------- | ------- | -------- | ---------------------------------------- |
88 | | allow_join | string | n | Joining group control. "all" or "application". |
89 | | allow_post | string | n | Posting control. "all", "none", "application". |
90 |
91 | #### Response
92 |
93 | | Name | Type | Optional | Description |
94 | | ------------ | ------------- | ------------ | ------------- |
95 | | id | string | n | The id of the group. |
96 | | dna | string | n | The DNA of the group. |
97 |
98 | #### Example
99 |
100 | ```bash
101 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
102 |
103 | {"result_code":0,"data":{"dna":"", ...}}
104 |
105 | ```
106 |
107 |
108 | ### 3. Update group(designing)
109 |
110 | [PUT] /groups/{group_id}
111 |
112 | For updating, only the changed metadata need to be provided.
113 |
114 | #### Request
115 |
116 | | Name | Type | Optional | Description |
117 | | -------------- | ------- | -------- | ---------------------------------------- |
118 | | version | string | n | DTCP version. Fixed to "1.0". |
119 | | type | string | n | Fixed to "object". |
120 | | tag | string | n | Fixed to "group". |
121 | | parent_dna | string | n | The latest DNA of the group. |
122 | | status | string | n | Fixed to "updated". |
123 | | updated | integer | n | Group update time. Unix timestamp. |
124 | | title | string | y | Group title. |
125 | | avatar | string | y | An image id used for avatar. |
126 | | abstract | string | y | Group introduction. |
127 | | language | string | y | Group language. [RFC4646](http://www.ietf.org/rfc/rfc4646.txt) defined locales such as "en-US" |
128 | | category | string | y | Group categories. Comma separated words list. |
129 | | extra | object | y | Extra metadata. |
130 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
131 |
132 | `extra` object:
133 |
134 | | Name | Type | Optional | Description |
135 | | -------------- | ------- | -------- | ---------------------------------------- |
136 | | allow_join | string | y | Joining group control. "all" or "application". |
137 | | allow_post | string | y | Posting control. "all", "none", "application". |
138 |
139 | #### Response
140 |
141 | | Name | Type | Optional | Description |
142 | | ------------ | ------------- | ------------ | ------------- |
143 | | dna | string | n | The new DNA of the group. |
144 |
145 | #### Example
146 |
147 | ```bash
148 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
149 |
150 | {"result_code":0,"data":{"dna":"", ...}}
151 |
152 | ```
153 |
154 |
155 | ### 4. Dismiss group(designing)
156 |
157 | [DELETE] /groups/{group_id}
158 |
159 | #### Request
160 |
161 | | Name | Type | Optional | Description |
162 | | -------------- | ------- | -------- | ---------------------------------------- |
163 | | version | string | n | DTCP version. Fixed to "1.0". |
164 | | type | string | n | Fixed to "object". |
165 | | tag | string | n | Fixed to "group". |
166 | | parent_dna | string | n | The latest DNA of the group. |
167 | | status | string | n | Fixed to "deleted". |
168 | | updated | integer | n | Group updating time. Unix timestamp. |
169 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
170 |
171 | #### Response
172 |
173 | | Name | Type | Optional | Description |
174 | | ---- | ------ | -------- | ----------- |
175 | | dna | string | n | Group DNA. |
176 |
177 | #### Example
178 |
179 | ```bash
180 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
181 |
182 | {"result_code":0,"data":{"dna":"", ...}}
183 |
184 | ```
185 |
186 |
187 | ### 5. Get group members
188 |
189 | [GET] /groups/{group_id}/members
190 |
191 | #### Query parameters
192 |
193 | | Name | Type | Optional | Description |
194 | | ------------------ | -------- | -------- | --------------------------------------------------- |
195 | | page | integer | y | Page number. Starts from 0. |
196 | | page_size | integer | y | Page size. Default to 20. |
197 | | application_status | string | y | Status filter. "pending", "approved" or "declined". |
198 |
199 | #### Response
200 |
201 | Response `data` is an array whose elements contain:
202 |
203 | | Name | Type | Optional | Description |
204 | | ------------------- | ------- | -------- | ----------- |
205 | | id | string | n | Group member id. |
206 | | src_id | string | n | Account id. Root account id in the case of [Sub account](./dtcp.md#sub-accounts). |
207 | | dest_id | string | n | Group id. |
208 | | creator | object | n | Creator. |
209 | | created | integer | n | Member joining time. Unix timestamp. |
210 | | updated | integer | n | Member updating time. Unix timestamp. |
211 | | extra | object | y | Extra metadata. |
212 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
213 | | dna | string | n | Group member DNA. |
214 | | transaction_id | string | n | Latest transaction id. |
215 | | account | object | n | Related member account. |
216 |
217 | `creator` object:
218 |
219 | | Name | Type | Optional | Description |
220 | | -------------- | ------- | -------- | ---------------------------------------- |
221 | | account_id | string | n | Account id. Root account id in the case of Sub account posting. |
222 | | account_name | string | n | Account name. |
223 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
224 | | sub_account_name | string | y | Sub account name. For fast creation of new sub accounts. |
225 |
226 | `extra` object:
227 |
228 | | Name | Type | Optional | Description |
229 | | -------------- | ------- | -------- | ----------------------------------------------- |
230 | | application_status | string | n | "pending", "approved" or "declined". |
231 |
232 | `account` object:
233 |
234 | | Name | Type | Optional | Description |
235 | | -------------- | ------- | -------- | ---------------------------------------- |
236 | | id | string | n | Account id. |
237 | | address | string | n | Account address. |
238 | | title | string | n | Account name. |
239 | | abstract | string | y | Description. |
240 | | avatar | string | y | An image DNA used for avatar. |
241 | | creator | object | y | Creator. Provided when this account is a [sub account](./dtcp.md#sub-accounts). |
242 | | created | string | n | Account creation time. Unix timestamp. |
243 | | updated | string | n | Account last updating time. Unix timestamp. |
244 | | extra | object | y | Extra metadata. |
245 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
246 | | dna | string | n | DNA of the account. |
247 |
248 | #### Example
249 |
250 | ```bash
251 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
252 |
253 | {"result_code":0,"data":{"dna":"", ...}}
254 |
255 | ```
256 |
257 |
258 | ### 6. Join group
259 |
260 | [POST] /groups/{group_id}/members
261 |
262 | #### Request
263 |
264 | | Name | Type | Optional | Description |
265 | | -------------- | ------- | -------- | ---------------------------------------- |
266 | | version | string | n | DTCP version. Fixed to "1.0". |
267 | | type | string | n | Fixed to "relation". |
268 | | tag | string | n | Fixed to "group_member". |
269 | | src_id | string | n | Account id. Root account id in the case of [Sub account](./dtcp.md#sub-accounts). |
270 | | dest_id | string | n | Group id. |
271 | | creator | object | n | Creator. |
272 | | created | integer | n | Member joining time. Unix timestamp. |
273 | | status | string | n | Fixed to "created". |
274 | | extra | object | y | Extra metadata. |
275 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
276 |
277 | `creator` object:
278 |
279 | | Name | Type | Optional | Description |
280 | | -------------- | ------- | -------- | ---------------------------------------- |
281 | | account_id | string | n | Account id. Root account id in the case of Sub account posting. |
282 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
283 | | sub_account_name | string | y | Sub account name. For fast creation of new sub accounts. |
284 |
285 | `extra` object:
286 |
287 | | Name | Type | Optional | Description |
288 | | -------------- | ------- | -------- | ----------------------------------------------- |
289 | | application_status | string | n | For group requiring application. Fill "pending". |
290 | | application_expire | integer | n | Application expiration time. |
291 |
292 | #### Response
293 |
294 | | Name | Type | Optional | Description |
295 | | ------------ | ------------- | ------------ | ------------- |
296 | | id | string | n | Group member id. |
297 | | dna | string | n | Group member DNA. |
298 |
299 | #### Example
300 |
301 | ```bash
302 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
303 |
304 | {"result_code":0,"data":{"dna":"", ...}}
305 |
306 | ```
307 |
308 |
309 | ### 7. Approve or decline member application
310 |
311 | [PUT] /groups/{group_id}/members/{group_member_id}
312 |
313 | #### Request
314 |
315 | | Name | Type | Optional | Description |
316 | | -------------- | ------- | -------- | ---------------------------------------- |
317 | | version | string | n | DTCP version. Fixed to "1.0". |
318 | | type | string | n | Fixed to "relation". |
319 | | tag | string | n | Fixed to "group_member". |
320 | | parent_dna | string | n | Latest group member DNA. |
321 | | status | string | n | Fixed to "updated". |
322 | | updated | integer | n | Member updating time. Unix timestamp. |
323 | | creator | object | n | Creator. Group owner. |
324 | | extra | object | n | Extra metadata. |
325 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
326 |
327 | `creator` object:
328 |
329 | | Name | Type | Optional | Description |
330 | | -------------- | ------- | -------- | ---------------------------------------- |
331 | | account_id | string | n | Account id. Root account id in the case of Sub account posting. |
332 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
333 |
334 | `extra` object:
335 |
336 | | Name | Type | Optional | Description |
337 | | -------------- | ------- | -------- | ----------------------------------------------- |
338 | | application_status | string | n | "approved" or "declined". |
339 |
340 | #### Response
341 |
342 | | Name | Type | Optional | Description |
343 | | ------------ | ------------- | ------------ | ------------- |
344 | | dna | string | n | Group member DNA. |
345 |
346 | #### Example
347 |
348 | ```bash
349 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
350 |
351 | {"result_code":0,"data":{"dna":"", ...}}
352 |
353 | ```
354 |
355 |
356 | ### 8. Quit group or kick member out
357 |
358 | [DELETE] /groups/{group_id}/members/{group_member_id}
359 |
360 | This API can be used for both quiting group and kicking member out of the group. Use members account to generate
361 | the signature and leave `creator` empty to quit the group and fill in the group owner's info in the `creator` field
362 | to kick member out.
363 |
364 | #### Request
365 |
366 | | Name | Type | Optional | Description |
367 | | -------------- | ------- | -------- | ---------------------------------------- |
368 | | version | string | n | DTCP version. Fixed to "1.0". |
369 | | type | string | n | Fixed to "relation". |
370 | | tag | string | n | Fixed to "group_member". |
371 | | parent_dna | string | n | Latest group member DNA. |
372 | | status | string | n | "deleted". |
373 | | updated | integer | n | Member quiting time. Unix timestamp. |
374 | | creator | object | n | Creator. |
375 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
376 |
377 | `creator` object:
378 |
379 | | Name | Type | Optional | Description |
380 | | -------------- | ------- | -------- | ---------------------------------------- |
381 | | account_id | string | n | Account id. Root account id in the case of Sub account posting. |
382 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
383 |
384 | #### Response
385 |
386 | | Name | Type | Optional | Description |
387 | | ------------ | ------------- | ------------ | ------------- |
388 | | dna | string | n | Group member DNA. |
389 |
390 | #### Example
391 |
392 | ```bash
393 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
394 |
395 | {"result_code":0,"data":{"dna":"", ...}}
396 |
397 | ```
398 |
399 |
400 | ### 9. Get group member whitelist
401 |
402 | [GET] /groups/{group_id}/whitelist/members
403 |
404 | #### Query parameters
405 |
406 | | Name | Type | Optional | Description |
407 | | ------------------ | -------- | -------- | --------------------------------------------------- |
408 | | page | integer | y | Page number. Starts from 0. |
409 | | page_size | integer | y | Page size. Default to 20. |
410 | | application_status | string | y | Status filter. "pending", "approved" or "declined". |
411 |
412 | #### Response
413 |
414 | | Name | Type | Optional | Description |
415 | | -------------- | ------- | -------- | ---------------------------------------- |
416 | | id | string | n | Whitelist id. |
417 | | src_id | string | n | Account id. |
418 | | dest_id | string | n | Group id. |
419 | | creator | object | n | Creator. |
420 | | created | integer | n | Whitelist creating time. Unix timestamp. |
421 | | status | string | n | Fixed to "created". |
422 | | extra | object | n | Extra metadata. |
423 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
424 | | dna | string | n | Latest whitelist DNA. |
425 | | account | object | n | Account metadata. |
426 |
427 | `creator` object:
428 |
429 | | Name | Type | Optional | Description |
430 | | -------------- | ------- | -------- | ---------------------------------------- |
431 | | account_id | string | n | Account id. Root account id in the case of Sub account posting. |
432 | | account_name | string | n | Account name. |
433 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
434 | | sub_account_name | string | y | Sub account name. For fast creation of new sub accounts. |
435 |
436 | `extra` object:
437 |
438 | | Name | Type | Optional | Description |
439 | | -------------- | ------- | -------- | ----------------------------------------------- |
440 | | application_status | string | n | Fixed to "pending". |
441 |
442 | `account` object contains metadata for [account](./account.md#1-get-account-metadata).
443 |
444 | #### Example
445 |
446 | ```bash
447 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
448 |
449 | {"result_code":0,"data":{"dna":"", ...}}
450 |
451 | ```
452 |
453 |
454 | ### 10. Add group member whitelist
455 |
456 | [POST] /groups/{group_id}/whitelist/members
457 |
458 | #### Request
459 |
460 | | Name | Type | Optional | Description |
461 | | -------------- | ------- | -------- | ---------------------------------------- |
462 | | version | string | n | DTCP version. Fixed to "1.0". |
463 | | type | string | n | Fixed to "relation". |
464 | | tag | string | n | Fixed to "group_member_whitelist". |
465 | | src_id | string | n | Account id. |
466 | | dest_id | string | n | Group id. |
467 | | creator | object | n | Creator. |
468 | | created | integer | n | Whitelist creating time. Unix timestamp. |
469 | | status | string | n | Fixed to "created". |
470 | | extra | object | n | Extra metadata. |
471 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
472 |
473 | `creator` object:
474 |
475 | | Name | Type | Optional | Description |
476 | | -------------- | ------- | -------- | ---------------------------------------- |
477 | | account_id | string | n | Account id. Root account id in the case of Sub account posting. |
478 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
479 | | sub_account_name | string | y | Sub account name. For fast creation of new sub accounts. |
480 |
481 | `extra` object:
482 |
483 | | Name | Type | Optional | Description |
484 | | -------------- | ------- | -------- | ----------------------------------------------- |
485 | | application_status | string | n | Fixed to "pending". |
486 |
487 | #### Response
488 |
489 | | Name | Type | Optional | Description |
490 | | ------------ | ------------- | ------------ | ------------- |
491 | | id | string | n | Group member whitelist id. |
492 | | dna | string | n | Group member whitelist DNA. |
493 |
494 | #### Example
495 |
496 | ```bash
497 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
498 |
499 | {"result_code":0,"data":{"dna":"", ...}}
500 |
501 | ```
502 |
503 |
504 | ### 11. Approve or decline group member whitelist
505 |
506 | [PUT] /groups/{group_id}/whitelist/members/{whitelist_id}
507 |
508 | #### Request
509 |
510 | | Name | Type | Optional | Description |
511 | | -------------- | ------- | -------- | ---------------------------------------- |
512 | | version | string | n | DTCP version. Fixed to "1.0". |
513 | | type | string | n | Fixed to "relation". |
514 | | tag | string | n | Fixed to "group_member_whitelist". |
515 | | parent_dna | string | n | Latest whitelist DNA. |
516 | | status | string | n | Fixed to "updated". |
517 | | updated | integer | n | Whitelist updating time. Unix timestamp. |
518 | | creator | object | n | Creator. |
519 | | extra | object | n | Extra metadata. |
520 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
521 |
522 | `creator` object:
523 |
524 | | Name | Type | Optional | Description |
525 | | -------------- | ------- | -------- | ---------------------------------------- |
526 | | account_id | string | n | Account id. Root account id in the case of Sub account posting. |
527 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
528 |
529 | `extra` object:
530 |
531 | | Name | Type | Optional | Description |
532 | | -------------- | ------- | -------- | ----------------------------------------------- |
533 | | application_status | string | n | "approved" or "declined". |
534 |
535 | #### Response
536 |
537 | | Name | Type | Optional | Description |
538 | | ------------ | ------------- | ------------ | ------------- |
539 | | dna | string | n | Group member whitelist DNA. |
540 |
541 | #### Example
542 |
543 | ```bash
544 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
545 |
546 | {"result_code":0,"data":{"dna":"", ...}}
547 |
548 | ```
549 |
550 |
551 | ### 12. Quit group member whitelist
552 |
553 | [DELETE] /groups/{group_id}/whitelist/members/{whitelist_id}
554 |
555 | #### Request
556 |
557 | | Name | Type | Optional | Description |
558 | | -------------- | ------- | -------- | ---------------------------------------- |
559 | | version | string | n | DTCP version. Fixed to "1.0". |
560 | | type | string | n | Fixed to "relation". |
561 | | tag | string | n | Fixed to "group_member_whitelist". |
562 | | parent_dna | string | n | Latest whitelist DNA. |
563 | | status | string | n | Fixed to "deleted". |
564 | | updated | integer | n | Whitelist updating time. Unix timestamp. |
565 | | creator | object | n | Creator. |
566 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
567 |
568 | `creator` object:
569 |
570 | | Name | Type | Optional | Description |
571 | | -------------- | ------- | -------- | ---------------------------------------- |
572 | | account_id | string | n | Account id. Root account id in the case of Sub account posting. |
573 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
574 |
575 | #### Response
576 |
577 | | Name | Type | Optional | Description |
578 | | ------------ | ------------- | ------------ | ------------- |
579 | | dna | string | n | Group member whitelist DNA. |
580 |
581 | #### Example
582 |
583 | ```bash
584 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
585 |
586 | {"result_code":0,"data":{"dna":"", ...}}
587 |
588 | ```
589 |
590 |
591 | ### 13. Get group shares
592 |
593 | [GET] /groups/{group_id}/shares
594 |
595 | #### Query parameters
596 |
597 | | Name | Type | Optional | Description |
598 | | ------------------ | -------- | -------- | --------------------------------------------------- |
599 | | page | integer | y | Page number. Starts from 0. |
600 | | page_size | integer | y | Page size. Default to 20. |
601 | | application_status | string | y | Status filter. "pending", "approved" or "declined". |
602 |
603 | #### Response
604 |
605 | `data` is an array of [shares](./content-interaction.md#1-get-share-metadata).
606 |
607 | #### Example
608 |
609 | ```bash
610 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
611 |
612 | {"result_code":0,"data":{"dna":"", ...}}
613 |
614 | ```
615 |
616 |
617 | ### 14. Share to a group
618 |
619 | [POST] /groups/{group_id}/shares
620 |
621 | #### Request
622 |
623 | | Name | Type | Optional | Description |
624 | | -------------- | ------- | -------- | ---------------------------------------- |
625 | | version | string | n | DTCP version. Fixed to "1.0". |
626 | | type | string | n | Fixed to "relation". |
627 | | tag | string | n | Fixed to "group_share". |
628 | | src_id | string | n | Content id. |
629 | | dest_id | string | n | Group id. |
630 | | hp | integer | n | hp value. Greater than or equal to zero. |
631 | | creator | object | n | Creator. |
632 | | created | integer | n | Share created time. Unix timestamp. |
633 | | status | string | n | Fixed to "created". |
634 | | extra | object | y | Extra metadata. |
635 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
636 |
637 | `creator` object:
638 |
639 | | Name | Type | Optional | Description |
640 | | -------------- | ------- | -------- | ---------------------------------------- |
641 | | account_id | string | n | Account id. Root account id in the case of Sub account posting. |
642 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
643 | | sub_account_name | string | y | Sub account name. For fast creation of new sub accounts. |
644 |
645 | `extra` object:
646 |
647 | | Name | Type | Optional | Description |
648 | | ------------------ | ------- | -------- | ------------------------------------------------ |
649 | | share_id | string | y | Parent share id. |
650 | | application_status | string | y | For group requiring application. Fill "pending". |
651 | | application_expire | integer | y | Application expiration time. |
652 |
653 | #### Response
654 |
655 | | Name | Type | Optional | Description |
656 | | ------- | ------- | -------- | ------------- |
657 | | id | string | n | Share id. |
658 | | dna | string | n | Share DNA. |
659 |
660 | #### Example
661 |
662 | ```bash
663 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
664 |
665 | {"result_code":0,"data":{"dna":"", ...}}
666 |
667 | ```
668 |
669 |
670 | ### 15. Approve or decline share application
671 |
672 | [PUT] /shares/{share_id}
673 |
674 | #### Request
675 |
676 | | Name | Type | Optional | Description |
677 | | -------------- | ------- | -------- | ---------------------------------------- |
678 | | version | string | n | DTCP version. Fixed to "1.0". |
679 | | type | string | n | Fixed to "relation". |
680 | | tag | string | n | Fixed to "group_share". |
681 | | parent_dna | string | n | Latest share DNA. |
682 | | status | string | n | Fixed to "updated". |
683 | | updated | integer | n | Share updated time. Unix timestamp. |
684 | | creator | object | n | Creator. Group owner |
685 | | extra | object | n | Extra metadata. |
686 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
687 |
688 | `creator` object:
689 |
690 | | Name | Type | Optional | Description |
691 | | -------------- | ------- | -------- | ---------------------------------------- |
692 | | account_id | string | n | Account id. Root account id in the case of Sub account posting. |
693 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
694 |
695 | `extra` object:
696 |
697 | | Name | Type | Optional | Description |
698 | | ------------------ | ------- | -------- | ------------------------------------------------ |
699 | | application_status | string | n | "approved" or "declined". |
700 |
701 | #### Response
702 |
703 | | Name | Type | Optional | Description |
704 | | ------- | ------- | -------- | ----------- |
705 | | dna | string | n | Share DNA. |
706 |
707 | #### Example
708 |
709 | ```bash
710 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
711 |
712 | {"result_code":0,"data":{"dna":"", ...}}
713 |
714 | ```
715 |
716 |
717 | ### 16. Delete group share
718 |
719 | [DELETE] /shares/{share_id}
720 |
721 | This API can be called both by group owner or share creator with corresponding creator info and its signature.
722 |
723 | #### Request
724 |
725 | | Name | Type | Optional | Description |
726 | | -------------- | ------- | -------- | ---------------------------------------- |
727 | | version | string | n | DTCP version. Fixed to "1.0". |
728 | | type | string | n | Fixed to "relation". |
729 | | tag | string | n | Fixed to "group_share". |
730 | | parent_dna | string | n | Latest share DNA. |
731 | | status | string | n | Fixed to "deleted". |
732 | | updated | integer | n | Share updated time. Unix timestamp. |
733 | | creator | object | y | Creator. Group owner. |
734 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
735 |
736 | `creator` object:
737 |
738 | | Name | Type | Optional | Description |
739 | | -------------- | ------- | -------- | ---------------------------------------- |
740 | | account_id | string | n | Account id. Root account id in the case of Sub account posting. |
741 | | sub_account_id | string | y | Sub account id. Refer to [Sub account](./dtcp.md#sub-accounts) for details. |
742 |
743 | #### Response
744 |
745 | | Name | Type | Optional | Description |
746 | | ------------ | ------------- | ------------ | ------------- |
747 | | dna | string | n | Share DNA. |
748 |
749 | #### Example
750 |
751 | ```bash
752 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
753 |
754 | {"result_code":0,"data":{"dna":"", ...}}
755 |
756 | ```
757 |
758 |
759 | ### 17. Get group avatar metadata
760 |
761 | [GET] /groups/{group_id}/avatar
762 |
763 | #### Response
764 |
765 | `data` is [content](./content.md#1-get-content-metadata) metadata.
766 |
767 | #### Example
768 |
769 | ```bash
770 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
771 |
772 | {"result_code":0,"data":{"dna":"", ...}}
773 |
774 | ```
775 |
776 |
777 | ### 18. Get group avatar raw image
778 |
779 | [GET] /groups/{group_id}/avatar/raw
780 |
781 | Primas Node can build local cache of raw image for accessing speed. Or redirect the request to
782 | image URI for raw content directly.
783 |
784 | #### Response
785 |
786 | Response is raw image data.
787 |
788 | #### Example
789 |
790 | ```bash
791 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
792 |
793 | {"result_code":0,"data":{"dna":"", ...}}
794 |
795 | ```
796 |
--------------------------------------------------------------------------------
/node.md:
--------------------------------------------------------------------------------
1 | # Primas Node API Documentation
2 |
3 | ## Node APIs
4 |
5 | ### 1. Get node list
6 |
7 | [GET] /nodes
8 |
9 | #### Query parameters
10 |
11 | | Name | Type | Optional | Description |
12 | | ------------------ | -------- | -------- | --------------------------------------------------- |
13 | | page | integer | y | Page number. Starts from 0. |
14 | | page_size | integer | y | Page size. Default to 20. |
15 |
16 | #### Response
17 |
18 | `data` is an array of nodes:
19 |
20 | | Name | Type | Optional | Description |
21 | | -------------- | ------- | -------- | ---------------------------------------- |
22 | | id | string | n | Node id.|
23 | | title | string | n | Node name. |
24 | | created | integer | n | Node creation time. Unix timestamp. |
25 | | updated | integer | n | Node last updating time. Unix timestamp. |
26 | | url | string | n | Node access url. |
27 | | withdrawal_fee | big integer | n | Withdrawal fee charged by node. |
28 | | address_hot | string | n | Node hot address. |
29 | | address_cold | string | n | Node cold address. |
30 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
31 | | transaction_id | string | n | Latest transaction id. |
32 |
33 | #### Example
34 |
35 | ```bash
36 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
37 |
38 | {"result_code":0,"data":{"dna":"", ...}}
39 |
40 | ```
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "primas-api-doc",
3 | "version": "1.0.0",
4 | "description": "Primas Node API Documentation",
5 | "main": "README.md",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "build": "node run toc.js"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/primasio/primas-api-doc.git"
13 | },
14 | "author": "Gan Lu",
15 | "license": "Apache-2.0",
16 | "bugs": {
17 | "url": "https://github.com/primasio/primas-api-doc/issues"
18 | },
19 | "homepage": "https://github.com/primasio/primas-api-doc#readme",
20 | "dependencies": {
21 | "markdown-toc": "^1.2.0"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/query.md:
--------------------------------------------------------------------------------
1 | # Primas Node API Documentation
2 |
3 | ## Query APIs
4 |
5 | ### 1. Query all
6 |
7 | [GET] /query
8 |
9 | #### Query parameters
10 |
11 | | Name | Type | Optional | Description |
12 | | ------------------ | -------- | -------- | -------------------------------------------------------------------- |
13 | | page | integer | y | Page number. Starts from 0. |
14 | | page_size | integer | y | Page size. Default to 20. |
15 | | text | string | y | Text filter. Full text search on title, description, etc. |
16 | | type | string | y | Query type. Currently supports "all", "share", "account", "group". |
17 | | category | string | y | Category filter. |
18 |
19 | #### Response
20 |
21 | `data` is an array containing [groups](./group.md#1-get-group-metadata),
22 | [content](./content.md#1-get-content-metadata), [accounts](./account.md#1-get-account-metadata)
23 | or a mixture of all types.
24 |
25 | #### Example
26 |
27 | ```bash
28 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
29 |
30 | {"result_code":0,"data":{"dna":"", ...}}
31 |
32 | ```
33 | ### 2. Find content using URL or hash
34 |
35 | [GET] /query/content
36 |
37 | #### Query parameters
38 |
39 | | Name | Type | Optional | Description |
40 | | ------------------ | -------- | -------- | -------------------------------------------------------------------- |
41 | | url | string | y | Url encoded url. |
42 | | hash | string | y | Lowercase hex string of the Keccak256 hash of the raw content. |
43 |
44 | #### Response
45 |
46 | `data` is an array of [content](./content.md#1-get-content-metadata).
47 |
48 | #### Example
49 |
50 | ```bash
51 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
52 |
53 | {"result_code":0,"data":{"dna":"", ...}}
54 |
55 | ```
56 |
57 |
58 | ### 3. Find reproductions using URL(designing)
59 |
60 | [GET] /query/reproductions
61 |
62 | #### Query parameters
63 |
64 | | Name | Type | Optional | Description |
65 | | ------------------ | -------- | -------- | -------------------------------------------------------------------- |
66 | | page | integer | y | Page number. Starts from 0. |
67 | | page_size | integer | y | Page size. Default to 20. |
68 | | url | string | n | Url encoded url. |
69 |
70 | #### Response
71 |
72 | `data` is an array of reproductions:
73 |
74 |
75 |
76 | #### Example
77 |
78 | ```bash
79 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
80 |
81 | {"result_code":0,"data":{"dna":"", ...}}
82 |
83 | ```
--------------------------------------------------------------------------------
/system.md:
--------------------------------------------------------------------------------
1 | # Primas Node API Documentation
2 |
3 | ## System APIs
4 |
5 | ### 1. Get system parameters
6 |
7 | [GET] /system
8 |
9 | #### Response
10 |
11 | | Name | Type | Optional | Description |
12 | | ------------------------ | ----------- | -------- | ---------------------------------------- |
13 | | lock_amount_content | big integer | n | Token lock amount for posting content. |
14 | | lock_period_content | integer | n | Token lock period in seconds for posting content. |
15 | | lock_amount_group_join | big integer | n | Token lock amount for joining group. |
16 | | lock_amount_group_create | big integer | n | Token lock amount for creating group.|
17 | | consume_amount_report | big integer | n | Token consumed amount for report share. |
18 |
19 | #### Example
20 |
21 | ```bash
22 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
23 |
24 | {"result_code":0,"data":{"dna":"", ...}}
25 |
26 | ```
27 |
--------------------------------------------------------------------------------
/timeline.md:
--------------------------------------------------------------------------------
1 | # Primas Node API Documentation
2 |
3 | ## Timeline APIs
4 |
5 | ### 1. Get account timeline
6 |
7 | [GET] /accounts/{account_id}/timeline
8 |
9 | Get all the shares in all the groups account has joined.
10 | Notice that **if the same article is shared multiple times
11 | in several adjacent shares, only the first one will show.**
12 |
13 | #### Query parameters
14 |
15 | | Name | Type | Optional | Description |
16 | | ------------------ | -------- | -------- | --------------------------------------------------- |
17 | | page | integer | y | Page number. Starts from 0. |
18 | | page_size | integer | y | Page size. Default to 20. |
19 |
20 | #### Response
21 |
22 | `data` is an array of [shares](./content-interaction.md#1-get-share-metadata):
23 |
24 | #### Example
25 |
26 | ```bash
27 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
28 |
29 | {"result_code":0,"data":{"dna":"", ...}}
30 |
31 | ```
32 |
--------------------------------------------------------------------------------
/toc.js:
--------------------------------------------------------------------------------
1 | var toc = require('markdown-toc');
2 | var fs = require('fs');
3 |
4 | var mdFiles = [
5 | "content.md",
6 | "content-interaction.md",
7 | "group.md",
8 | "account.md",
9 | "token.md",
10 | "timeline.md",
11 | "query.md",
12 | "system.md",
13 | "node.md",
14 | "transaction.md"
15 | ];
16 |
17 | var tocContent = "";
18 |
19 | function processAt(idx) {
20 |
21 | if (idx >= mdFiles.length)
22 | {
23 | finished();
24 | return;
25 | }
26 |
27 | fs.readFile(mdFiles[idx], 'utf8', function(err, data) {
28 | tocContent += toc(data, {
29 | firsth1: false,
30 | maxdepth: 2
31 | }).content + "\n";
32 | processAt(idx + 1);
33 | });
34 | }
35 |
36 | function finished() {
37 | console.log(tocContent);
38 | }
39 |
40 | processAt(0);
41 |
--------------------------------------------------------------------------------
/token.md:
--------------------------------------------------------------------------------
1 | # Primas Node API Documentation
2 |
3 | ## Token APIs
4 |
5 |
6 | ### 1. Get account tokens data
7 |
8 | [GET] /accounts/{account_id}/tokens
9 |
10 | #### Response
11 |
12 | | Name | Type | Optional | Description |
13 | | -------------------- | ----------- | -------- | ------------------------------------- |
14 | | balance | big integer | n | Token balance. |
15 | | pre_lock_all | big integer | n | Total pre-locked amount. |
16 | | pre_lock_available | big integer | n | Remaining pre-locked amount. |
17 | | incentives_all | big integer | n | Total incentives on this node. . |
18 | | incentives_locked | big integer | n | Incentives locked on this node. |
19 | | incentives_on_node | big integer | n | Amount in the node's incentives pool. |
20 |
21 | #### Example
22 |
23 | ```bash
24 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
25 |
26 | {"result_code":0,"data":{"dna":"", ...}}
27 |
28 | ```
29 |
30 |
31 | ### 2. Get incentives list
32 |
33 | [GET] /accounts/{account_id}/tokens/incentives
34 |
35 | #### Query parameters
36 |
37 | | Name | Type | Optional | Description |
38 | | ----------- | -------- | -------- | --------------------------------- |
39 | | start_date | integer | y | Query start date. Unix timestamp. |
40 | | end_date | integer | y | Query end date. Unix timestamp. |
41 | | page | integer | y | Page number. Starts from 0. |
42 | | page_size | integer | y | Page size. Default to 20. |
43 |
44 | #### Response
45 |
46 | Response `data` is an array whose element containing:
47 |
48 | | Name | Type | Optional | Description |
49 | | ----------------- | ------------- | -------- | ----------------------------------------------------------------- |
50 | | date | string | n | Incentives date. Unix timestamp. |
51 | | from | string | n | "original", "share", "group", "original_like", "original_comment", "original_share". |
52 | | object_id | string | n | Corresponding object id. Such as article_id, group_id, share_id. |
53 | | amount | big integer | n | Incentives amount. |
54 |
55 | #### Example
56 |
57 | ```bash
58 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
59 |
60 | {"result_code":0,"data":{"dna":"", ...}}
61 |
62 | ```
63 |
64 |
65 | ### 3. Get incentives statistics list
66 |
67 | [GET] /accounts/{account_id}/tokens/incentives/stats
68 |
69 | #### Query parameters
70 |
71 | | Name | Type | Optional | Description |
72 | | ----------- | -------- | -------- | --------------------------------- |
73 | | start_date | integer | y | Query start date. Unix timestamp. |
74 | | end_date | integer | y | Query end date. Unix timestamp. |
75 | | page | integer | y | Page number. Starts from 0. |
76 | | page_size | integer | y | Page size. Default to 20. |
77 |
78 | #### Response
79 |
80 | Response `data` is an array whose element containing:
81 |
82 | | Name | Type | Optional | Description |
83 | | ----------------- | ------------- | -------- | ------------------------------------- |
84 | | date | string | n | Incentives date. Unix timestamp. |
85 | | total | big integer | n | Total incentives get for today. |
86 | | originals | big integer | n | Incentives get from original. 40% of all the incentives. |
87 | | shares | big integer | n | Incentives get from shares. 40% of all the incentives. |
88 | | original_likes | big integer | n | Incentives get from likes. 10% of the original incentives. |
89 | | original_comments | big integer | n | Incentives get from comments. 10% of the original incentives. |
90 | | original_shares | big integer | n | Incentives get from shares. 10% of the original incentives. |
91 | | groups | big integer | n | Incentives get from group management. |
92 |
93 | #### Example
94 |
95 | ```bash
96 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
97 |
98 | {"result_code":0,"data":{"dna":"", ...}}
99 |
100 | ```
101 |
102 |
103 | ### 4. Get incentives withdrawal list
104 |
105 | [GET] /accounts/{account_id}/tokens/incentives/withdrawal
106 |
107 | #### Query parameters
108 |
109 | | Name | Type | Optional | Description |
110 | | ----------- | -------- | -------- | ----------------------------------- |
111 | | start_date | integer | y | Query start date. Unix timestamp. |
112 | | end_date | integer | y | Query end date. Unix timestamp. |
113 | | page | integer | y | Page number. Starts from 0. |
114 | | page_size | integer | y | Page size. Default to 20. |
115 | | status | string | y | Status filter. "pending" or "done". |
116 |
117 | #### Response
118 |
119 | Response `data` is an array whose element containing:
120 |
121 | | Name | Type | Optional | Description |
122 | | -------------- | ----------- | -------- | ------------------------------------------------------------- |
123 | | id | string | n | Withdrawal id. |
124 | | created | integer | n | Withdrawal created time. Unix timestamp. |
125 | | updated | integer | n | Withdrawal updated time. |
126 | | amount | big integer | n | Withdrawal amount. |
127 | | node_fee | big integer | n | Node charged withdrawal fee. |
128 | | status | string | n | Withdrawal status. "pending", "done" or "cancelled". |
129 | | transaction | object | n | Withdrawal [transaction object](./transaction.md#transaction) |
130 |
131 | #### Example
132 |
133 | ```bash
134 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
135 |
136 | {"result_code":0,"data":{"dna":"", ...}}
137 |
138 | ```
139 |
140 |
141 | ### 5. Withdraw incentives
142 |
143 | [POST] /accounts/{account_id}/tokens/incentives/withdrawal
144 |
145 | #### Request
146 |
147 | | Name | Type | Optional | Description |
148 | | ------------ | ----------- | ------------ | ---------------------------------------------------------- |
149 | | node_id | string | n | Node id.
150 | | created | integer | n | Withdrawal creation time. Unix timestamp. |
151 | | amount | big integer | n | Withdraw amount value. |
152 | | node_fee | big integer | n | Node charged withdrawal fee. |
153 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
154 |
155 | #### Response
156 |
157 | | Name | Type | Optional | Description |
158 | | ---- | ------ | -------- | --------------- |
159 | | id | string | n | Withdrawal id. |
160 |
161 | #### Example
162 |
163 | ```bash
164 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
165 |
166 | {"result_code":0,"data":{"dna":"", ...}}
167 |
168 | ```
169 |
170 |
171 | ### 6. Get token pre-lock list
172 |
173 | [GET] /accounts/{account_id}/tokens/pre_locks
174 |
175 | #### Query parameters
176 |
177 | | Name | Type | Optional | Description |
178 | | ----------- | -------- | -------- | ----------------------------------- |
179 | | start_date | integer | y | Query start date. Unix timestamp. |
180 | | end_date | integer | y | Query end date. Unix timestamp. |
181 | | page | integer | y | Page number. Starts from 0. |
182 | | page_size | integer | y | Page size. Default to 20. |
183 | | type | string | y | Type filter. "lock" or "unlock". |
184 |
185 | #### Response
186 |
187 | Response `data` is an array whose element containing:
188 |
189 | | Name | Type | Optional | Description |
190 | | ------------------ | ----------- | -------- | ---------------------------------------- |
191 | | id | string | n | Lock id. |
192 | | created | integer | n | Lock creation time. Unix timestamp. |
193 | | type | string | n | Pre-lock type. "lock" or "unlock" |
194 | | amount | big integer | n | Pre-lock amount. |
195 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
196 | | transaction_hash | string | n | Transaction hash. |
197 | | transaction_status | string | n | Transaction status. "pending", "done" or "failed" |
198 |
199 | #### Example
200 |
201 | ```bash
202 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
203 |
204 | {"result_code":0,"data":{"dna":"", ...}}
205 |
206 | ```
207 |
208 |
209 | ### 7. Pre-lock tokens
210 |
211 | [POST] /accounts/{account_id}/tokens/pre_locks
212 |
213 | #### Request
214 |
215 | | Name | Type | Optional | Description |
216 | | ---------------- | ------- | -------- | -------------------------------------- |
217 | | transaction | string | n | Signed raw transaction to lock tokens. |
218 |
219 | #### Response
220 |
221 | | Name | Type | Optional | Description |
222 | | ------- | ------ | -------- | ------------ |
223 | | id | string | n | Pre-lock id. |
224 |
225 | #### Example
226 |
227 | ```bash
228 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
229 |
230 | {"result_code":0,"data":{"dna":"", ...}}
231 |
232 | ```
233 |
234 |
235 | ### 8. Unlock pre-locked tokens(designing)
236 |
237 | [DELETE] /accounts/{account_id}/tokens/pre_locks
238 |
239 | #### Request
240 |
241 | | Name | Type | Optional | Description |
242 | | ------------ | ----------- | -------- | ---------------------------------------------------------- |
243 | | node_id | string | n | Primas Node id. |
244 | | created | integer | n | People creation time. Unix timestamp. |
245 | | amount | big integer | n | Unlock amount. |
246 | | signature | string | n | [Metadata signature](./dtcp.md#metadata-signature). |
247 |
248 | #### Response
249 |
250 | | Name | Type | Optional | Description |
251 | | ------- | ------ | -------- | ------------ |
252 | | id | string | n | Pre-lock id. |
253 |
254 | #### Example
255 |
256 | ```bash
257 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
258 |
259 | {"result_code":0,"data":{"dna":"", ...}}
260 |
261 | ```
262 |
263 |
264 | ### 9. Get token lock list
265 |
266 | [GET] /accounts/{account_id}/tokens/locks
267 |
268 | #### Query parameters
269 |
270 | | Name | Type | Optional | Description |
271 | | ----------- | -------- | -------- | ----------------------------------------------- |
272 | | start_date | integer | y | Query start date. Unix timestamp. |
273 | | end_date | integer | y | Query end date. Unix timestamp. |
274 | | page | integer | y | Page number. Starts from 0. |
275 | | page_size | integer | y | Page size. Default to 20. |
276 | | type | string | y | Type filter. "content", "group_create", "group_join" or "report". |
277 |
278 | #### Response
279 |
280 | Response `data` is an array whose element containing:
281 |
282 | | Name | Type | Optional | Description |
283 | | --------- | ----------- | -------- | -------------------------------------------------------- |
284 | | id | string | n | Lock id. |
285 | | amount | big integer | n | Lock amount. |
286 | | expire | integer | n | Lock expire time. Unix timestamp. 0 for non-expire locks. |
287 | | type | string | n | Lock type. "content", "group_create", "group_join" or "report". |
288 | | object_id | string | n | Locked object(content, group, report) id. |
289 | | created | integer | n | Lock creation time. Unix timestamp. |
290 |
291 | #### Example
292 |
293 | ```bash
294 | $ curl -x https://rigel-a.primas.network/v3/content -d '{"type":"article","content":"...","signature":"..."}'
295 |
296 | {"result_code":0,"data":{"dna":"", ...}}
297 |
298 | ```
299 |
--------------------------------------------------------------------------------
/transaction.md:
--------------------------------------------------------------------------------
1 | `transaction` object:
2 |
3 | | Name | Type | Optional | Description |
4 | | ------------------- | ----------- | -------- | ------------------------------------------------------------- |
5 | | transaction_id | string | y | Transaction hash. |
6 | | block_number | integer | y | Block number of this transaction. |
7 | | block_confirmations | integer | y | Block confirmation time. |
8 | | estimated_time | integer | n | Estimated confirmation time. Unix timestamp. |
9 | | confirmed_time | integer | y | Confirmation time. Unix timestamp. |
10 |
--------------------------------------------------------------------------------