friendlypins.utils.rest_io module

Abstraction around the raw Pinterest REST API calls

class friendlypins.utils.rest_io.RestIO(authentication_token)[source]

Bases: object

Interface for low level REST API interactions

Parameters

authentication_token (str) – Personal API token for authenticating to REST API

delete(path)[source]

Sends a delete request to a remote endpoint

Parameters

path (str) – API endpoint to send delete request to

get(path, properties=None)[source]

Gets API data from a given sub-path

Parameters
  • path (str) – sub-path with in the REST API to query

  • properties (dict) – optional set of request properties to append to the API call

Returns

json data returned from the API endpoint

Return type

dict

get_pages(path, properties=None)[source]

Generator for iterating over paged results returned from API

Parameters
  • path (str) – sub-path with in the REST API to query

  • properties (dict) – optional set of request properties to append to the API call

Returns

json data returned from the API endpoint

Return type

dict

property headers

the HTTP headers from the most recent API operation

Type

Headers

post(path, data, properties=None)[source]

Posts API data to a given sub-path

Parameters
  • path (str) – sub-path with in the REST API to send data to

  • data (str) – form data to be posted to the API endpoint

  • properties (dict) – optional set of request properties to append to the API call

Returns

json data returned from the API endpoint

Return type

dict

refresh_headers()[source]

Forces an update to the cached headers

property root_url

canonical url for the REST API

Type

str

property token

authentication token

Type

str