cta-scr-api-client-durban-2015
v1.0.1cta-scr-api-client (Durban hackathon 2015 edition)
introduction
The API client module for the CTA Shared Content Repository
This is a special version of the API client that was made and published specifically for the AgriHack challenge in Durban
http://durban-agrihack.ict4ag.org/index.php/about-2/
installation
$ npm install cta-scr-api-client-durban-2015 --save
usage
Generate a project and then run grunt to build/update the distribution sources.
You can also use grunt watch
to continuously update when file changes are detected.
enrichment event subscribtion
There is a pubsub-js based setup you can subscribe to like so:
subscription = api.events.subscribe( "enrichment", ( msg, data ) ->
console.log( "[SOCKET] enrichment", msg, data or "" )
)
or for only articles:
subscription = api.events.subscribe( "enrichment.article", ( msg, data ) ->
console.log( "[SOCKET] enrichment", msg, data or "" )
)
or for a specific article:
subscription = api.events.subscribe( "enrichment.article.<articleId>", ( msg, data ) ->
console.log( "[SOCKET] enrichment", msg, data or "" )
)
Don't forget to unsubscribe when you no longer want to listen to the messages:
api.events.unsubscribe( subscription )
The msg will contain the full message name. This will always be in the format:
enrichment.<type>.<id>
The data will be an object that looks like this:
{
type: "article",
id: articleId,
success: true,
msg: "done"
}
npm i [email protected]
Metadata
- Unknown
- Whatever
- Mark Doeswijk
- released 11/25/2015