using TW as a API testbed

92 views
Skip to first unread message

S.

unread,
Jun 20, 2016, 10:57:53 AM6/20/16
to TiddlyWikiDev
Hi there.

I want to grab information from a RESTful API (for instance this: https://developer.spotify.com/web-api/get-recommendations/ ), which will return XML or JSON, and was thinking TW would be a fine platform to test connections, and perhaps even configure a prettified view of the response.

I'm very rusty in TW development, haven't touched it in years, is there any plugin tutorials, or plugins themselves you can point to as a good start for me to look at?  I've done a bit of googling, but not finding anything yet.

Regards,
S.

S.

unread,
Jun 28, 2016, 12:29:59 PM6/28/16
to TiddlyWikiDev
I've been working on this, and I think I've gotten it working.

You can see the macro here:
https://github.com/Steinthor/APIPostPlugin

I'm testing it against gracenotes' API, and I'm not getting a response, most likely because of cross-browser referencing, which they seem to have denied.

Anyone know of a way to get past cross-browser lockdowns with a tiddlywiki file?  Some way to use the path of the computer, or some such?

Regards,
S.

S.

unread,
Jun 29, 2016, 6:00:09 AM6/29/16
to TiddlyWikiDev
I'm just replying to myself if by chance someone else is interested I can direct them where I stand in trying to solve this..

There are firefox addons that can test GET POST and PUT requests, one called RESTClient and other POSTer, both work fine with gracenote API, so I?m guessing it's not a cross-domain problem, or that they solve it in some way that would work for a tiddlywiki.

So I'm still studying this.

S.

Daniel Metcalfe

unread,
Aug 22, 2016, 12:35:14 PM8/22/16
to tiddly...@googlegroups.com
Hi S,

Are you trying to implement this as a Javascript Macro? Have you looked in the develop console to see what error you're actually getting?

I'm currently trying to write a TiddlyWiki plugin that calls an API but have had difficulties because the Javascript runs in the browser and so it is subject to the Same Origin Policy (SOP) and so unless the API you are calling supports CORS your requests will be rejected by the browser.

The reason Firefox addons can make such requests is because addons are extensions to the browser itself and therefore can have special privileges to ignore SOP restrictions that the browser would enforce on normal web pages.

TiddlyWiki can be run as a node server and server-side code is not subject to SOP restrictions so you can call whatever APIs you want. However there are other open source projects designed specifically to be API test beds. You might want to look at Swagger UI. You can test it out using the Swagger Editor.
Reply all
Reply to author
Forward
0 new messages