All Projects → dempe → pinterest-java

dempe / pinterest-java

Licence: MIT License
developers.pinterest.com/docs/getting-started/introduction/

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to pinterest-java

Bubbleactions
An open source implementation of the long press actions in the Pinterest app.
Stars: ✭ 217 (+1346.67%)
Mutual labels:  pinterest
dbt ad reporting
Fivetran's ad reporting dbt package. Combine your Facebook, Google, Pinterest, Linkedin, Twitter, Snapchat and Microsoft advertising spend using this package.
Stars: ✭ 68 (+353.33%)
Mutual labels:  pinterest
hosts
自动生成 Hosts 文件,科学上网
Stars: ✭ 30 (+100%)
Mutual labels:  pinterest
Reaper
Social media scraping / data collection tool for the Facebook, Twitter, Reddit, YouTube, Pinterest, and Tumblr APIs
Stars: ✭ 240 (+1500%)
Mutual labels:  pinterest
pinterest-php
📌 PHP client for the official Pinterest API (v1)
Stars: ✭ 50 (+233.33%)
Mutual labels:  pinterest
pinterest-pinner
Programmatically create a pin. Pinterest auto-poster (auto-pinner, autoposter, autopinner, api).
Stars: ✭ 32 (+113.33%)
Mutual labels:  pinterest
Postwill
Posting to the most popular social media from Ruby
Stars: ✭ 181 (+1106.67%)
Mutual labels:  pinterest
sharon
A lightweight and modular social sharing library
Stars: ✭ 16 (+6.67%)
Mutual labels:  pinterest
pinterest-web-scraper
Scraping Visually Similar Images from Pinterest
Stars: ✭ 26 (+73.33%)
Mutual labels:  pinterest
boardz
Create Pinterest-like boards with pure CSS, in less than 1kB.
Stars: ✭ 33 (+120%)
Mutual labels:  pinterest
Gatsby Remark Embedder
Gatsby Remark plugin to embed well known services by their URL.
Stars: ✭ 245 (+1533.33%)
Mutual labels:  pinterest
JonContextMenu
A beautiful and minimalist arc menu like the Pinterest one, written in Swift
Stars: ✭ 60 (+300%)
Mutual labels:  pinterest
CwsShareCount
PHP class to get social share count for Delicious, Facebook, Google+, Linkedin, Pinterest, Reddit, StumbleUpon and Twitter.
Stars: ✭ 13 (-13.33%)
Mutual labels:  pinterest
Pinterestlayout
Custom collection view layout inspired by Pinterest layout. Written in Swift.
Stars: ✭ 219 (+1360%)
Mutual labels:  pinterest
Skeleton
Skeleton is a Social Engineering tool attack switcher
Stars: ✭ 44 (+193.33%)
Mutual labels:  pinterest
Quickactionview
View that shows quick actions when long pressed, inspired by Pinterest
Stars: ✭ 185 (+1133.33%)
Mutual labels:  pinterest
pinterest-backend
Pinterest Clone Backend in Phoenix Framework
Stars: ✭ 19 (+26.67%)
Mutual labels:  pinterest
keyring-social-importers
A collection of importers which pull your content back from social networks, and into your own WordPress install.
Stars: ✭ 26 (+73.33%)
Mutual labels:  pinterest
react-custom-share
Social media share buttons for ReactJS. Use one of the built-in button themes or create a custom one from scratch.
Stars: ✭ 47 (+213.33%)
Mutual labels:  pinterest
PickColor
📌 Pick color in image, make placeholder color like Pinterest!
Stars: ✭ 53 (+253.33%)
Mutual labels:  pinterest

EDIT 2020-03-29

This project is no longer actively maintained. I no longer have access to the Pinterest API. Feel free to take over development. I'm happy to answer any questions.

Happy hacking! Dempe

Description

Public Java/Kotlin SDK for Pinterest's new API.

Maven

<dependency>
    <groupId>com.chrisdempewolf</groupId>
    <artifactId>pinterest-sdk</artifactId>
    <version>4.1.0</version>
</dependency>

Or check Maven Central for a list of published artifacts.

Versioning

This project uses Semantic Versioning; MAJOR.MINOR.PATCH: X.Y.Z, such that X, Y, and Z are natural numbers where an update to X indicates a breaking (API) change, to Y indicates new, backwards-compatible features were added, and to Z indicates a bug was patched. Please see the Semantic Versioning website for more information.

Examples

Quick Note on Terminology

The word "Board" on Pinterest can be somewhat confusing - does it refer to <username/board_name> or just the latter, board_name part?

Here, when I say "board", I mean the <username/board_name> combination. I will say "board name" when I'm specifically refering to the name of the Board without the prepended username portion. I believe this is the approach Pinterest takes as well.

Initialization

  • Construct a new Pinterest SDK:
 final Pinterest pinterest = new Pinterest("<INSERT_YOUR_PINTEREST_ACCESS_TOKEN>");

Pin Methods

Fetching

Available Fields

  • .withCounts()
  • .withLink()
  • .withMetadata()
  • .withNote()
  • .withURL()
  • .withColor()
  • .withAttribution()
  • .withCreatedAt()

Usage

  • To get a Pin (with all fields) via a Pin ID:
    • Example Pin ID: 525091637782793357; from URL: https://www.pinterest.com/pin/525091637782793357/
final PinResponse pin = pinterest.getPin("<PIN_ID>", new PinFields().withAll());
  • To get a Pin with only default fields (url, note, link, id) set:
final PinResponse pin = pinterest.getPin("<PIN_ID>");
  • To get a Pin with only link, created_at, and color set:
final PinResponse pin = pinterest.getPin("<PIN_ID>", new PinFields().withLink().withCreatedAt().withColor());
  • To get your own Pins (with all fields):
final Pins pins = pinterest.getMyPins(new PinFields().withAll());
pins.forEach(pin -> {System.out.println(pin);});
  • To get your own Pins (with any arbitrary field):
final Pins pins = pinterest.getMyPins(new PinFields().with("some_field"));
pins.forEach(pin -> {System.out.println(pin);});
  • To get all the Pins from a board with default fields:
    • Example Board: cdatarank/欲しいもの; from URL: https://www.pinterest.com/cdatarank/欲しいもの/
final Pins pins = pinterest.getPinsFromBoard("<BOARD>");
  • To get all the Pins from a board with all fields:
final Pins pins = pinterest.getPinsFromBoard("<BOARD>", new PinFields().withAll());
  • Paging through Pin responses:
Pins pins = pinterest.getPinsFromBoard(BOARD);
while (pins.getNextPage() != null) {
    pins = pinterest.getNextPageOfPins(pins.getNextPage());
}

Updating

List of parameters:

Field Required Description
Pin ID Yes ID of Pin to update
Board No Board to post to
Note No Pin's "note" or "description"
Link No The URL to the the Pin

(See the Pinterest API documentation for more info).

final ResponseMessageAndStatusCode response = pinterest.patchPin("<PIN_ID>", 
                                                                "(optional)<BOARD>", 
                                                                "(optional)<NOTE>", 
                                                                "(optional)<LINK>");
  • To update a Pin's note:
final ResponseMessageAndStatusCode response = pinterest.patchPin("<PIN_ID>", null, "<NOTE>", null);

Posting

Currently, only POSTing via an image URL is supported. Multi-part form and base64 encoded image uploading will be added soon.

final ResponseMessageAndStatusCode response = pinterest.postPin("<BOARD>", "<NOTE>", "<IMG_URL>", "<LINK>");

Deleting

All you need is the Pin ID and an access token with write access to the Pin question. This method returns true if the Pin was successfully deleted; false otherwise. This true/false return pattern was adopted from RestFB.

final boolean deleted = pinterest.deletePin("<PIN_ID>");

Board Methods

Fetching

Available Fields

  • .withCounts()
  • .withCreatedAt()
  • .withDescription()
  • .withID()
  • .withImage()
  • .withName()
  • .withURL()

Usage

  • To get info about a particular Board with default fields:
  • Example Board: cdatarank/欲しいもの from URL: https://www.pinterest.com/cdatarank/欲しいもの/
final BoardResponse boardResponse = pinterest.getBoard("<BOARD>");
final Board board = boardResponse.getBoard();
  • To get info about a particular Board with an arbitrary field:
final BoardResponse boardResponse = pinterest.getBoard("<BOARD>", new BoardFields().with("foo"));
final Board board = boardResponse.getBoard();
  • To get info about a particular Board with all fields:
final BoardResponse boardResponse = pinterest.getBoard("<BOARD>", new BoardFields().withAll());
final Board board = boardResponse.getBoard();
  • Paging through Board responses:
Boards boards = pinterest.getMyBoards(new BoardFields().withAll());
while (boards.getNextPage() != null) {
    boards = pinterest.getNextPageOfBoards(boards.getNextPage());
}

Posting

Note: this method requires a Board name not a Board (see terminology section for more information).

final String boardName = "foo";
final ResponseMessageAndStatusCode response = pinterest.postBoard(boardName, "<BOARD_DESCRIPTION>");

Updating

final name = "newname"; // the _actual_ name of the board
final board = "<CURRENT_BOARD>";
final ResponseMessageAndStatusCode response = pinterest.patchBoard(board, name, description);

Deleting

final Boolean deleted = pinterest.deleteBoard("<BOARD>");
assertEquals(true, deleted);

User Methods

Note: user methods only work with the authenticated user (i.e., the owner of the access token you used to initialize the Pinterest SDK).

Fetching

Available Fields

  • .withBio()
  • .withCounts()
  • .withCretedAt()
  • .withFirstName()
  • .withImage()
  • .withLastName()
  • .withURL()
  • .withUsername()

Usage

USER

To get a user with the default fields:

final User user = pinterest.getUser();

To get a user with all fields:

final User user = pinterest.getUser(new UserFields().withAll());

To get a user with an arbitrary field:

final User user = pinterest.getUser(new UserFields().with("foo"));

To get a user with first name and last name:

final User user = pinterest.getUser(new UserFields().withFirstName().withLastName());
USER'S SUGGESTED BOARDS

To get the user's list of suggested Boards (with default fields):

final Boards boards = pinterest.getUserSuggestedBoards();
  • This method takes an optional BoardFields parameter (see the Board section above for more info).
final Boards boards = pinterest.getUserSuggestedBoards(new BoardFields().withName());
USER'S BOARDS
  • Retrieving all of a user's Boards works the same way:
final Boards boards = pinterest.getUserBoards(new BoardFields().withName());
  • Paging works the same for all Boards responses, so:
Boards boards = pinterest.getUserBoards(new BoardFields().withName());
while (boards.getNextPage() != null) {
    boards = pinterest.getNextPageOfBoards(boards.getNextPage());
}
USER'S PINS
  • Similarly, to retrieve a user's Pins:
final Pins pins = pinterest.getUserPins();
  • Or...
final Pins pins = pinterest.getUserPins(new PinFields().withCreatedAt());
SEARCH USER'S PINS
  • With default fields:
final Pins pins = pinterest.searchUserPins("cucumber");
  • With select fields:
final Pins pins = pinterest.searchUserPins("cucumber", new PinFields().withNote());
  • Paging works the same for all Pins responses, so:
Pins pins = pinterest.searchUserPins("cucumber", new PinFields().withNote());
while (pins.getNextPage() != null) {
    pins = pinterest.getNextPageOfPins(pins.getNextPage());
}

USER'S FOLLOWERS

  • With default fields:
final Users users = pinterest.getFollowers();
  • With select fields:
final Users users = pinterest.getFollowers(new UserFields().withCounts().withBio());
  • Paginating:
Users users = pinterest.getFollowers(new UserFields().withCounts().withBio());
while (users.getNextPage() != null) {
    users = pinterest.getNextPageOfUsers(users.getNextPage());
}

FOLLOWERS' BOARDS

  • With default fields:
final Boards boards = pinterest.getFollowersBoards();;
  • With select fields:
final Boards boards = pinterest.getFollowersBoards(new BoardFields().withName().withURL());
  • Paginating:
Boards boards = pinterest.getFollowersBoards(new BoardFields().withName().withURL());
while (boards.getNextPage() != null) {
    boards = pinterest.getNextPageOfBoards(boards.getNextPage());
}

FOLLOWING

  • With default fields:
final Users users = pinterest.getFollowing();
  • With select fields:
final Users users = pinterest.getFollowing(new UserFields().withCounts().withBio());
  • Paginating:
Users users = pinterest.getFollowing(new UserFields().withCounts().withBio());
while (users.getNextPage() != null) {
    users = pinterest.getNextPageOfUsers(users.getNextPage());
}
SEARCH USER'S BOARDS
  • With default fields:
final Boards boards = pinterest.searchUserBoards("cucumber");
  • With select fields:
final Boards boards = pinterest.searchUserBoards("cucumber", new BoardFields().withName());
  • Paging works the same for all Boards responses, so:
Boards boards = pinterest.searchUserBoards("cucumber", new BoardFields().withName());
while (boards.getNextPage() != null) {
    boards = pinterest.getNextPageOfBoards(boards.getNextPage());
}

Posting

FOLLOW BOARD

final ResponseMessageAndStatusCode resp = pinterest.followBoard("cdatarank/my-board");
assertEquals(200L, resp.getStatusCode());

FOLLOW USER

final ResponseMessageAndStatusCode resp = pinterest.followUser("cdatarank");
if (resp.getStatusCode() != 200) {
    System.err.println(resp.getMessage());
}

Deleting

UNFOLLOW BOARD

final boolean unfollowed = pinterest.unfollowBoard("cdatarank/my-board");

UNFOLLOW USER

final boolean unfollowed = pinterest.unfollowUser("cdatarank");

Coverage

  • GET /v1/pins/<pin_id>
  • GET /v1/me/pins/<pin_id>
  • GET /v1/boards/<board_name>/pins/
  • GET /v1/me/boards/
  • DELETE /v1/pins/<pin_id>
  • POST /v1/pins/ (still missing multi-part form uploading and base64 encoded image URLs).
  • POST /v1/boards/
  • PATCH /v1/pins/<pin_id>
  • PATCH /v1/boards/<board_name>
  • DELETE /v1/boards/<board_name>
  • GET /v1/me/
  • GET /v1/me/boards/suggested/
  • GET /v1/me/boards/
  • GET /v1/me/pins/
  • GET /v1/me/search/boards/
  • GET /v1/me/search/pins/
  • GET /v1/me/followers/
  • GET /v1/me/following/boards/
  • GET /v1/me/following/interests/
  • GET /v1/me/following/users/
  • POST /v1/me/following/boards/
  • POST /v1/me/following/users/
  • DELETE /v1/me/following/boards/<board>/
  • DELETE /v1/me/following/users/<user>/

Contributing

See CONTRIBUTING.md.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].