500px-API
500px API 是一个非官方的包,用于从中获取照片、用户、摄影师、相机设备详细信息和其他信息500px.com 网站!
When will it be ready?
Table of contents
What is 500px?
500px(发音为“五百像素”) 是一个摄影社区,在这里您可以通过第一次上传立即获得曝光,与世界联系和分享您的照片,并在任何地方成长为一名摄影师。
Why 500px-api?
根据这篇支持帖子,他们不再向第三方提供官方 API。
500px 的历史一直鼓励创意开发,但自 2018 年 1 月 24 日起,500px 将不再提供对我们 API 的免费访问。
做出此决定是为了保护我们的资产并提高我们网站的性能。
6 月 15 日,API 访问被关闭。
这是更大战略转变的一部分,我们将集中精力继续在 500px.com 建立世界上最好的摄影社区。
这是我开发和发布这个包的主要原因。
跳转到顶部
Features
- Proxy support
- Random
User-Agent
header for each Client
Coverage
Installing
使用 yarn(推荐):
yarn add 500px-api
使用 npm:
npm install 500px-api
Get started
参见 examples用于简单 API 调用的子目录。
如果您有一个例子没有很好地展示的用例,请创建一个问题 或提交合并请求。
跳转到顶部
Method Options
每个方法都有很多选项,其中一些需要前置上下文。
首先,我将描述这些选项是什么以及在您的应用程序中使用它们的最佳实践。
跳转到顶部
Categories
根据 API 方法,照片的类别可以通过其 ID 或字符串名称指定。
避免在您的应用程序中硬编码这些ID 和名称! ⚠️
在方法选项中使用它们的最佳实践是使用 Category< /code>
枚举。
如果您使用这种编码方式,以防将来我们更改它们的值,您就不再需要更新您的代码,这进一步确保了您代码的稳定性。
import { Category } from '500px-api';
/**
* Return the String name of the category.
*/
console.log(Category.FAMILY); // Family
有时在发送 API 调用后,您可能希望将类别的数字 ID 转换为人类可读的名称,方法是使用 CategoriesHelper
类。
import { CategoriesHelper } from '500px-api';
/**
* Converts Numeric category ID to it's name.
*/
console.log(CategoriesHelper.convertIdToName(20)); // Family
ID |
Name |
Enum Usage |
10 |
Abstract |
Category.ABSTRACT |
29 |
Aerial |
Category.AERIAL |
11 |
Animals |
Category.ANIMALS |
5 |
Black and White |
Category.BLACK_AND_WHITE |
1 |
Celebrities |
Category.CELEBRITIES |
15 |
Commercial |
Category.COMMERCIAL |
16 |
Concert |
Category.CONCERT |
20 |
Family |
Category.FAMILY |
14 |
Fashion |
Category.FASHION |
2 |
Film |
Category.FILM |
24 |
Fine Art |
Category.FINE_ART |
23 |
Food |
Category.FOOD |
3 |
Journalism |
Category.JOURNALISM |
8 |
Landscapes |
Category.LANDSCAPES |
12 |
Macro |
Category.MACRO |
18 |
Nature |
Category.NATURE |
30 |
Night |
Category.NIGHT |
7 |
People |
Category.PEOPLE |
19 |
Performing Arts |
Category.PERFORMING_ARTS |
9 |
City & Architecture |
Category.CITY_AND_ARCHITECTURE |
17 |
Sport |
Category.SPORT |
6 |
Still Life |
Category.STILL_LIFE |
21 |
Street |
Category.STREET |
26 |
Transportation |
Category.TRANSPORTATION |
13 |
Travel |
Category.TRAVEL |
22 |
Underwater |
Category.UNDERWATER |
27 |
Urban Exploration |
Category.URBAN_EXPLORATION |
25 |
Wedding |
Category.WEDDING |
0 |
Uncategorized |
Category.UNCATEGORIZED |
跳到顶部
Hidden categories
出于多种原因,例如受众类型或具有 NSFW 标签,500px.com 网站将这些类别隐藏在公众视线之外。
您可以像通常的类别一样使用这些ID和名称,但您必须知道内容是对于成熟的用户。
ID |
Name |
Enum Usage |
31 |
Boudoir |
Category.BOUDOIR |
4 |
Nude |
Category.NUDE |
跳转到顶部
Image sizes
要获取不同大小的图像,您必须提供一个数字 ID 数组作为方法选项。 这些 ID 中的每一个都代表不同的图像大小。
避免在您的应用程序中硬编码这些ID! ⚠️
在方法选项中使用它们的最佳做法是使用 ImageSize< /code>
枚举。
import { ImageSize } from '500px-api';
console.log(ImageSize.STANDARD_WIDTH_4096); // 15
我不知道 K 和 S 列代表什么,但我还是在这个包和文档中实现了它们。 如果您有关于它们的更多信息,请随时打开一个新问题来解释它们。
跳到顶部
Standard sizes
如果宽度或高度为空,则表示将自动计算它们(将其视为auto
)。
import { ImageSize } from '500px-api';
const sizes = [
// Standard width
ImageSize.STANDARD_WIDTH_1000_Q50,
ImageSize.STANDARD_WIDTH_2000_Q75,
ImageSize.STANDARD_WIDTH_4096,
// Standard height
ImageSize.STANDARD_HEIGHT_300_Q80,
ImageSize.STANDARD_HEIGHT_300,
ImageSize.STANDARD_HEIGHT_450_Q80,
ImageSize.STANDARD_HEIGHT_450_Q50,
ImageSize.STANDARD_HEIGHT_600_Q80,
ImageSize.STANDARD_HEIGHT_600,
ImageSize.STANDARD_HEIGHT_1080,
];
ID |
Width |
Height |
Quality |
K |
S |
Watermark |
Enum Usage |
23 |
1000 |
|
50 |
|
|
✖️ |
ImageSize.STANDARD_WIDTH_1000_Q50 |
24 |
2000 |
|
75 |
|
|
✖️ |
ImageSize.STANDARD_WIDTH_2000_Q75 |
15 |
4096 |
|
|
|
✔️ |
✖️ |
ImageSize.STANDARD_WIDTH_4096 |
32 |
|
300 |
80 |
|
|
✖️ |
ImageSize.STANDARD_HEIGHT_300_Q80 |
20 |
|
300 |
|
|
|
✖️ |
ImageSize.STANDARD_HEIGHT_300 |
31 |
|
450 |
80 |
|
|
✖️ |
ImageSize.STANDARD_HEIGHT_450_Q80 |
22 |
|
450 |
50 |
|
|
✖️ |
ImageSize.STANDARD_HEIGHT_450_Q50 |
33 |
|
600 |
80 |
✔️ |
|
✖️ |
ImageSize.STANDARD_HEIGHT_600_Q80 |
21 |
|
600 |
|
✔️ |
|
✖️ |
ImageSize.STANDARD_HEIGHT_600 |
6 |
|
1080 |
|
✔️ |
|
✖️ |
ImageSize.STANDARD_HEIGHT_1080 |
跳转到顶部
Longest edge sizes
根据图像的整体高度和宽度,图像的最长边将设置为Longest Edge 列的值,而另一条边将被视为<代码>自动。
import { ImageSize } from '500px-api';
const sizes = [
// Longest edge
ImageSize.LONGEST_EDGE_256,
ImageSize.LONGEST_EDGE_900,
ImageSize.LONGEST_EDGE_900_WATERMARK,
ImageSize.LONGEST_EDGE_1000_Q80,
ImageSize.LONGEST_EDGE_1080,
ImageSize.LONGEST_EDGE_1170,
ImageSize.LONGEST_EDGE_1500_Q80,
ImageSize.LONGEST_EDGE_1600,
ImageSize.LONGEST_EDGE_2000_Q80,
ImageSize.LONGEST_EDGE_2048,
ImageSize.LONGEST_EDGE_4096,
];
ID |
Longest Edge |
Quality |
K |
S |
Watermark |
Enum Usage |
30 |
256 |
|
|
|
✖️ |
ImageSize.LONGEST_EDGE_256 |
4 |
900 |
|
|
|
✖️ |
ImageSize.LONGEST_EDGE_900 |
14 |
900 |
|
✔️ |
✔️ |
✔️ |
ImageSize.LONGEST_EDGE_900_WATERMARK |
34 |
1000 |
80 |
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_1000_Q80 |
1080 |
1080 |
|
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_1080 |
5 |
1170 |
|
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_1170 |
35 |
1500 |
80 |
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_1500_Q80 |
1600 |
1600 |
|
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_1600 |
36 |
2000 |
80 |
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_2000_Q80 |
2048 |
2048 |
|
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_2048 |
4096 |
4096 |
|
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_4096 |
跳到顶部
Cropped sizes
无论照片的原始尺寸如何,它们都会被裁剪并且永远不会大于指定尺寸。
import { ImageSize } from '500px-api';
const sizes = [
// Cropped
ImageSize.CROPPED_70x70,
ImageSize.CROPPED_100x100,
ImageSize.CROPPED_140x140_Q50,
ImageSize.CROPPED_200x200,
ImageSize.CROPPED_280x280,
ImageSize.CROPPED_440x440,
ImageSize.CROPPED_580x580,
ImageSize.CROPPED_600x600,
ImageSize.CROPPED_680x680,
];
ID |
Width |
Height |
Quality |
S |
Watermark |
Enum Usage |
1 |
70 |
70 |
|
|
✖️ |
ImageSize.CROPPED_70x70 |
100 |
100 |
100 |
|
|
✖️ |
ImageSize.CROPPED_100x100 |
2 |
140 |
140 |
50 |
|
✖️ |
ImageSize.CROPPED_140x140_Q50 |
200 |
200 |
200 |
|
|
✖️ |
ImageSize.CROPPED_200x200 |
3 |
280 |
280 |
|
|
✖️ |
ImageSize.CROPPED_280x280 |
440 |
440 |
440 |
|
|
✖️ |
ImageSize.CROPPED_440x440 |
11 |
580 |
580 |
|
✔️ |
✖️ |
ImageSize.CROPPED_580x580 |
600 |
600 |
600 |
|
|
✖️ |
ImageSize.CROPPED_600x600 |
13 |
680 |
680 |
|
✔️ |
✖️ |
ImageSize.CROPPED_680x680 |
跳转到顶部
Contributing
请阅读 CONTRIBUTING.md 文件以了解详细信息我们的行为准则、运行测试的过程以及向我们提交拉取请求。
跳到顶部
Resources
跳到顶部
500px-API
500px API is an unofficial package to fetch photos, users, photographers, camera equipment details, and other information from the 500px.com website!
When will it be ready?
Table of contents
What is 500px?
500px (pronounced "five hundred p-x") is a photography community where you can get immediate exposure with your first upload, connect and share your photos with the world, and grow as a photographer from anywhere.
Why 500px-api?
According to this support post, they no longer provide official API to third-parties.
The history of 500px has always encouraged creative development, but as of January 24th 2018, 500px will no longer be offering free access to our API.
This decision was made in order to protect our assets and improve our website's performance.
On June 15th, access to the API was shut down.
This is part of a larger strategic shift focusing our energy on continuing to build the world’s best photography community at 500px.com.
That's the main reason I developed and publish this package.
???? jump to the top
Features
- Proxy support
- Random
User-Agent
header for each Client
Coverage
Installing
Using yarn (recommended):
yarn add 500px-api
Using npm:
npm install 500px-api
Get started
See the examples subdirectory for simple API calls.
If you have a use-case in mind which isn't well-represented by the examples, please create an issue or submit a Pull Request.
???? jump to the top
Method Options
Each method has a lot of options, and some of them require pre-context.
First, I'll describe what those options are and the best practices to use them in your application.
???? jump to the top
Categories
Categories of photos may be specified by their ID or string name, depending on the API method.
Avoid hard coding these IDs and names in your application! ⚠️
The best practice to use them in method options, is using Category
enum.
If you use this coding approach, in case if we change their values in the future, you no longer need to update your code, and this further ensures the stability of your code.
import { Category } from '500px-api';
/**
* Return the String name of the category.
*/
console.log(Category.FAMILY); // Family
Sometimes after sending an API call, you might want to convert the category's numeric IDs to human-readable names, by using CategoriesHelper
class.
import { CategoriesHelper } from '500px-api';
/**
* Converts Numeric category ID to it's name.
*/
console.log(CategoriesHelper.convertIdToName(20)); // Family
ID |
Name |
Enum Usage |
10 |
Abstract |
Category.ABSTRACT |
29 |
Aerial |
Category.AERIAL |
11 |
Animals |
Category.ANIMALS |
5 |
Black and White |
Category.BLACK_AND_WHITE |
1 |
Celebrities |
Category.CELEBRITIES |
15 |
Commercial |
Category.COMMERCIAL |
16 |
Concert |
Category.CONCERT |
20 |
Family |
Category.FAMILY |
14 |
Fashion |
Category.FASHION |
2 |
Film |
Category.FILM |
24 |
Fine Art |
Category.FINE_ART |
23 |
Food |
Category.FOOD |
3 |
Journalism |
Category.JOURNALISM |
8 |
Landscapes |
Category.LANDSCAPES |
12 |
Macro |
Category.MACRO |
18 |
Nature |
Category.NATURE |
30 |
Night |
Category.NIGHT |
7 |
People |
Category.PEOPLE |
19 |
Performing Arts |
Category.PERFORMING_ARTS |
9 |
City & Architecture |
Category.CITY_AND_ARCHITECTURE |
17 |
Sport |
Category.SPORT |
6 |
Still Life |
Category.STILL_LIFE |
21 |
Street |
Category.STREET |
26 |
Transportation |
Category.TRANSPORTATION |
13 |
Travel |
Category.TRAVEL |
22 |
Underwater |
Category.UNDERWATER |
27 |
Urban Exploration |
Category.URBAN_EXPLORATION |
25 |
Wedding |
Category.WEDDING |
0 |
Uncategorized |
Category.UNCATEGORIZED |
???? jump to the top
Hidden categories
For several reasons, such as the type of audience or having an NSFW tag, the 500px.com website keeps these categories hidden from the public eye.
You can use these IDs and names the same way as usual categories, but you have to be aware the content is for mature users.
ID |
Name |
Enum Usage |
31 |
Boudoir |
Category.BOUDOIR |
4 |
Nude |
Category.NUDE |
???? jump to the top
Image sizes
To fetch images of different sizes, you have to provide an array of numeric IDs as a method option. Each of these IDs represents different image sizes.
Avoid hard coding these IDs in your application! ⚠️
The best practice to use them in method options, is using ImageSize
enum.
import { ImageSize } from '500px-api';
console.log(ImageSize.STANDARD_WIDTH_4096); // 15
I have no idea what the K, and S columns are stands for, but I implemented them in this package and the documentation anyway. If you have any more information about them, feel free to open a new issue to explain them.
???? jump to the top
Standard sizes
If the width or height is empty, it means that they'll be calculated automatically (consider it as auto
).
import { ImageSize } from '500px-api';
const sizes = [
// Standard width
ImageSize.STANDARD_WIDTH_1000_Q50,
ImageSize.STANDARD_WIDTH_2000_Q75,
ImageSize.STANDARD_WIDTH_4096,
// Standard height
ImageSize.STANDARD_HEIGHT_300_Q80,
ImageSize.STANDARD_HEIGHT_300,
ImageSize.STANDARD_HEIGHT_450_Q80,
ImageSize.STANDARD_HEIGHT_450_Q50,
ImageSize.STANDARD_HEIGHT_600_Q80,
ImageSize.STANDARD_HEIGHT_600,
ImageSize.STANDARD_HEIGHT_1080,
];
ID |
Width |
Height |
Quality |
K |
S |
Watermark |
Enum Usage |
23 |
1000 |
|
50 |
|
|
✖️ |
ImageSize.STANDARD_WIDTH_1000_Q50 |
24 |
2000 |
|
75 |
|
|
✖️ |
ImageSize.STANDARD_WIDTH_2000_Q75 |
15 |
4096 |
|
|
|
✔️ |
✖️ |
ImageSize.STANDARD_WIDTH_4096 |
32 |
|
300 |
80 |
|
|
✖️ |
ImageSize.STANDARD_HEIGHT_300_Q80 |
20 |
|
300 |
|
|
|
✖️ |
ImageSize.STANDARD_HEIGHT_300 |
31 |
|
450 |
80 |
|
|
✖️ |
ImageSize.STANDARD_HEIGHT_450_Q80 |
22 |
|
450 |
50 |
|
|
✖️ |
ImageSize.STANDARD_HEIGHT_450_Q50 |
33 |
|
600 |
80 |
✔️ |
|
✖️ |
ImageSize.STANDARD_HEIGHT_600_Q80 |
21 |
|
600 |
|
✔️ |
|
✖️ |
ImageSize.STANDARD_HEIGHT_600 |
6 |
|
1080 |
|
✔️ |
|
✖️ |
ImageSize.STANDARD_HEIGHT_1080 |
???? jump to the top
Longest edge sizes
Depending on the overall height and width of the image, the longest edge of the image will be set to the Longest Edge column's value, and the other edge will be considered as auto
.
import { ImageSize } from '500px-api';
const sizes = [
// Longest edge
ImageSize.LONGEST_EDGE_256,
ImageSize.LONGEST_EDGE_900,
ImageSize.LONGEST_EDGE_900_WATERMARK,
ImageSize.LONGEST_EDGE_1000_Q80,
ImageSize.LONGEST_EDGE_1080,
ImageSize.LONGEST_EDGE_1170,
ImageSize.LONGEST_EDGE_1500_Q80,
ImageSize.LONGEST_EDGE_1600,
ImageSize.LONGEST_EDGE_2000_Q80,
ImageSize.LONGEST_EDGE_2048,
ImageSize.LONGEST_EDGE_4096,
];
ID |
Longest Edge |
Quality |
K |
S |
Watermark |
Enum Usage |
30 |
256 |
|
|
|
✖️ |
ImageSize.LONGEST_EDGE_256 |
4 |
900 |
|
|
|
✖️ |
ImageSize.LONGEST_EDGE_900 |
14 |
900 |
|
✔️ |
✔️ |
✔️ |
ImageSize.LONGEST_EDGE_900_WATERMARK |
34 |
1000 |
80 |
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_1000_Q80 |
1080 |
1080 |
|
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_1080 |
5 |
1170 |
|
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_1170 |
35 |
1500 |
80 |
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_1500_Q80 |
1600 |
1600 |
|
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_1600 |
36 |
2000 |
80 |
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_2000_Q80 |
2048 |
2048 |
|
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_2048 |
4096 |
4096 |
|
✔️ |
|
✖️ |
ImageSize.LONGEST_EDGE_4096 |
???? jump to the top
Cropped sizes
Regardless of the original size of the photo, they will be cropped and will never be larger than the specified size.
import { ImageSize } from '500px-api';
const sizes = [
// Cropped
ImageSize.CROPPED_70x70,
ImageSize.CROPPED_100x100,
ImageSize.CROPPED_140x140_Q50,
ImageSize.CROPPED_200x200,
ImageSize.CROPPED_280x280,
ImageSize.CROPPED_440x440,
ImageSize.CROPPED_580x580,
ImageSize.CROPPED_600x600,
ImageSize.CROPPED_680x680,
];
ID |
Width |
Height |
Quality |
S |
Watermark |
Enum Usage |
1 |
70 |
70 |
|
|
✖️ |
ImageSize.CROPPED_70x70 |
100 |
100 |
100 |
|
|
✖️ |
ImageSize.CROPPED_100x100 |
2 |
140 |
140 |
50 |
|
✖️ |
ImageSize.CROPPED_140x140_Q50 |
200 |
200 |
200 |
|
|
✖️ |
ImageSize.CROPPED_200x200 |
3 |
280 |
280 |
|
|
✖️ |
ImageSize.CROPPED_280x280 |
440 |
440 |
440 |
|
|
✖️ |
ImageSize.CROPPED_440x440 |
11 |
580 |
580 |
|
✔️ |
✖️ |
ImageSize.CROPPED_580x580 |
600 |
600 |
600 |
|
|
✖️ |
ImageSize.CROPPED_600x600 |
13 |
680 |
680 |
|
✔️ |
✖️ |
ImageSize.CROPPED_680x680 |
???? jump to the top
Contributing
Please read the CONTRIBUTING.md file for details on our code of conduct, the process of running tests, and submitting pull requests to us.
???? jump to the top
Resources
???? jump to the top