I basically want to create my own private IFTTT/Zapier for plugging data from one API to another.
I’m using the node module
GET data from one API and then
POST to another.
request supports streaming to do neat things like this:
In between those two requests, I’d like to pipe the JSON through a transform, cherry picking the key/value pairs that I need and changing the keys to what the destination API is expecting.
request.get('http://example.com/api') .pipe(apiToApi2Map) .pipe(request.put('http://example.com/api2'));
Here’s a JSON sample from the source API: http://pastebin.com/iKYTJCYk
And this is what I’d like to send forward: http://pastebin.com/133RhSJT
The transformed JSON in this case takes the keys from the value of each objects “attribute” key and the value from each objects “value” key.
So my questions:
Is there a framework, library or module that will make the transform step easier?
requestto easily access API methods, I just need to figure out the middle step.
Would it be possible to create “templates” or “maps” for these transforms? Say I want to change the source or destination API, it would be nice to create a new file that maps the source to destination key/values required.
Hope the community can help and I’m open to any and all suggestions! 🙂
This is an Open Source project I’m working on, so if anyone would like to get involved, just get in touch.