-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b1a2869
Showing
34 changed files
with
1,638 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2022 biologyscience | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<p align="center"> | ||
<img src="https://biologyscience.github.io/package/alpha-coders/svg/Alpha%20Coders.svg" alt="Cover" height="200px" width="600px"> | ||
</p> | ||
|
||
# About | ||
A complete package used to interact with the [Wallpaper Abyss API](https://wall.alphacoders.com/api.php) to get wallpapers, wallpaper count, collections, and much more ! | ||
Please make sure that you are following the Wallpaper Abyss API [terms and conditions](https://wall.alphacoders.com/api.php) while using this package. | ||
|
||
You will need an API key which was given to you by the admins of [Wallpaper Abyss](https://alphacoders.com) to use this package. | ||
|
||
### **NOTE**: | ||
Unfortunately they have closed their API applications, so any new user cannot use this package because you would need an API key in order to use this package. | ||
|
||
# Installation | ||
``` | ||
npm i alpha-coders | ||
``` | ||
# Features | ||
- Made with JavaScript. | ||
- Easy to use. | ||
- Complete coverage of all the methods in [Wallpaper Abyss API](https://wall.alphacoders.com/api.php). | ||
- Type support. | ||
|
||
<br> | ||
|
||
> Make sure to have a look at the [Documentation](https://biologyscience.gitbook.io/alpha-coders) of this package to get an in depth information on how to use this package. | ||
<br> | ||
|
||
# Function Tree | ||
> **C** - Class | ||
**P** - Property | ||
**M** - Method | ||
|
||
- [Alpha](https://biologyscience.gitbook.io/alpha-coders/reference/classes/alpha) **C** | ||
- [getWallpapers](https://biologyscience.gitbook.io/alpha-coders/reference/properties/getwallpapers) **P** | ||
- [bySort](https://biologyscience.gitbook.io/alpha-coders/reference/methods/bysort) **M** | ||
- [fromCategory](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromcategory) **M** | ||
- [fromCollection](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromcollection) **M** | ||
- [fromGroup](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromgroup) **M** | ||
- [fromSubCategory](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromsubcategory) **M** | ||
- [fromFeatured](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromfeatured) **M** | ||
- [fromPopular](https://biologyscience.gitbook.io/alpha-coders/reference/methods/frompopular) **M** | ||
- [fromTag](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromtag) **M** | ||
- [fromUser](https://biologyscience.gitbook.io/alpha-coders/reference/methods/fromuser) **M** | ||
- [getWallpaperCount](https://biologyscience.gitbook.io/alpha-coders/reference/properties/getwallpapercount) **P** | ||
- [inEntireDB](https://biologyscience.gitbook.io/alpha-coders/reference/methods/inentiredb) **M** | ||
- [inCategory](https://biologyscience.gitbook.io/alpha-coders/reference/methods/incategory) **M** | ||
- [inCollection](https://biologyscience.gitbook.io/alpha-coders/reference/methods/incollection) **M** | ||
- [inGroup](https://biologyscience.gitbook.io/alpha-coders/reference/methods/ingroup) **M** | ||
- [inSubCategory](https://biologyscience.gitbook.io/alpha-coders/reference/methods/insubcategory) **M** | ||
- [inTag](https://biologyscience.gitbook.io/alpha-coders/reference/methods/intag) **M** | ||
- [inUser](https://biologyscience.gitbook.io/alpha-coders/reference/methods/inuser) **M** | ||
- [getList](https://biologyscience.gitbook.io/alpha-coders/reference/properties/getlist) **P** | ||
- [ofCategory](https://biologyscience.gitbook.io/alpha-coders/reference/methods/ofcategory) **M** | ||
- [ofCollection](https://biologyscience.gitbook.io/alpha-coders/reference/methods/ofcollection) **M** | ||
- [ofGroup](https://biologyscience.gitbook.io/alpha-coders/reference/methods/ofgroup) **M** | ||
- [ofSubCategory](https://biologyscience.gitbook.io/alpha-coders/reference/methods/ofsubcategory) **M** | ||
- [search](https://biologyscience.gitbook.io/alpha-coders/reference/methods/search) **M** | ||
- [getWallpaperInfo](https://biologyscience.gitbook.io/alpha-coders/reference/methods/getwallpaperinfo) **M** | ||
- [getRandomWallpaper](https://biologyscience.gitbook.io/alpha-coders/reference/methods/getrandomwallpaper) **M** | ||
- [queryCount](https://biologyscience.gitbook.io/alpha-coders/reference/methods/querycount) **M** | ||
|
||
# Known Issue: | ||
### Caused due to version mismatch of [node-fetch](https://www.npmjs.com/package/node-fetch) | ||
|
||
Error: | ||
``` | ||
\node_modules\alpha-coders\methods\search.js:2 | ||
const fetch = require('node-fetch'); | ||
^ | ||
Error [ERR_REQUIRE_ESM]: require() of ES Module ... | ||
``` | ||
To Fix: | ||
- Open up your terminal | ||
- Do `npm rm node-fecth` | ||
- Then do `npm i [email protected]` | ||
|
||
<br> | ||
|
||
If you face any other issue, feel free to create an issue on the [issues page](https://github.com/biologyscience/alpha-coders/issues) in the github repository. | ||
|
||
# Useful Links | ||
<a href="https://github.com/biologyscience/alpha-coders"> | ||
<img alt="GitHub" src="https://biologyscience.github.io/package/alpha-coders/svg/GitHub.svg" height="40px"> | ||
</a> | ||
<a href="https://www.npmjs.com/package/alpha-coders"> | ||
<img alt="npm" src="https://biologyscience.github.io/package/alpha-coders/svg/npm.svg" height="40px"> | ||
</a> | ||
<a href="https://biologyscience.github.io/package/alpha-coders"> | ||
<img alt="Website" src="https://biologyscience.github.io/package/alpha-coders/svg/Website.svg" height="40px"> | ||
</a> | ||
<a href="https://biologyscience.gitbook.io/alpha-coders/"> | ||
<img alt="Documentation" src="https://biologyscience.github.io/package/alpha-coders/svg/Docs.svg" height="40px"> | ||
</a> | ||
<a href="https://github.com/biologyscience/alpha-coders/blob/main/LICENSE"> | ||
<img alt="License" src="https://biologyscience.github.io/package/alpha-coders/svg/Open%20Source.svg" height="40px"> | ||
</a> | ||
|
||
--- | ||
|
||
## Happy Coding 🥳 | ||
|
||
<br> | ||
|
||
> ###### Edit this page on [GitHub](https://github.com/biologyscience/alpha-coders/edit/main/README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
class Alpha | ||
{ | ||
baseURL = new URL('https://wall.alphacoders.com/api2.0/get.php'); | ||
|
||
constructor(apiToken) | ||
{ | ||
this.apiToken = apiToken; | ||
this.baseURL.searchParams.set('auth', this.apiToken); | ||
} | ||
|
||
getWallpapers = | ||
{ | ||
baseURL: this.baseURL, | ||
bySort: require('./methods/getWallpapers/bySort'), | ||
fromCategory: require('./methods/getWallpapers/fromCategory'), | ||
fromCollection: require('./methods/getWallpapers/fromCollection'), | ||
fromGroup: require('./methods/getWallpapers/fromGroup'), | ||
fromSubCategory: require('./methods/getWallpapers/fromSubCategory'), | ||
fromFeatured: require('./methods/getWallpapers/fromFeatured'), | ||
fromPopular: require('./methods/getWallpapers/fromPopular'), | ||
fromTag: require('./methods/getWallpapers/fromTag'), | ||
fromUser: require('./methods/getWallpapers/fromUser') | ||
} | ||
|
||
getWallpaperCount = | ||
{ | ||
baseURL: this.baseURL, | ||
inEntireDB: require('./methods/getWallpaperCount/inEntireDB'), | ||
inCategory: require('./methods/getWallpaperCount/inCategory'), | ||
inCollection: require('./methods/getWallpaperCount/inCollection'), | ||
inGroup: require('./methods/getWallpaperCount/inGroup'), | ||
inSubCategory: require('./methods/getWallpaperCount/inSubCategory'), | ||
inFeatured: require('./methods/getWallpaperCount/inFeatured'), | ||
inPopular: require('./methods/getWallpaperCount/inPopular'), | ||
inTag: require('./methods/getWallpaperCount/inTag'), | ||
inUser: require('./methods/getWallpaperCount/inUser') | ||
} | ||
|
||
getList = | ||
{ | ||
baseURL: this.baseURL, | ||
ofCategory: require('./methods/getList/ofCategory'), | ||
ofCollection: require('./methods/getList/ofCollection'), | ||
ofGroup: require('./methods/getList/ofGroup'), | ||
ofSubCategory: require('./methods/getList/ofSubCategory') | ||
} | ||
|
||
search = require('./methods/search'); | ||
getWallpaperInfo = require('./methods/getWallpaperInfo'); | ||
getRandom = require('./methods/getRandomWallpaper'); | ||
queryCount = require('./methods/queryCount'); | ||
} | ||
|
||
module.exports = Alpha; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const | ||
fetch = require('node-fetch'), | ||
misc = require('../../misc/misc.json'); | ||
|
||
function ofCategory() | ||
{ | ||
misc.params.forEach(x => x === 'auth' ? null : this.baseURL.searchParams.delete(x)); | ||
|
||
this.baseURL.searchParams.set('method', 'category_list'); | ||
|
||
return new Promise((resolve) => | ||
{ | ||
fetch.default(this.baseURL).then(x => x.json()).then((response) => | ||
{ | ||
if (response.success === false) { return require('../../misc/errorHandler')(response); } | ||
|
||
resolve(response.categories); | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = ofCategory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const | ||
fetch = require('node-fetch'), | ||
misc = require('../../misc/misc.json'); | ||
|
||
function ofCollection() | ||
{ | ||
misc.params.forEach(x => x === 'auth' ? null : this.baseURL.searchParams.delete(x)); | ||
|
||
this.baseURL.searchParams.set('method', 'collection_list'); | ||
|
||
return new Promise((resolve) => | ||
{ | ||
fetch.default(this.baseURL).then(x => x.json()).then((response) => | ||
{ | ||
if (response.success === false) { return require('../../misc/errorHandler')(response); } | ||
|
||
resolve(response.collections); | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = ofCollection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const | ||
fetch = require('node-fetch'), | ||
misc = require('../../misc/misc.json'); | ||
|
||
function ofGroup(id) | ||
{ | ||
misc.params.forEach(x => x === 'auth' ? null : this.baseURL.searchParams.delete(x)); | ||
|
||
this.baseURL.searchParams.set('method', 'group_list'); | ||
this.baseURL.searchParams.set('id', id) | ||
|
||
return new Promise((resolve) => | ||
{ | ||
fetch.default(this.baseURL).then(x => x.json()).then((response) => | ||
{ | ||
if (response.success === false) { return require('../../misc/errorHandler')(response); } | ||
|
||
resolve(response.groups); | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = ofGroup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const | ||
fetch = require('node-fetch'), | ||
misc = require('../../misc/misc.json'); | ||
|
||
function ofSubCategory(id) | ||
{ | ||
misc.params.forEach(x => x === 'auth' ? null : this.baseURL.searchParams.delete(x)); | ||
|
||
this.baseURL.searchParams.set('method', 'sub_category_list'); | ||
this.baseURL.searchParams.set('id', id); | ||
|
||
return new Promise((resolve) => | ||
{ | ||
fetch.default(this.baseURL).then(x => x.json()).then((response) => | ||
{ | ||
if (response.success === false) { return require('../../misc/errorHandler')(response); } | ||
|
||
resolve(response['sub-categories']); | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = ofSubCategory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const | ||
fetch = require('node-fetch'), | ||
misc = require('../misc/misc.json'); | ||
|
||
function getRandomWallpaper(options) | ||
{ | ||
misc.params.forEach(x => x === 'auth' ? null : this.baseURL.searchParams.delete(x)); | ||
|
||
this.baseURL.searchParams.set('method', 'random'); | ||
this.baseURL.searchParams.set('info_level', 3); | ||
|
||
if (options?.count !== undefined) { this.baseURL.searchParams.set('count', options.count); } | ||
|
||
return new Promise((resolve) => | ||
{ | ||
fetch.default(this.baseURL).then(x => x.json()).then((response) => | ||
{ | ||
if (response.success === false) { return require('../misc/errorHandler')(response); } | ||
|
||
let | ||
data = [], | ||
temp = {}; | ||
|
||
response.wallpapers.forEach((item) => | ||
{ | ||
temp.id = item.id; | ||
temp.width = item.width; | ||
temp.height = item.height; | ||
temp.fileType = item.file_type; | ||
temp.fileSize = item.file_size; | ||
temp.url = { image: item.url_image, thumbnail: item.url_thumb, webpage: item.url_page }; | ||
|
||
if (options?.level === 2) | ||
{ | ||
temp.category = { name: item.category, id: item.category_id }; | ||
temp.subCategory = { name: item.sub_category, id: item.sub_category_id }; | ||
temp.user = { name: item.user_name, id: item.user_id }; | ||
} | ||
|
||
if (options?.level === 3) | ||
{ | ||
temp.category = { name: item.category, id: item.category_id }; | ||
temp.subCategory = { name: item.sub_category, id: item.sub_category_id }; | ||
temp.user = { name: item.user_name, id: item.user_id }; | ||
|
||
temp.collection = { name: item.collection , id: item.collection_id }; | ||
temp.group = { name: item.group , id: item.group_id }; | ||
} | ||
|
||
data.push(temp); | ||
|
||
temp = {}; | ||
}); | ||
|
||
resolve(data); | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = getRandomWallpaper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const | ||
fetch = require('node-fetch'), | ||
misc = require('../../misc/misc.json'); | ||
|
||
function inCategory(id, options) | ||
{ | ||
misc.params.forEach(x => x === 'auth' ? null : this.baseURL.searchParams.delete(x)); | ||
|
||
this.baseURL.searchParams.set('method', 'category_count'); | ||
this.baseURL.searchParams.set('id', id); | ||
|
||
if (options?.width !== undefined) { this.baseURL.searchParams.set('width', options.width); } | ||
if (options?.height !== undefined) { this.baseURL.searchParams.set('height', options.height); } | ||
if (options?.operator !== undefined) { this.baseURL.searchParams.set('operator', options.operator); } | ||
|
||
return new Promise((resolve) => | ||
{ | ||
fetch.default(this.baseURL).then(x => x.json()).then((response) => | ||
{ | ||
if (response.success === false) { return require('../../misc/errorHandler')(response); } | ||
|
||
resolve(response.count); | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = inCategory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const | ||
fetch = require('node-fetch'), | ||
misc = require('../../misc/misc.json'); | ||
|
||
function inCollection(id, options) | ||
{ | ||
misc.params.forEach(x => x === 'auth' ? null : this.baseURL.searchParams.delete(x)); | ||
|
||
this.baseURL.searchParams.set('method', 'collection_count'); | ||
this.baseURL.searchParams.set('id', id); | ||
|
||
if (options?.width !== undefined) { this.baseURL.searchParams.set('width', options.width); } | ||
if (options?.height !== undefined) { this.baseURL.searchParams.set('height', options.height); } | ||
if (options?.operator !== undefined) { this.baseURL.searchParams.set('operator', options.operator); } | ||
|
||
return new Promise((resolve) => | ||
{ | ||
fetch.default(this.baseURL).then(x => x.json()).then((response) => | ||
{ | ||
if (response.success === false) { return require('../../misc/errorHandler')(response); } | ||
|
||
resolve(response.count); | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = inCollection; |
Oops, something went wrong.