Skip to content

Latest commit

 

History

History

joystream-api

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Joystream API Examples

Repo with examples on how to use the @joystream/types package along with @polkadot/api to communicate with a joystream full node.

Building the code

yarn && yarn build

In case you have a compilation error saying:

node_modules/@joystream/types/content-working-group/index.d.ts:3:22 - error TS2614: Module '"../common"' has no exported member 'Credential'. Did you mean to use 'import Credential from "../common"' instead?

3 import { OptionText, Credential, SlashingTerms } from '../common';
                       ~~~~~~~~~~
Found 1 error.

Open the file node_modules/@joystream/types/content-working-group/index.d.ts in a text editor and remove the failing import, so that the line looks as follows: import { OptionText, SlashingTerms } from '../common';

Save the changes and re-run yarn && yarn build again, the build should work fine.

Example Scripts

Ideal for newcomers. Contains the very basic APIs usage examples: get the last blockchain finalized block, get total coin issuance. Also shows how to iterate the events inside a given block.

node lib/examples/general.js

Another good starting point for newcomers to understand how APIs are called.

node lib/general/status.js

Shows how to work with Substrate events and Extrinsics to get the information about Joystream media uploads.

node lib/curators/get-media-change.js

Shows how to use councilElection, minting, council APIs.

node lib/examples/council.js

Shows the variety of Substrate event Extrinsic types within a given range of blocks.

node lib/examples/get-events-and-extrinsics.js

Shows how to use a set of APIs related to Joystream working groups: storageWorkingGroup, recurringRewards, contentDirectoryWorkingGroup.

node lib/examples/working-groups.js

Shows how to use a APIs related to Joystream DAO proposals proposalsEngine, staking, members.

node lib/examples/proposals.js

Javascript scripts

There are some untyped Javascript scripts available for working with the data directory. You can run them using yarn:

//shows the available scripts
yarn script index

yarn script exportDataDirectory
yarn script listDataDirectory

or execute them in Pioneer JS Toolbox