Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meltingice/jsonp-fu
A Javascript library that provides access to multiple JSONP API's through a unified, extensible, and easy to use interface.
https://github.com/meltingice/jsonp-fu
Last synced: 24 days ago
JSON representation
A Javascript library that provides access to multiple JSONP API's through a unified, extensible, and easy to use interface.
- Host: GitHub
- URL: https://github.com/meltingice/jsonp-fu
- Owner: meltingice
- License: bsd-3-clause
- Created: 2010-10-19T03:16:12.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2011-01-05T06:34:49.000Z (almost 14 years ago)
- Last Synced: 2024-04-13T01:54:13.906Z (7 months ago)
- Language: JavaScript
- Homepage: http://meltingice.github.com/JSONP-Fu/
- Size: 452 KB
- Stars: 27
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
About the Project
JSONP-Fu is a project inspired by the latest design of my own homepage and the work I had to put into it in order to grab data from various JSONP API's. The idea behind the project is simple: provide a unified and extendible interface that Javascript developers can use to easily query various JSONP API's efficiently and easily instead of having to waste time doing research and figuring out how each different API works.JSONP-Fu is a similar idea to oEmbed, but uses a different API and works a bit differently. Instead of throwing a whole URL at an API endpoint, we simply call the API with our parameters and use the JSON data thats returned.
Since all of the JSONP is managed by JSONP-Fu, it makes sure your header stays pretty and your DOM stays uncluttered. All JSONP callback functions are removed after they are called and all script tags added to the header are also removed once their data is retrieved.
Oh and by the way, JSONP-Fu passes JSLint with these options:
/*jslint white: true, browser: true, devel: true, fragment: true, onevar: true, undef: true, nomen: true, eqeqeq: true, bitwise: true, regexp: true, newcap: true, immed: true */Currently Supported APIs
* Flickr
* GitHub
* Last.fm
* Plixi
* Tumblr
* TwitPic
* TypePad
* Wordpress (for custom blogs with JSON-API plugin)
* Yahoo Query Language (YQL)Project To-Do
* Create documentation for each API
* Write more plugins (and finish incomplete ones)!
* Extensive bug testing (of course)
* Update based on feedbackHow to Use
More information and examples can be found on the official GitHub page for JSONP-Fu.How to Extend
Support for new JSONP APIs is added via a very simple to use interface. Feel free to check out jsonp-fu/lib/twitpic.js to see a complete example.To add support for a new API, add a JS file to the lib directory with the API name as the filename. I recommend keeping it as simple as possible.
The basic format is:
/*
* 'my_api' must also be the same name as the filename, minus the .js
* The 'script' variable passed into the callback has a few nifty JSONP related
* functions that you will probably want to use, especially script.jsonp_query()
*/
jsonpfu.extend('my_api', function (script) {return {
do: function () {
script.jsonp_query({
url: 'http://path.to.json.api.com/some/endpoint',
data: { variable1: 'some_data' },
success: function (data) {
console.log(data);
}
});
}
};
});Which means you will be able to do:
jsonpfu.ready('my_api', function () {
this.do();
});Obviously this API plugin is useless and boring, but you get the idea. Check out one of the existing plugins for more comprehensive info.
I Want to Make a Plugin!
Awesome, I'm glad you want to contribute! The best way to do this would be to fork the project, add your plugin in the lib directory, then send a pull request. If the only change you made was adding your new plugin file, then merging your branch with the trunk should be super easy.