Discuss Scratch

kvackkvack
Scratcher
500+ posts

Scratch Messages API

Quite long ago now, I made a JavaScript API . Looking back at it now, I say one thing with certainty: It sucked. Like, it didn't even work for all types of messages, and it was clunky to use with bad documentation and bad code.
To redeem myself, I've made another, similar API– this time with classes, proper documentation, as much browser support as I could get in there and a minified version.
If anybody would be interested in using it, the code is here. Personally, I think it's pretty great, but there's definitely room for improvement! If you spot some bad code or want to add a new feature, feel free to submit a pull request. There's a Wiki article for Developers on there.
IcyCoder
Scratcher
1000+ posts

Scratch Messages API

Nice may use this
kvackkvack
Scratcher
500+ posts

Scratch Messages API

BUMP.
I just added message filtering and an ability to specify wait time between HTTP requests.
Here's an example script which gets your 15 most recent follows (with modern JS):
getMessages({
  filter: msg => msg.type === ScratchMessage.TYPE.FOLLOWED,
  limit:  15,
  time:   2000
}, (error, messages) => {
  if(error) error.call()
  messages.forEach(message => 
    console.log('At ' + message.date + ': ' + message)
  )
})
Note that the long wait times are due to it possibly having to crawl through multiple messages pages, to decrease this time change the time attribute.
groudon3211
Scratcher
63 posts

Scratch Messages API

apiscratch is op

Powered by DjangoBB