Public Java SDK for Pinterest's new API.
<dependency>
<groupId>com.chrisdempewolf</groupId>
<artifactId>pinterest-sdk</artifactId>
<version>1.9</version>
</dependency>
- Construct a new Pinterest SDK
final Pinterest pinterest = new Pinterest("<INSERT_YOUR_PINTEREST_ACCESS_TOKEN>");
- To get a Pin (with all fields) via a Pin ID:
- Example Pin ID:
525091637782793357
from URL:https://www.pinterest.com/pin/525091637782793357/
- Example Pin ID:
final PinResponse pin = pinterest.getPin("<INSERT_PIN_ID>", new PinFields().setAll());
- To get a Pin with only default fields (URL, note, link, ID) set
final PinResponse pin = pinterest.getPin("<INSERT_PIN_ID>");
- To get a Pin with only link, created_at, and color set
final PinResponse pin = pinterest.getPin("<INSERT_PIN_ID>", new PinFields().setLink().setCreatedAt().setColor());
- To get your own Pins (with all fields):
final Pins pins = pinterest.getMyPins(new PinFields().setAll());
pins.forEach(pin -> {System.out.println(pin);});
- To get all the Pins from a board with default fields
- Example board name:
cdatarank/欲しいもの/
from URL:https://www.pinterest.com/cdatarank/欲しいもの/
- Example board name:
final Pins pins = pinterest.getPinsFromBoard("<INSERT_BOARD_NAME>");
- To get all the Pins from a board with all fields
final Pins pins = pinterest.getPinsFromBoard("<INSERT_BOARD_NAME>", new PinFields().setAll());
- Paging through Pin responses
Pins pins = pinterest.getPinsFromBoard(BOARD_NAME);
while (pins.getNextPage() != null) {
pins = pinterest.getNextPageOfPins(pins.getNextPage());
}
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.
final boolean deleted = pinterest.deletePin("<INSERT_PIN_ID>");
- To get info about a particular Board with default fields:
- Example Board name:
cdatarank/欲しいもの
from URL:https://www.pinterest.com/cdatarank/欲しいもの/
final BoardResponse boardResponse = pinterest.getBoard("<INSERT_BOARD_NAME>");
final Board board = boardResponse.getBoard();
- To get info about a particular Board with all fields:
final BoardResponse boardResponse = pinterest.getBoard("<INSERT_BOARD_NAME>", new BoardFields().setAll());
final Board board = boardResponse.getBoard();
... more to come soon. (non-GET endpoints are currently in construction)
Found a bug? Have a suggestion? Feel free to send me PR or make an issue on the repo!
To run the integration tests, put your Pinterest access token in the root of this directory in a file called .access_token
.