0.0.4 โ€ข Published 2 years ago

500px-api v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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?

Who knows?

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

  • Photo
    • Discover
    • Search
    • Comments

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
IDNameEnum Usage
10AbstractCategory.ABSTRACT
29AerialCategory.AERIAL
11AnimalsCategory.ANIMALS
5Black and WhiteCategory.BLACK_AND_WHITE
1CelebritiesCategory.CELEBRITIES
15CommercialCategory.COMMERCIAL
16ConcertCategory.CONCERT
20FamilyCategory.FAMILY
14FashionCategory.FASHION
2FilmCategory.FILM
24Fine ArtCategory.FINE_ART
23FoodCategory.FOOD
3JournalismCategory.JOURNALISM
8LandscapesCategory.LANDSCAPES
12MacroCategory.MACRO
18NatureCategory.NATURE
30NightCategory.NIGHT
7PeopleCategory.PEOPLE
19Performing ArtsCategory.PERFORMING_ARTS
9City & ArchitectureCategory.CITY_AND_ARCHITECTURE
17SportCategory.SPORT
6Still LifeCategory.STILL_LIFE
21StreetCategory.STREET
26TransportationCategory.TRANSPORTATION
13TravelCategory.TRAVEL
22UnderwaterCategory.UNDERWATER
27Urban ExplorationCategory.URBAN_EXPLORATION
25WeddingCategory.WEDDING
0UncategorizedCategory.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.

IDNameEnum Usage
31BoudoirCategory.BOUDOIR
4NudeCategory.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,
];
IDWidthHeightQualityKSWatermarkEnum Usage
23100050โœ–๏ธImageSize.STANDARD_WIDTH_1000_Q50
24200075โœ–๏ธImageSize.STANDARD_WIDTH_2000_Q75
154096โœ”๏ธโœ–๏ธImageSize.STANDARD_WIDTH_4096
3230080โœ–๏ธImageSize.STANDARD_HEIGHT_300_Q80
20300โœ–๏ธImageSize.STANDARD_HEIGHT_300
3145080โœ–๏ธImageSize.STANDARD_HEIGHT_450_Q80
2245050โœ–๏ธImageSize.STANDARD_HEIGHT_450_Q50
3360080โœ”๏ธโœ–๏ธImageSize.STANDARD_HEIGHT_600_Q80
21600โœ”๏ธโœ–๏ธImageSize.STANDARD_HEIGHT_600
61080โœ”๏ธโœ–๏ธ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,
];
IDLongest EdgeQualityKSWatermarkEnum Usage
30256โœ–๏ธImageSize.LONGEST_EDGE_256
4900โœ–๏ธImageSize.LONGEST_EDGE_900
14900โœ”๏ธโœ”๏ธโœ”๏ธImageSize.LONGEST_EDGE_900_WATERMARK
34100080โœ”๏ธโœ–๏ธImageSize.LONGEST_EDGE_1000_Q80
10801080โœ”๏ธโœ–๏ธImageSize.LONGEST_EDGE_1080
51170โœ”๏ธโœ–๏ธImageSize.LONGEST_EDGE_1170
35150080โœ”๏ธโœ–๏ธImageSize.LONGEST_EDGE_1500_Q80
16001600โœ”๏ธโœ–๏ธImageSize.LONGEST_EDGE_1600
36200080โœ”๏ธโœ–๏ธImageSize.LONGEST_EDGE_2000_Q80
20482048โœ”๏ธโœ–๏ธImageSize.LONGEST_EDGE_2048
40964096โœ”๏ธโœ–๏ธ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,
];
IDWidthHeightQualitySWatermarkEnum Usage
17070โœ–๏ธImageSize.CROPPED_70x70
100100100โœ–๏ธImageSize.CROPPED_100x100
214014050โœ–๏ธImageSize.CROPPED_140x140_Q50
200200200โœ–๏ธImageSize.CROPPED_200x200
3280280โœ–๏ธImageSize.CROPPED_280x280
440440440โœ–๏ธImageSize.CROPPED_440x440
11580580โœ”๏ธโœ–๏ธImageSize.CROPPED_580x580
600600600โœ–๏ธImageSize.CROPPED_600x600
13680680โœ”๏ธโœ–๏ธ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