Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/archangel-irk/rest-api-client
RESTfull api client (beta) for browser (deps on jQuery)
https://github.com/archangel-irk/rest-api-client
Last synced: 7 days ago
JSON representation
RESTfull api client (beta) for browser (deps on jQuery)
- Host: GitHub
- URL: https://github.com/archangel-irk/rest-api-client
- Owner: archangel-irk
- Created: 2013-08-23T03:49:42.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T04:54:13.000Z (about 2 years ago)
- Last Synced: 2025-01-01T20:20:03.733Z (8 days ago)
- Language: JavaScript
- Homepage:
- Size: 2.2 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 21
-
Metadata Files:
- Readme: README.eng.md
Awesome Lists containing this project
README
# RESTful api client [![Travis][build-badge]][build]
[build-badge]: https://img.shields.io/travis/archangel-irk/rest-api-client/master.svg?style=flat-square
[build]: https://travis-ci.org/archangel-irk/rest-api-client[english](README.eng.md) | [по-русски](README.md)
Build easy client to the RESTful server api.
The library uses the approach of "chaining" for the organization transparent query.
Authorization is available on the token.## Dependencies
1. jQuery for ajax.## Basic usage
```javascript
var github = ApiClient('https://api.github.com', {
hooks: {
headers: {
Accept: 'application/vnd.github.v3+json',
Authorization: 'token XXXXXX'
}
},
unauthorizedCallback: function(){} // Called whenever a response code from the server 401
});github.read(); // GET https://api.github.com
github.add('user'); // /user
github.add('users'); // /users
github.users.add('repos'); // /users/reposgithub.user.read(); // GET /user
github.users('archangel-irk').repos.read(); // GET /users/archangel-irk/repos
github.users('archangel-irk').repos.read({ sort: 'pushed' }); // GET /users/archangel-irk/repos?sort=pushed
```## Call parent functions
```javascript
github.add('search', {
searchMethod: function(){
console.log( 'search::searchMethod' );
}
});
github.search.add('users', {
usersMethod: function(){
this.parent.searchMethod();
}
});github.search.users.usersMethod(); // search::searchMethod
```